1:如果程序没有启动,在这里获得
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
NSDictionary *apsDict = [[launchOptions objectForKey:@"UIApplicationLaunchOptionsRemoteNotificationKey"] objectForKey:@"aps"];
NSString *apn = [NSString stringWithFormat:@"%@",[apsDict allKeys] ];
if (launchOptions) {
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:[apsDict objectForKey:@"log"] message:apn delegate:nil cancelButtonTitle:@"aps" otherButtonTitles:nil, nil];
[alert show];
}
return YES;
}
2:如果程序启动在后台,在这里获得
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
NSDictionary *apsDict = [userInfo objectForKey:@"aps"];
NSString *apn = [NSString stringWithFormat:@"%@",[apsDict allKeys] ];
if (userInfo) {
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:[apsDict objectForKey:@"log"] message:apn delegate:nil cancelButtonTitle:@"aps" otherButtonTitles:nil, nil];
[alert show];
}
}
注:log是要获得的内容的键
转载于:https://www.cnblogs.com/guangzhi405/archive/2012/08/16/2641772.html