更新时间:2022-11-20 23:38:25
一个简单的例子:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSDictionary *tmpDic = [launchOptions objectForKey:@"UIApplicationLaunchOptionsRemoteNotificationKey"];
//if tmpDic is not nil, then your app is launched due to an APNs push, therefore check this NSDictionary for further information
if (tmpDic != nil) {
NSLog(@" - launch options dict has something ");
NSLog(@" - badge number is %@ ", [[tmpDic objectForKey:@"aps"] objectForKey:@"badge"]);
NSLog(@" - ");
}
编辑:关于你的NSDictionary收到来自苹果的官方文档:
Edited: About the NSDictionary you received, from Apple's official documentation:
您可以访问的APS的内容
字典虽然你不应该需要
在大多数情况下,使用下面的
键:
You can access the contents of the aps dictionary—though you shouldn’t need to in most cases—using the following keys:
该词典还可以有
由供应商定义的自定义数据
根据JSON模式。该
自定义数据属性应该是
在相同的水平的APS指定
字典。然而,自定义的
属性不应该被用于大规模
数据传输,因为有一个
每个通知严格的大小限制
(256字节)和递送是不
保证的。
The dictionary may also have custom data defined by the provider according to the JSON schema. The properties for custom data should be specified at the same level as the aps dictionary. However, custom-defined properties should not be used for mass data transport because there is a strict size limit per notification (256 bytes) and delivery is not guaranteed.