Showing
1 changed file
with
38 additions
and
9 deletions
... | @@ -749,7 +749,17 @@ var timer2: DispatchSourceTimer? | ... | @@ -749,7 +749,17 @@ var timer2: DispatchSourceTimer? |
749 | } else if (eventArray[1] == "loyaltyWallet") { | 749 | } else if (eventArray[1] == "loyaltyWallet") { |
750 | // event:loyaltyWallet | 750 | // event:loyaltyWallet |
751 | SwiftEventBus.post("refresh_vouchers") | 751 | SwiftEventBus.post("refresh_vouchers") |
752 | - SwiftEventBus.post("open_my_rewards") | 752 | +// SwiftEventBus.post("open_my_rewards") |
753 | + | ||
754 | + swiftApi().getUnifiedCouponsDeals { unifiedCoupons in | ||
755 | + let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) | ||
756 | + let vc = storyboard.instantiateViewController(withIdentifier: "UnifiedCouponsViewController") as! SwiftWarplyFramework.UnifiedCouponsViewController | ||
757 | + self.navigationController?.pushViewController(vc, animated: true) | ||
758 | + } failureCallback: { errorCode in | ||
759 | + let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) | ||
760 | + let vc = storyboard.instantiateViewController(withIdentifier: "UnifiedCouponsViewController") as! SwiftWarplyFramework.UnifiedCouponsViewController | ||
761 | + self.navigationController?.pushViewController(vc, animated: true) | ||
762 | + } | ||
753 | 763 | ||
754 | // let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) | 764 | // let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) |
755 | // let vc = storyboard.instantiateViewController(withIdentifier: "WalletViewController") as! SwiftWarplyFramework.WalletViewController | 765 | // let vc = storyboard.instantiateViewController(withIdentifier: "WalletViewController") as! SwiftWarplyFramework.WalletViewController |
... | @@ -803,14 +813,33 @@ var timer2: DispatchSourceTimer? | ... | @@ -803,14 +813,33 @@ var timer2: DispatchSourceTimer? |
803 | 813 | ||
804 | } else if (eventArray[1] == "activeCoupons") { | 814 | } else if (eventArray[1] == "activeCoupons") { |
805 | // event:activeCoupons | 815 | // event:activeCoupons |
806 | - swiftApi().getUnifiedCouponsDeals { unifiedCoupons in | 816 | + swiftApi().getCouponsAsync(getCouponsCallback, failureCallback: {errorCode in }) |
807 | - let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) | 817 | + |
808 | - let vc = storyboard.instantiateViewController(withIdentifier: "UnifiedCouponsViewController") as! SwiftWarplyFramework.UnifiedCouponsViewController | 818 | + func getCouponsCallback (_ couponsData: Array<swiftApi.CouponItemModel>?) -> Void { |
809 | - self.navigationController?.pushViewController(vc, animated: true) | 819 | + if (couponsData != nil) { |
810 | - } failureCallback: { errorCode in | 820 | + DispatchQueue.main.async { |
811 | - let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) | 821 | + SwiftEventBus.post("coupons_fetched") |
812 | - let vc = storyboard.instantiateViewController(withIdentifier: "UnifiedCouponsViewController") as! SwiftWarplyFramework.UnifiedCouponsViewController | 822 | + } |
813 | - self.navigationController?.pushViewController(vc, animated: true) | 823 | + } else { |
824 | + } | ||
825 | + } | ||
826 | + | ||
827 | + swiftApi().getCampaignsAsyncNew(language: "en", filters: [String : Any](), getCampaignsCallback, failureCallback: {errorCode in }) | ||
828 | + | ||
829 | + func getCampaignsCallback (_ campaignsData: Array<swiftApi.CampaignItemModel>?) -> Void { | ||
830 | + if (campaignsData != nil) { | ||
831 | + DispatchQueue.main.async { | ||
832 | + SwiftEventBus.post("campaigns_retrieved") | ||
833 | + } | ||
834 | + } else { | ||
835 | + } | ||
836 | + } | ||
837 | + | ||
838 | + DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) { | ||
839 | + let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: SwiftWarplyFramework.CouponsViewController.self)) | ||
840 | + if let vc = storyboard.instantiateViewController(withIdentifier: "CouponsViewController") as? SwiftWarplyFramework.CouponsViewController{ | ||
841 | + self.navigationController?.pushViewController(vc,animated: true) | ||
842 | + } | ||
814 | } | 843 | } |
815 | 844 | ||
816 | } | 845 | } | ... | ... |
-
Please register or login to post a comment