即时通信工具使用推送通知,并实现了方法:
-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler{
NSLog(@"will-present");
}但是,只有在应用程序处于活动状态时才会调用通知,而不是在后台。有没有办法在通知即将出现,iPhone屏幕被锁定的情况下进行回调?
发布于 2017-05-12 19:42:45
您需要在功能中打开远程通知的后台模式

使用此方法在后台处理通知
//handle in this method when app in foreground and background func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {}
发布于 2017-05-12 19:46:27
看来我所需要的行为是不可能的。
点击此链接了解更多信息:Alarm clock app in iOS
https://stackoverflow.com/questions/43935776
复制相似问题