应用程序被杀后无法对通知采取行动

时间:2016-12-22 15:25:16

标签: objective-c background push-notification notifications ios10

当我的应用程序处于前台或非活动状态时,然后在收到推送通知后,我可以单击它并执行所需的操作。如果我杀了应用程序然后点击通知应用程序进入主屏幕。 Handling Push Notifications when App is Terminated从这篇文章我明白这是理想的行为。

我的通知上还附有2个可操作的按钮。如果我点击其中一个然后我没有被重定向到主屏幕,应用程序无限加载!是否有解决方法让用户进入主屏幕?

我实施的方法在应用程序被杀后不会被执行并且我收到通知

(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler

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

(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler 

另外,我在帖子上看到应用程序被杀后,如果我点击通知,则会执行didFinishLaunchingWithOptions。我在我的方法中添加了logger语句,但我没有收到它们。 任何指针都表示赞赏。

0 个答案:

没有答案