On iOS, how can my app get the notification data that it received while the phone was in the background?

前端 未结 4 602
醉梦人生
醉梦人生 2021-01-24 06:52

Is there a way in AppDelegate to get a queue of all the notification data? (Once the user opens the app).

4条回答
  •  独厮守ぢ
    2021-01-24 07:04

    For UILocalNotification, you can get received notifications by calling following function in your AppDelegate:

    - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
    UIApplicationState state = [application applicationState];
        if (state == UIApplicationStateInactive) {
        // Application was in the background when notification was delivered.
        } 
    }
    

    If you want to find the list of local Notifications, that app has already set, check this solution.

提交回复
热议问题