apns推送获得特定的内容

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:nilnil];
        [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:nilnil];
        [alert show];
    }
}


注:log是要获得的内容的键

posted @ 2012-08-16 10:17  Mr.Songz  阅读(208)  评论(0编辑  收藏  举报