苹果推送通知设置远程通知方法重写其他方法 [英] Apple Push Notification setting up Remote Notifications method overrides other methods
问题描述
我已经正确设置我的应用程序的远程通知
使用方法
I have properly set up my app for Remote Notifications
with the method
FUNC应用程序(应用程序:UIApplication的,didReceiveRemoteNotification用户信息:[NSObject的:AnyObject],fetchCompletionHandler completionHandler:(UIBackgroundFetchResult) - GT;无效)
和它正确,现在每一个应用程序接收到一个苹果推送通知的时间处理它
。
and it processes it correctly now every time the app receives an Apple Push Notification
.
但我的问题是,这种方法被称为在所有情况了。
But my issue is that this method is being called in all instances now.
didFinishLaunchingWithOptions
似乎没有再被叫什么名字?或 launchOptions
快到了空?
didFinishLaunchingWithOptions
does not seem to be called anymore? Or the launchOptions
is coming up empty?
基本上我使用了 didReceiveRemoteNotification
作为一个包罗万象的处理任何来电通知这是我预期的目的,但是当我点击该通知本身,它触发 didReceiveRemoteNotification
一次。因此,处理通知的两倍,这是我不想要的。
Basically I used the didReceiveRemoteNotification
as a catch all to process any incoming notifications which is my intended purpose, but then when I click the notification itself, it fires the didReceiveRemoteNotification
again. Thus processing the notification twice, which I do not want.
这就是我多么希望我的应用程序来处理通知:
So this is how I want my app to handle notifications:
- 收到通知任何时候,想自动在后台处理 通知
- 当用户从外部应用程序点击通知后,跑的比
didReceiveRemoteNotification
不同的方法 - 当用户在里面的应用程序,运行速度比其他 不同的方法
- Anytime a notification is received, would like to automatically process the notification in the background
- When user clicks notification from outside app, to run a different method than the
didReceiveRemoteNotification
- When user is inside app, to run a different method than the other
推荐答案
苹果不允许你想要什么。推送通知以下列方式工作。
Apple does not allow what you want. Push notifications work in the following way
1)当应用程序没有运行,并且用户点击一个通知,应用程序启动和通知的有效载荷在功能加载的 didFinishLaunchingWithOptions
1) When the application is not running, and the user clicks a notification, the application is launched and the payload of the notification is loaded in the function didFinishLaunchingWithOptions.
2)当应用程序在后台运行,并且用户点击一个通知,应用程序变得活跃和功能的 didReceiveRemoteNotification 被调用。现在,这个函数包含通知的有效载荷。
2) When the application is running in background, and the user clicks a notification, the application becomes active and the function didReceiveRemoteNotification is called. Now this function contains the payload of the notification.
3)当应用程序正在运行,推送通知被调用时,函数 didReceiveRemoteNotification 被调用,这个函数包含通知的有效载荷。
3) When the application is running and a push notification is called, the function didReceiveRemoteNotification is called and this function contains the payload of the notification.
4)当应用程序在后台或无效状态,通知运行时接收到,没有什么可以与通知完成直到用户点击通知
4) When the app is running in background or inactive and notification is received, nothing can be done with the notifications until the user clicks the notification
这篇关于苹果推送通知设置远程通知方法重写其他方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!