ios - RemoteNotification 来自 launchOptions

标签 ios objective-c push-notification

在我的应用程序中,我添加了推送通知服务,一切正常。 需要在 App 未处于事件或后台模式时处理通知。

我为此添加了如下代码。在方法中

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
     [[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeSound];    
     NSDictionary *RemoteNoti =[launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
     if (RemoteNoti) {
     //your methods to process notification
     }
     return YES;
}

例如,我收到了三个通知 当应用程序未在后台或前台运行并且我点击通知时,它只会给我点击通知的详细信息。

它只提供点击通知的详细信息是正确的行为吗?或者应该有所有三个通知的详细信息 NSDictionary *RemoteNoti =[launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];

如果我遗漏了什么,请提出建议。

最佳答案

是的,这是正确的行为。您只会收到一个您选择的通知。

In dictionary containing the payload of the remote notification. > - alert: Either a string for the alert message or a dictionary with two keys: body and show-view. > - badge: A number indicating the quantity of data items to download from the provider. This number is to be displayed on the app icon. The absence of a badge property indicates that any number currently badging the icon should be removed. > - sound: The name of a sound file in the app bundle to play as an alert sound. If “default” is specified, the default sound should be played.

关于ios - RemoteNotification 来自 launchOptions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24967952/

相关文章:

iphone - 如何创建带有向左大箭头的后退按钮(如 iPod 应用程序)

iOS 后退手势关闭键盘

ios - 当应用程序未运行时,在后台以固定时间间隔重复调用函数

ios - 修改 NSObjects 的内部属性(特别是 SKPaymentTransaction)

objective-c - NSOutputStream 给出 -1 字节?

android - 通知栏自定义 View 中的动画

ios - 什么是便利构造函数。我需要保留便利构造函数返回的对象吗

objective-c - 如何使用 NSString 检测字符串是否在字符串中

ios - 推送通知不会振动且静音

android - 将推送通知接收到图书馆项目