Showing
10 changed files
with
260 additions
and
138 deletions
... | @@ -7,7 +7,7 @@ | ... | @@ -7,7 +7,7 @@ |
7 | <key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key> | 7 | <key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key> |
8 | <dict> | 8 | <dict> |
9 | <key>orderHint</key> | 9 | <key>orderHint</key> |
10 | - <integer>0</integer> | 10 | + <integer>1</integer> |
11 | </dict> | 11 | </dict> |
12 | </dict> | 12 | </dict> |
13 | </dict> | 13 | </dict> | ... | ... |
... | @@ -7,7 +7,7 @@ | ... | @@ -7,7 +7,7 @@ |
7 | <key>SwiftWarplyFramework.xcscheme_^#shared#^_</key> | 7 | <key>SwiftWarplyFramework.xcscheme_^#shared#^_</key> |
8 | <dict> | 8 | <dict> |
9 | <key>orderHint</key> | 9 | <key>orderHint</key> |
10 | - <integer>1</integer> | 10 | + <integer>0</integer> |
11 | </dict> | 11 | </dict> |
12 | </dict> | 12 | </dict> |
13 | </dict> | 13 | </dict> | ... | ... |
No preview for this file type
... | @@ -333,60 +333,67 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{ | ... | @@ -333,60 +333,67 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{ |
333 | 333 | ||
334 | } else { | 334 | } else { |
335 | if (campaigns[indexPath.row].session_uuid != nil && campaigns[indexPath.row].session_uuid != "") { | 335 | if (campaigns[indexPath.row].session_uuid != nil && campaigns[indexPath.row].session_uuid != "") { |
336 | - let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) | ||
337 | - let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController | ||
338 | - var url = "" | ||
339 | - var params = "" | ||
340 | - let isCcmsOffer = (campaigns[indexPath.row].ccms_offer != nil) && (campaigns[indexPath.row].ccms_offer != "") && (campaigns[indexPath.row].ccms_offer == "true") | ||
341 | - | ||
342 | - if (isCcmsOffer) { | ||
343 | - let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns() | ||
344 | 336 | ||
345 | - let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaigns[indexPath.row].session_uuid } | 337 | + let status = swiftApi().getNetworkStatus() |
338 | + if (status == -1 || status == 0) { | ||
339 | + self.showDialog("Δεν υπάρχει σύνδεση","Αυτή τη στιγμή βρίσκεσαι εκτός σύνδεσης. Παρακαλούμε βεβαιώσου ότι είσαι συνδεδεμένος στο διαδίκτυο και προσπάθησε ξανά.") | ||
340 | + } else { | ||
341 | + | ||
342 | + let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) | ||
343 | + let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController | ||
344 | + var url = "" | ||
345 | + var params = "" | ||
346 | + let isCcmsOffer = (campaigns[indexPath.row].ccms_offer != nil) && (campaigns[indexPath.row].ccms_offer != "") && (campaigns[indexPath.row].ccms_offer == "true") | ||
347 | + | ||
348 | + if (isCcmsOffer) { | ||
349 | + let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns() | ||
346 | 350 | ||
347 | - if (loyaltyCampaignIdExists == true) { | 351 | + let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaigns[indexPath.row].session_uuid } |
348 | - var ccmsCampaignFound:swiftApi.LoyaltyContextualOfferModel = swiftApi.LoyaltyContextualOfferModel() | 352 | + |
349 | - for item in ccmsCampaigns { | 353 | + if (loyaltyCampaignIdExists == true) { |
350 | - if (item._loyaltyCampaignId == campaigns[indexPath.row].session_uuid) { | 354 | + var ccmsCampaignFound:swiftApi.LoyaltyContextualOfferModel = swiftApi.LoyaltyContextualOfferModel() |
351 | - ccmsCampaignFound = item | 355 | + for item in ccmsCampaigns { |
356 | + if (item._loyaltyCampaignId == campaigns[indexPath.row].session_uuid) { | ||
357 | + ccmsCampaignFound = item | ||
358 | + } | ||
352 | } | 359 | } |
353 | - } | 360 | + swiftApi().logTrackersEvent("click", ("Contextual:" + (ccmsCampaignFound._sessionId))) |
354 | - swiftApi().logTrackersEvent("click", ("Contextual:" + (ccmsCampaignFound._sessionId))) | 361 | + |
355 | - | 362 | + url = swiftApi().constructCcmsUrl(campaigns[indexPath.row], ccmsCampaignFound) |
356 | - url = swiftApi().constructCcmsUrl(campaigns[indexPath.row], ccmsCampaignFound) | 363 | + params = swiftApi().constructCcmsParams(campaigns[indexPath.row], ccmsCampaignFound) |
357 | - params = swiftApi().constructCcmsParams(campaigns[indexPath.row], ccmsCampaignFound) | ||
358 | 364 | ||
359 | - } else { | 365 | + } else { |
360 | - url = swiftApi().constructCampaignUrl(campaigns[indexPath.row]) | 366 | + url = swiftApi().constructCampaignUrl(campaigns[indexPath.row]) |
361 | - params = swiftApi().constructCampaignParams(campaigns[indexPath.row]) | 367 | + params = swiftApi().constructCampaignParams(campaigns[indexPath.row]) |
362 | 368 | ||
363 | - } | 369 | + } |
364 | 370 | ||
365 | - let encoder = JSONEncoder() | 371 | + let encoder = JSONEncoder() |
366 | - encoder.outputFormatting = .prettyPrinted | 372 | + encoder.outputFormatting = .prettyPrinted |
367 | - let data = try! encoder.encode(campaigns[indexPath.row]) | 373 | + let data = try! encoder.encode(campaigns[indexPath.row]) |
368 | 374 | ||
369 | - print("CCMS_CLICK " + String(data: data, encoding: .utf8)!) | 375 | + print("CCMS_CLICK " + String(data: data, encoding: .utf8)!) |
370 | 376 | ||
371 | - } else { | 377 | + } else { |
372 | - swiftApi().logTrackersEvent("click", ("Loyalty:" + (campaigns[indexPath.row].session_uuid ?? ""))) | 378 | + swiftApi().logTrackersEvent("click", ("Loyalty:" + (campaigns[indexPath.row].session_uuid ?? ""))) |
373 | - | 379 | + |
374 | - url = swiftApi().constructCampaignUrl(campaigns[indexPath.row]) | 380 | + url = swiftApi().constructCampaignUrl(campaigns[indexPath.row]) |
375 | - params = swiftApi().constructCampaignParams(campaigns[indexPath.row]) | 381 | + params = swiftApi().constructCampaignParams(campaigns[indexPath.row]) |
376 | 382 | ||
377 | - let encoder = JSONEncoder() | 383 | + let encoder = JSONEncoder() |
378 | - encoder.outputFormatting = .prettyPrinted | 384 | + encoder.outputFormatting = .prettyPrinted |
379 | - let data = try! encoder.encode(campaigns[indexPath.row]) | 385 | + let data = try! encoder.encode(campaigns[indexPath.row]) |
380 | 386 | ||
381 | - print("GFY_CLICK " + String(data: data, encoding: .utf8)!) | 387 | + print("GFY_CLICK " + String(data: data, encoding: .utf8)!) |
382 | - } | 388 | + } |
383 | - print("CampaignUrl url onclick: " + url) | 389 | + print("CampaignUrl url onclick: " + url) |
384 | - vc.campaignUrl = url | 390 | + vc.campaignUrl = url |
385 | - vc.params = params | 391 | + vc.params = params |
386 | - self.navigationController?.pushViewController(vc, animated: true) | 392 | + self.navigationController?.pushViewController(vc, animated: true) |
387 | 393 | ||
388 | - if let sessionUuid = campaigns[indexPath.row].session_uuid { | 394 | + if let sessionUuid = campaigns[indexPath.row].session_uuid { |
389 | - getSingleCampaignAsyncRequest(sessionUuid: sessionUuid) | 395 | + getSingleCampaignAsyncRequest(sessionUuid: sessionUuid) |
396 | + } | ||
390 | } | 397 | } |
391 | 398 | ||
392 | } else { | 399 | } else { |
... | @@ -417,5 +424,25 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{ | ... | @@ -417,5 +424,25 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{ |
417 | } else { | 424 | } else { |
418 | } | 425 | } |
419 | } | 426 | } |
427 | + | ||
428 | + | ||
429 | + func showDialog(_ alertTitle: String, _ alertSubTitle: String) -> Void { | ||
430 | + | ||
431 | + let alert = UIAlertController(title: alertTitle, message: alertSubTitle, preferredStyle: .alert) | ||
432 | + alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in | ||
433 | + switch action.style{ | ||
434 | + case .default: | ||
435 | + print("default") | ||
436 | + | ||
437 | + case .cancel: | ||
438 | + print("cancel") | ||
439 | + | ||
440 | + case .destructive: | ||
441 | + print("destructive") | ||
442 | + | ||
443 | + } | ||
444 | + })) | ||
445 | + self.present(alert, animated: true, completion: nil) | ||
446 | + } | ||
420 | 447 | ||
421 | } | 448 | } | ... | ... |
... | @@ -371,68 +371,73 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{ | ... | @@ -371,68 +371,73 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{ |
371 | } | 371 | } |
372 | 372 | ||
373 | } else { | 373 | } else { |
374 | - // let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) | 374 | + let status = swiftApi().getNetworkStatus() |
375 | - // let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController | 375 | + if (status == -1 || status == 0) { |
376 | - // let url = swiftApi().constructCampaignUrl(campaign) | 376 | + self.showDialog("Δεν υπάρχει σύνδεση","Αυτή τη στιγμή βρίσκεσαι εκτός σύνδεσης. Παρακαλούμε βεβαιώσου ότι είσαι συνδεδεμένος στο διαδίκτυο και προσπάθησε ξανά.") |
377 | - // print("CampaignUrl url onclick: " + url) | 377 | + } else { |
378 | - // vc.campaignUrl = url | 378 | + // let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) |
379 | - // self.navigationController?.pushViewController(vc, animated: true) | 379 | + // let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController |
380 | - | 380 | + // let url = swiftApi().constructCampaignUrl(campaign) |
381 | - let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) | 381 | + // print("CampaignUrl url onclick: " + url) |
382 | - let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController | 382 | + // vc.campaignUrl = url |
383 | - var url = "" | 383 | + // self.navigationController?.pushViewController(vc, animated: true) |
384 | - var params = "" | 384 | + |
385 | - let isCcmsOffer = (campaign.ccms_offer != nil) && (campaign.ccms_offer != "") && (campaign.ccms_offer == "true") | 385 | + let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) |
386 | - | 386 | + let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController |
387 | - if (isCcmsOffer) { | 387 | + var url = "" |
388 | - let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns() | 388 | + var params = "" |
389 | + let isCcmsOffer = (campaign.ccms_offer != nil) && (campaign.ccms_offer != "") && (campaign.ccms_offer == "true") | ||
390 | + | ||
391 | + if (isCcmsOffer) { | ||
392 | + let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns() | ||
389 | 393 | ||
390 | - let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaign.session_uuid } | 394 | + let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaign.session_uuid } |
391 | 395 | ||
392 | - if (loyaltyCampaignIdExists == true) { | 396 | + if (loyaltyCampaignIdExists == true) { |
393 | - var ccmsCampaignFound:swiftApi.LoyaltyContextualOfferModel = swiftApi.LoyaltyContextualOfferModel() | 397 | + var ccmsCampaignFound:swiftApi.LoyaltyContextualOfferModel = swiftApi.LoyaltyContextualOfferModel() |
394 | - for item in ccmsCampaigns { | 398 | + for item in ccmsCampaigns { |
395 | - if (item._loyaltyCampaignId == campaign.session_uuid) { | 399 | + if (item._loyaltyCampaignId == campaign.session_uuid) { |
396 | - ccmsCampaignFound = item | 400 | + ccmsCampaignFound = item |
401 | + } | ||
397 | } | 402 | } |
398 | - } | 403 | + |
399 | - | 404 | + swiftApi().logTrackersEvent("click", ("Contextual:" + (ccmsCampaignFound._sessionId))) |
400 | - swiftApi().logTrackersEvent("click", ("Contextual:" + (ccmsCampaignFound._sessionId))) | 405 | + |
401 | - | 406 | + url = swiftApi().constructCcmsUrl(campaign, ccmsCampaignFound) |
402 | - url = swiftApi().constructCcmsUrl(campaign, ccmsCampaignFound) | 407 | + params = swiftApi().constructCcmsParams(campaign, ccmsCampaignFound) |
403 | - params = swiftApi().constructCcmsParams(campaign, ccmsCampaignFound) | ||
404 | 408 | ||
405 | - } else { | 409 | + } else { |
406 | - url = swiftApi().constructCampaignUrl(campaign) | 410 | + url = swiftApi().constructCampaignUrl(campaign) |
407 | - params = swiftApi().constructCampaignParams(campaign) | 411 | + params = swiftApi().constructCampaignParams(campaign) |
408 | 412 | ||
409 | - } | 413 | + } |
410 | 414 | ||
411 | - let encoder = JSONEncoder() | 415 | + let encoder = JSONEncoder() |
412 | - encoder.outputFormatting = .prettyPrinted | 416 | + encoder.outputFormatting = .prettyPrinted |
413 | - let data = try! encoder.encode(campaign) | 417 | + let data = try! encoder.encode(campaign) |
414 | 418 | ||
415 | - print("CCMS_CLICK " + String(data: data, encoding: .utf8)!) | 419 | + print("CCMS_CLICK " + String(data: data, encoding: .utf8)!) |
416 | 420 | ||
417 | - } else { | 421 | + } else { |
418 | - swiftApi().logTrackersEvent("click", ("Loyalty:" + (campaign.session_uuid ?? ""))) | 422 | + swiftApi().logTrackersEvent("click", ("Loyalty:" + (campaign.session_uuid ?? ""))) |
419 | - | 423 | + |
420 | - url = swiftApi().constructCampaignUrl(campaign) | 424 | + url = swiftApi().constructCampaignUrl(campaign) |
421 | - params = swiftApi().constructCampaignParams(campaign) | 425 | + params = swiftApi().constructCampaignParams(campaign) |
422 | 426 | ||
423 | - let encoder = JSONEncoder() | 427 | + let encoder = JSONEncoder() |
424 | - encoder.outputFormatting = .prettyPrinted | 428 | + encoder.outputFormatting = .prettyPrinted |
425 | - let data = try! encoder.encode(campaign) | 429 | + let data = try! encoder.encode(campaign) |
426 | 430 | ||
427 | - print("GFY_CLICK " + String(data: data, encoding: .utf8)!) | 431 | + print("GFY_CLICK " + String(data: data, encoding: .utf8)!) |
428 | - } | 432 | + } |
429 | - print("CampaignUrl url onclick: " + url) | 433 | + print("CampaignUrl url onclick: " + url) |
430 | - vc.campaignUrl = url | 434 | + vc.campaignUrl = url |
431 | - vc.params = params | 435 | + vc.params = params |
432 | - self.navigationController?.pushViewController(vc, animated: true) | 436 | + self.navigationController?.pushViewController(vc, animated: true) |
433 | 437 | ||
434 | - if let sessionUuid = campaign.session_uuid { | 438 | + if let sessionUuid = campaign.session_uuid { |
435 | - getSingleCampaignAsyncRequest(sessionUuid: sessionUuid) | 439 | + getSingleCampaignAsyncRequest(sessionUuid: sessionUuid) |
440 | + } | ||
436 | } | 441 | } |
437 | } | 442 | } |
438 | } | 443 | } |
... | @@ -449,5 +454,24 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{ | ... | @@ -449,5 +454,24 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{ |
449 | } else { | 454 | } else { |
450 | } | 455 | } |
451 | } | 456 | } |
457 | + | ||
458 | + func showDialog(_ alertTitle: String, _ alertSubTitle: String) -> Void { | ||
459 | + | ||
460 | + let alert = UIAlertController(title: alertTitle, message: alertSubTitle, preferredStyle: .alert) | ||
461 | + alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in | ||
462 | + switch action.style{ | ||
463 | + case .default: | ||
464 | + print("default") | ||
465 | + | ||
466 | + case .cancel: | ||
467 | + print("cancel") | ||
468 | + | ||
469 | + case .destructive: | ||
470 | + print("destructive") | ||
471 | + | ||
472 | + } | ||
473 | + })) | ||
474 | + self.present(alert, animated: true, completion: nil) | ||
475 | + } | ||
452 | 476 | ||
453 | } | 477 | } | ... | ... |
... | @@ -117,6 +117,7 @@ | ... | @@ -117,6 +117,7 @@ |
117 | - (void) sendEvent: (NSString *) eventName priority: (BOOL) priority; | 117 | - (void) sendEvent: (NSString *) eventName priority: (BOOL) priority; |
118 | - (void)updateRefreshTokenMA:(NSString*)access_token :(NSString*)refresh_token; | 118 | - (void)updateRefreshTokenMA:(NSString*)access_token :(NSString*)refresh_token; |
119 | - (NSString*)getAccessTokenM; | 119 | - (NSString*)getAccessTokenM; |
120 | +- (long)getNetworkStatusM; | ||
120 | 121 | ||
121 | @end | 122 | @end |
122 | #endif /* MyApi_h */ | 123 | #endif /* MyApi_h */ | ... | ... |
... | @@ -1841,4 +1841,10 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify"; | ... | @@ -1841,4 +1841,10 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify"; |
1841 | return [[Warply sharedService] getAccessToken2]; | 1841 | return [[Warply sharedService] getAccessToken2]; |
1842 | } | 1842 | } |
1843 | 1843 | ||
1844 | +- (long)getNetworkStatusM | ||
1845 | +{ | ||
1846 | + | ||
1847 | + return [[Warply sharedService] getNetworkStatus]; | ||
1848 | +} | ||
1849 | + | ||
1844 | @end | 1850 | @end | ... | ... |
... | @@ -471,6 +471,7 @@ WL_VERSION_INTERFACE() | ... | @@ -471,6 +471,7 @@ WL_VERSION_INTERFACE() |
471 | */ | 471 | */ |
472 | - (void)getInboxStatusWithSuccessBlock:(void (^)(int count, int newItems, int unread))success failureBlock:(void (^)(NSError *error))failure; | 472 | - (void)getInboxStatusWithSuccessBlock:(void (^)(int count, int newItems, int unread))success failureBlock:(void (^)(NSError *error))failure; |
473 | 473 | ||
474 | +- (long)getNetworkStatus; | ||
474 | 475 | ||
475 | /*! | 476 | /*! |
476 | @methodgroup Low Level API | 477 | @methodgroup Low Level API | ... | ... |
... | @@ -523,6 +523,12 @@ typedef void (^FailureResponse)(NSURLSessionDataTask * _Nullable task, NSError * | ... | @@ -523,6 +523,12 @@ typedef void (^FailureResponse)(NSURLSessionDataTask * _Nullable task, NSError * |
523 | // [[Warply sharedService] addEvent:(WLEvent*)event priority:NO]; | 523 | // [[Warply sharedService] addEvent:(WLEvent*)event priority:NO]; |
524 | } | 524 | } |
525 | 525 | ||
526 | +//- (AFNetworkReachabilityStatus)getNetworkStatus | ||
527 | +- (long)getNetworkStatus | ||
528 | +{ | ||
529 | + return (long)self.networkStatus; | ||
530 | +} | ||
531 | + | ||
526 | #pragma mark - Public Methods | 532 | #pragma mark - Public Methods |
527 | /////////////////////////////////////////////////////////////////////////////// | 533 | /////////////////////////////////////////////////////////////////////////////// |
528 | WL_VERSION_IMPLEMENTATION(WL_VERSION) | 534 | WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | ... |
... | @@ -4030,37 +4030,69 @@ public class swiftApi { | ... | @@ -4030,37 +4030,69 @@ public class swiftApi { |
4030 | } | 4030 | } |
4031 | } | 4031 | } |
4032 | 4032 | ||
4033 | + | ||
4034 | + func showDialog(_ controller: UIViewController,_ alertTitle: String, _ alertSubTitle: String) -> Void { | ||
4035 | + | ||
4036 | + let alert = UIAlertController(title: alertTitle, message: alertSubTitle, preferredStyle: .alert) | ||
4037 | + alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in | ||
4038 | + switch action.style{ | ||
4039 | + case .default: | ||
4040 | + print("default") | ||
4041 | + | ||
4042 | + case .cancel: | ||
4043 | + print("cancel") | ||
4044 | + | ||
4045 | + case .destructive: | ||
4046 | + print("destructive") | ||
4047 | + | ||
4048 | + } | ||
4049 | + })) | ||
4050 | + controller.present(alert, animated: true, completion: nil) | ||
4051 | + } | ||
4052 | + | ||
4033 | 4053 | ||
4034 | public func openQuestionnaire(_ controller: UIViewController) -> Void { | 4054 | public func openQuestionnaire(_ controller: UIViewController) -> Void { |
4035 | - for item in GlobalVariables.campaigns { | 4055 | + let status = swiftApi().getNetworkStatus() |
4036 | - if (item.offer_category == "questionnaire") { | 4056 | + if (status == -1 || status == 0) { |
4037 | - let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) | 4057 | + swiftApi().showDialog(controller, "Δεν υπάρχει σύνδεση","Αυτή τη στιγμή βρίσκεσαι εκτός σύνδεσης. Παρακαλούμε βεβαιώσου ότι είσαι συνδεδεμένος στο διαδίκτυο και προσπάθησε ξανά.") |
4038 | - let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController | 4058 | + |
4039 | - let url = swiftApi().constructCampaignUrl(item) | 4059 | + } else { |
4040 | - let params = swiftApi().constructCampaignParams(item) | 4060 | + for item in GlobalVariables.campaigns { |
4041 | - vc.campaignUrl = url | 4061 | + if (item.offer_category == "questionnaire") { |
4042 | - vc.params = params | 4062 | + let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) |
4043 | - vc.showHeader = false | 4063 | + let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController |
4044 | - controller.navigationController?.pushViewController(vc, animated: true) | 4064 | + let url = swiftApi().constructCampaignUrl(item) |
4045 | - break; | 4065 | + let params = swiftApi().constructCampaignParams(item) |
4066 | + vc.campaignUrl = url | ||
4067 | + vc.params = params | ||
4068 | + vc.showHeader = false | ||
4069 | + controller.navigationController?.pushViewController(vc, animated: true) | ||
4070 | + break; | ||
4071 | + } | ||
4046 | } | 4072 | } |
4047 | } | 4073 | } |
4048 | } | 4074 | } |
4049 | 4075 | ||
4050 | 4076 | ||
4051 | public func openPacing(_ controller: UIViewController) -> Void { | 4077 | public func openPacing(_ controller: UIViewController) -> Void { |
4052 | - for item in GlobalVariables.campaigns { | 4078 | + let status = swiftApi().getNetworkStatus() |
4053 | - if (item.offer_category == "pacing") { | 4079 | + if (status == -1 || status == 0) { |
4054 | - let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) | 4080 | + swiftApi().showDialog(controller, "Δεν υπάρχει σύνδεση","Αυτή τη στιγμή βρίσκεσαι εκτός σύνδεσης. Παρακαλούμε βεβαιώσου ότι είσαι συνδεδεμένος στο διαδίκτυο και προσπάθησε ξανά.") |
4055 | - let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController | 4081 | + |
4056 | - let url = swiftApi().constructCampaignUrl(item) | 4082 | + } else { |
4057 | - let params = swiftApi().constructCampaignParams(item, true) | 4083 | + for item in GlobalVariables.campaigns { |
4058 | - print("openPacing url: " + url) | 4084 | + if (item.offer_category == "pacing") { |
4059 | - vc.campaignUrl = url | 4085 | + let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) |
4060 | - vc.params = params | 4086 | + let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController |
4061 | - vc.showHeader = false | 4087 | + let url = swiftApi().constructCampaignUrl(item) |
4062 | - controller.navigationController?.pushViewController(vc, animated: true) | 4088 | + let params = swiftApi().constructCampaignParams(item, true) |
4063 | - break; | 4089 | + print("openPacing url: " + url) |
4090 | + vc.campaignUrl = url | ||
4091 | + vc.params = params | ||
4092 | + vc.showHeader = false | ||
4093 | + controller.navigationController?.pushViewController(vc, animated: true) | ||
4094 | + break; | ||
4095 | + } | ||
4064 | } | 4096 | } |
4065 | } | 4097 | } |
4066 | } | 4098 | } |
... | @@ -5936,17 +5968,23 @@ public class swiftApi { | ... | @@ -5936,17 +5968,23 @@ public class swiftApi { |
5936 | } | 5968 | } |
5937 | 5969 | ||
5938 | } else { | 5970 | } else { |
5939 | - swiftApi().logTrackersEvent("click", ("Loyalty:" + (campaign.session_uuid ?? ""))) | 5971 | + let status = swiftApi().getNetworkStatus() |
5940 | - | 5972 | + if (status == -1 || status == 0) { |
5941 | - let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) | 5973 | + swiftApi().showDialog(controller, "Δεν υπάρχει σύνδεση","Αυτή τη στιγμή βρίσκεσαι εκτός σύνδεσης. Παρακαλούμε βεβαιώσου ότι είσαι συνδεδεμένος στο διαδίκτυο και προσπάθησε ξανά.") |
5942 | - let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController | ||
5943 | - | ||
5944 | - vc.campaignUrl = swiftApi().constructCampaignUrl(campaign) | ||
5945 | - vc.params = swiftApi().constructCampaignParams(campaign) | ||
5946 | - controller.navigationController?.pushViewController(vc, animated: true) | ||
5947 | 5974 | ||
5948 | - if let sessionUuid = campaign.session_uuid { | 5975 | + } else { |
5949 | - getSingleCampaignAsyncRequest(sessionUuid: sessionUuid) | 5976 | + swiftApi().logTrackersEvent("click", ("Loyalty:" + (campaign.session_uuid ?? ""))) |
5977 | + | ||
5978 | + let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) | ||
5979 | + let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController | ||
5980 | + | ||
5981 | + vc.campaignUrl = swiftApi().constructCampaignUrl(campaign) | ||
5982 | + vc.params = swiftApi().constructCampaignParams(campaign) | ||
5983 | + controller.navigationController?.pushViewController(vc, animated: true) | ||
5984 | + | ||
5985 | + if let sessionUuid = campaign.session_uuid { | ||
5986 | + getSingleCampaignAsyncRequest(sessionUuid: sessionUuid) | ||
5987 | + } | ||
5950 | } | 5988 | } |
5951 | } | 5989 | } |
5952 | 5990 | ||
... | @@ -5992,19 +6030,26 @@ public class swiftApi { | ... | @@ -5992,19 +6030,26 @@ public class swiftApi { |
5992 | let isTelco = (loyaltyCampaign._type != nil && loyaltyCampaign._type == "telco") | 6030 | let isTelco = (loyaltyCampaign._type != nil && loyaltyCampaign._type == "telco") |
5993 | 6031 | ||
5994 | if (isCcmsOffer && (loyaltyCampaign.session_uuid == ccms._loyaltyCampaignId)) { | 6032 | if (isCcmsOffer && (loyaltyCampaign.session_uuid == ccms._loyaltyCampaignId)) { |
6033 | + | ||
6034 | + let status = swiftApi().getNetworkStatus() | ||
6035 | + if (status == -1 || status == 0) { | ||
6036 | + swiftApi().showDialog(controller, "Δεν υπάρχει σύνδεση","Αυτή τη στιγμή βρίσκεσαι εκτός σύνδεσης. Παρακαλούμε βεβαιώσου ότι είσαι συνδεδεμένος στο διαδίκτυο και προσπάθησε ξανά.") | ||
6037 | + | ||
6038 | + } else { | ||
5995 | 6039 | ||
5996 | - swiftApi().logTrackersEvent("click", ("Contextual:" + (ccms._sessionId))) | 6040 | + swiftApi().logTrackersEvent("click", ("Contextual:" + (ccms._sessionId))) |
5997 | 6041 | ||
5998 | - let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) | 6042 | + let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) |
5999 | - let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController | 6043 | + let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController |
6000 | - vc.campaignUrl = swiftApi().constructCcmsUrl(loyaltyCampaign, ccms) | 6044 | + vc.campaignUrl = swiftApi().constructCcmsUrl(loyaltyCampaign, ccms) |
6001 | - vc.params = swiftApi().constructCcmsParams(loyaltyCampaign, ccms) | 6045 | + vc.params = swiftApi().constructCcmsParams(loyaltyCampaign, ccms) |
6002 | - controller.navigationController?.pushViewController(vc, animated: true) | 6046 | + controller.navigationController?.pushViewController(vc, animated: true) |
6003 | 6047 | ||
6004 | - if let sessionUuid = loyaltyCampaign.session_uuid { | 6048 | + if let sessionUuid = loyaltyCampaign.session_uuid { |
6005 | - getSingleCampaignAsyncRequest(sessionUuid: sessionUuid) | 6049 | + getSingleCampaignAsyncRequest(sessionUuid: sessionUuid) |
6050 | + } | ||
6051 | + break; | ||
6006 | } | 6052 | } |
6007 | - break; | ||
6008 | 6053 | ||
6009 | } else if (isTelco && (loyaltyCampaign.session_uuid == ccms._loyaltyCampaignId)) { | 6054 | } else if (isTelco && (loyaltyCampaign.session_uuid == ccms._loyaltyCampaignId)) { |
6010 | 6055 | ||
... | @@ -7240,6 +7285,18 @@ public class swiftApi { | ... | @@ -7240,6 +7285,18 @@ public class swiftApi { |
7240 | successCallback(nil) | 7285 | successCallback(nil) |
7241 | } | 7286 | } |
7242 | } | 7287 | } |
7288 | + | ||
7289 | + | ||
7290 | + /* | ||
7291 | + AFNetworkReachabilityStatusUnknown = -1, | ||
7292 | + AFNetworkReachabilityStatusNotReachable = 0, | ||
7293 | + AFNetworkReachabilityStatusReachableViaWWAN = 1, | ||
7294 | + AFNetworkReachabilityStatusReachableViaWiFi = 2, | ||
7295 | + */ | ||
7296 | + public func getNetworkStatus() -> Int { | ||
7297 | + let instanceOfMyApi = MyApi() | ||
7298 | + return instanceOfMyApi.getNetworkStatusM() | ||
7299 | + } | ||
7243 | 7300 | ||
7244 | 7301 | ||
7245 | } | 7302 | } | ... | ... |
-
Please register or login to post a comment