构造函数 | |
| (void) | - setAPNSListener: |
| (void) | - setAPNS:succ:fail: |
| - (void) setAPNSListener: | (setAPNSListener(apnsListener:)) | NS_SWIFT_NAME |
1.1 设置 APNS 监听
| - (void) setAPNS: | (V2TIMAPNSConfig *_Nullable) | config | |
| succ: | (_Nullable V2TIMSucc) | succ | |
| fail: | (setAPNS(config:succ:fail:)) | NS_SWIFT_NAME | |
1.2 设置 APNS 推送
config -> token:苹果后台对客户端的唯一标识,需要主动调用系统 API 获取,获取方法如下:
//获取 token 代码示例
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) {
[[UIApplication sharedApplication] registerUserNotificationSettings:
[UIUserNotificationSettings settingsForTypes:
(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
else{
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];
}//收到 token 代码示例
-(void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
//回调的 deviceToken 就是需要的 token 信息
}
config -> busiId:推送证书 ID,上传推送证书(p.12)到 IM 控制台后生成。 具体步骤请参考 离线推送。