在这个方法里面处理获取的远程推送消息
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
// 取得 APNs 标准信息内容
NSDictionary *aps = [userInfo valueForKey:@"aps"];
NSString *content = [aps valueForKey:@"alert"]; //推送显示的内容
if (content.length != 0) {
if ([userInfo valueForKey:@"webUrl"])
{
webUrl = [userInfo valueForKey:@"webUrl"];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil
message:content
delegate:self
cancelButtonTitle:@"取消"
otherButtonTitles: @"去看看",nil];
alert.tag = 10000;
[alert show];
}
else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil
message:content
delegate:nil
cancelButtonTitle:@"知道了"
otherButtonTitles: nil];
[alert show];
}
}
}
注:有网页跳转带到网页