Skip to content

Instantly share code, notes, and snippets.

@greencoder
Created May 23, 2016 22:42
Show Gist options
  • Save greencoder/f6fd198e01720de8b3a9fc06aae167fa to your computer and use it in GitHub Desktop.
Save greencoder/f6fd198e01720de8b3a9fc06aae167fa to your computer and use it in GitHub Desktop.
Campaign Fulfillment
- (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