Detect if application: didReceiveRemoteNotification: fetchCompletionHandler: was called by tapping on a notification in Notification Center

前端 未结 8 1801
北荒
北荒 2021-01-30 16:38
application: didReceiveRemoteNotification: fetchCompletionHandler:

is different from

application: didReceiveRemoteNotification:
         


        
8条回答
  •  不思量自难忘°
    2021-01-30 17:25

    In iOS 10.0+ you can use the method

    - (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler;
    

    to detect when user taps on a system-displayed alert from the NotificationCenter.

    If you implement the method above

    • - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler; will be called only when a notification is received
    • - (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler; will be called when user taps on notification

提交回复
热议问题