Instantly share code, notes, and snippets.

Embed
What would you like to do?
Log notification received & clicked (Obj-C)
// tells the app that a remote notification arrived that indicates there is data to be fetched.
// ios 7+ prior to UNUserNotificationCenter
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler {
// check if the notification is from Flurry
if ([FlurryMessaging isFlurryMsg:userInfo]) {
[FlurryMessaging receivedRemoteNotification:userInfo withCompletionHandler:^{
completionHandler(UIBackgroundFetchResultNewData);
}];
}
}
// Process and handle the user's response to a delivered notification.
// ios 10+ UNUserNotificationCenterDelegate method
-(void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler API_AVAILABLE(ios(10.0)){
if ([FlurryMessaging isFlurryMsg:response.notification.request.content.userInfo]) {
[FlurryMessaging receivedNotificationResponse:response withCompletionHandler:^{
completionHandler();
// ... add your handling here
}];
}
}
// present user an alert if app is in foreground when a notification is coming
// ios 10+ UNUserNotificationCenterDelegate mehod
- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler API_AVAILABLE(ios(10.0)){
if ([FlurryMessaging isFlurryMsg:notification.request.content.userInfo]) {
[FlurryMessaging presentNotification:notification withCompletionHandler:^{
// present user an alert if app is in foreground when a notification is coming
completionHandler(UNNotificationPresentationOptionAlert);
}];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment