比应用程序收到推送并且应用程序没有运行我需要调用我的 API 的网络方法。我需要在没有来自用户的任何交互的情况下静默进行(例如单击通知或其他东西 - 没有它)
我将推送有效负载中的内容可用键设置为 1。
我该怎么做?
我实施了
func application( application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler handler: (UIBackgroundFetchResult) -> Void) {
作为测试,我添加了
UIApplication.sharedApplication().applicationIconBadgeNumber = 20
但看起来它不起作用,因为我关闭了我的应用程序并发送了一个测试通知,bagde 号码不是 20