Created
May 23, 2016 22:42
-
-
Save greencoder/f6fd198e01720de8b3a9fc06aae167fa to your computer and use it in GitHub Desktop.
Campaign Fulfillment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)campaignKit:(CKManager *)manager didFindCampaign:(CKCampaign *)campaign { | |
UIApplication *app = [UIApplication sharedApplication]; | |
// If app is in background, show a local notification. If in foreground, | |
// show an alert view | |
if (app.applicationState != UIApplicationStateActive) { | |
UILocalNotification *notification = [campaign buildLocalNotification]; | |
[app presentLocalNotificationNow:notification]; | |
} | |
else { | |
[CKCampaignAlertView showWithCampaign:campaign andCompletion:^{ | |
[self showCampaign:campaign]; | |
}]; | |
} | |
} | |
- (void)showCampaign:(CKCampaign *)campaign { | |
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; | |
UINavigationController *navController = [storyboard instantiateViewControllerWithIdentifier:@"DealNavController"]; | |
WebContentViewController *webVC = (WebContentViewController *)navController.childViewControllers.firstObject; | |
webVC.htmlContent = campaign.content.body; | |
[self.campaignKitManager setCampaignViewed:campaign]; | |
[self.window.rootViewController presentViewController:navController animated:YES completion:nil]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment