iOS通知payload字段通知扩展参数的获取参考如下:
// 基于 OpenAPI 高级接口推送 iOS 通知PushRequest pushRequest = new PushRequest();pushRequest.setAppKey(appKey);pushRequest.setTarget("DEVICE");pushRequest.setTargetValue("xxxxxx");pushRequest.setPushType("NOTICE");pushRequest.setDeviceType("iOS");pushRequest.setTitle("Push Title");pushRequest.setBody("Push Body");// 通知扩展属性通过json map格式传入// 这里额外属性为key1 = value1, key2 = value2pushRequest.setiOSExtParameters("{\"key1\":\"value1\",\"key2\":\"value2\"}")
客户端获取额外参数参考如下:
iOS 10 +设备:
- (void)handleiOS10Notification:(UNNotification *)notification {UNNotificationRequest *request = notification.request;UNNotificationContent *content = request.content;NSDictionary *userInfo = content.userInfo;// 通知时间NSDate *noticeDate = notification.date;// 标题NSString *title = content.title;// 副标题NSString *subtitle = content.subtitle;// 内容NSString *body = content.body;// 角标int badge = [content.badge intValue];// 取得通知自定义字段内容,例:获取key为"key1"和"key2"的内容NSString *extKey1 = @"key1";NSString *extKey2 = @"key2";NSString *extValue1 = [userInfo valueForKey:extKey1];NSString *extValue1 = [userInfo valueForKey:extKey1];// 通知打开回执上报[CloudPushSDK sendNotificationAck:userInfo];NSLog(@"Notification, date: %@, title: %@, subtitle: %@, body: %@, badge: %d, extras: [%@ = %@, %@ = %@].", noticeDate, title, subtitle, body, badge, extKey1, extValue1, extKey2, extValue2);}
iOS 10 -
- (void)application:(UIApplication*)application didReceiveRemoteNotification:(NSDictionary*)userInfo {NSLog(@"Receive one notification.");// 取得APNS通知内容NSDictionary *aps = [userInfo valueForKey:@"aps"];// 内容NSString *content = [aps valueForKey:@"alert"];// badge数量NSInteger badge = [[aps valueForKey:@"badge"] integerValue];// 播放声音NSString *sound = [aps valueForKey:@"sound"];// 取得通知自定义字段内容,例:获取key为"key1"和"key2"的内容NSString *extKey1 = @"key1";NSString *extKey2 = @"key2";NSString *extValue1 = [userInfo valueForKey:extKey1];NSString *extValue1 = [userInfo valueForKey:extKey1];NSLog(@"content = [%@], badge = [%ld], sound = [%@], Extras = [%@ = %@, %@ = %@]", content, (long)badge, sound, extKey1, extValue1, extKey2, extValue2);// iOS badge 清0application.applicationIconBadgeNumber = 0;// 通知打开回执上报// [CloudPushSDK handleReceiveRemoteNotification:userInfo];(Deprecated from v1.8.1)[CloudPushSDK sendNotificationAck:userInfo];