iOS无声推送通知

时间:2018-01-04 09:23:50

标签: ios objective-c notifications

在我的应用中,我发送静音推送通知,让应用下载一些数据。这只需要在应用程序处于活动状态时完成,我不希望应用程序在后台启动并执行此操作。

我的通知使用:

aps":{"content-available" : 1 }

因此,当应用未运行时,它不会被广播。自从iOS 10/11(不确定)以来,我没有收到以下的无声通知:

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo

所以我检查了文档并看到它已被弃用,并带有以下消息:

  

NS_DEPRECATED_IOS(3_0,10_0,"使用UserNotifications框架' S - [UNUserNotificationCenterDelegate willPresentNotification:withCompletionHandler:]或 - [UNUserNotificationCenterDelegate didReceiveNotificationResponse:withCompletionHandler:用于用户可见通知和 - [UIApplicationDelegate应用:didReceiveRemoteNotification:fetchCompletionHandler :]用于静音远程通知");

现在我使用-[UIApplicationDelegate application:didReceiveRemoteNotification:fetchCompletionHandler:],但在我的控制台中,我看到了这个警告:

  

您已实施 - [application:didReceiveRemoteNotification:fetchCompletionHandler:],但您仍需要添加"远程通知"到Info.plist中支持的UIBackgroundModes列表。

但我不想要这个,因为我不想在后台启动?任何建议如何解决这个问题。

0 个答案:

没有答案