0

Is there any way to retrieve what type (local or remote) notification fired userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler: ?

I'm working on some kind of internal analytics module for my apps. In the each app I need to send to our analytics server specific information from notification userInfo and notification type (local or remote).

To get userInfo I'm using the following code:

- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)())completionHandler {
    NSDictionary *userInfo = response.notification.request.content.userInfo;
    //app-specific logic goes here
    }

Of course when scheduling local notification, I can add specific parameter (to each app) to the userInfo to retrieve notification type. But might be more clear way exists to do what I want.

somedev
  • 791
  • 11
  • 29

1 Answers1

0

Finally I'm just checking userInfo for specific keys that are mandatory in the remote push notifications payload (ex. "aps"). For my purposes this is enough. More information about remote notification payload: https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CreatingtheNotificationPayload.html

somedev
  • 791
  • 11
  • 29