iphone 启动选项 [英] iphone Launch Options

查看:22
本文介绍了iphone 启动选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在推送通知后我没有得到任何启动选项;这是我拥有的代码,但似乎没有在调试区域打印 NSLog.

im not getting any launch options after a push notification; heres the code i have but non of the NSLogs seem to print in the debug area.

UILocalNotification *localNotif =
[launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];

if (localNotif) {
    NSString *itemName = [localNotif.userInfo objectForKey:@"aps"];
    NSLog(@"Custom: %@", itemName);
} else {
    NSLog(@"//////////////////////////");

}

当我打开应用程序(通过按下推送通知上的视图)时,它会转到 didReceiveRemoteNotification 脚本,我不确定这是否意味着发生..

when i open the app (via pressing view on the push notification) it goes to the didReceiveRemoteNotification script, im not sure if thats meant to happen..

感谢阅读.

推荐答案

您的应用程序通过多个路径接收推送通知,具体取决于您的应用程序在收到时的状态.

Your application receives push notifications through multiple paths, depending on the state of your app when it is received.

如果您的应用未启动(甚至未在后台暂停),launchOptions 将包含通知负载(键 UIApplicationLaunchOptionsRemoteNotificationKey).

If your app is not launched (not even suspended in background), the launchOptions will contain the notification payload (key UIApplicationLaunchOptionsRemoteNotificationKey).

如果它已经在后台运行或暂停,应用程序将通过应用程序委托中的 application:didReceiveRemoteNotification: 接收通知.

If it is already running or suspended in background, the app will receive the notifications via application:didReceiveRemoteNotification: in your application delegate.

本地通知的流程是一样的(UIApplicationLaunchOptionsLocalNotificationKey in application:didFinishLaunchingWithOptions:和application:didReceiveLocalNotification:)

The process is the same for local notifications (UIApplicationLaunchOptionsLocalNotificationKey in application:didFinishLaunchingWithOptions: and application:didReceiveLocalNotification:)

这篇关于iphone 启动选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆