通话邀请效果 | 通话记录效果 |
| |
setVOIP
接口将 token 上报到 IM 后台。Keychain Access - Certificate Assistant - Request a Certificate From a Certificate Authority
);*.certSigningRequest
文件;*.certSigningRequest
文件;voip_services.cer
,系统会将其导入钥匙串中。P12
文件。P12
文件时,请务必要为其设置密码。// 向苹果注册 VoIP Push- (void)registerForVOIPPush{_voipRegistry = [[PKPushRegistry alloc] initWithQueue:nil];_voipRegistry.delegate = self;_voipRegistry.desiredPushTypes = [NSSet setWithObject:PKPushTypeVoIP];}// 在代理方法中会返回 VoIP token,需要在登录后上报给腾讯云后台- (void)pushRegistry:(PKPushRegistry *)registry didUpdatePushCredentials:(PKPushCredentials *)pushCredentials forType:(PKPushType)type{NSData *token = pushCredentials.token;[self reportVOIPToken:token];}
- (void)reportVOIPToken:(NSData *)token{// 注意,此处的 config.certificateID 就是上传到证书到控制台后生成的证书 ID,请注意开发环境和生产环境的 ID 不一样。NSLog(@"[TUIOfflinePushManager] %s", __func__);if (token) {V2TIMVOIPConfig *config = [[V2TIMVOIPConfig alloc] init];config.token = token;config.certificateID = self.voipCertificateID;[[V2TIMManager sharedInstance] setVOIP:config succ:^{NSLog(@"%s, succ, id:%zd", __func__, config.certificateID);} fail:^(int code, NSString *desc) {NSLog(@"%s, fail, %d, %@", __func__, code, desc);}];}}
iOSPushType
字段为 V2TIM_IOS_OFFLINE_PUSH_TYPE_VOIP
来标记当前消息使用 VoIP Push。NSDictionary *ext = @{@"entity": @{@"action": @1,@"content": @"this is voip push",@"sender": @"senderid",@"nickname": @"nickName",@"faceUrl": @"",@"chatType": @(V2TIM_C2C)}};NSData *data = [NSJSONSerialization dataWithJSONObject:ext options:NSJSONWritingPrettyPrinted error:nil];V2TIMOfflinePushInfo *pushInfo = [[V2TIMOfflinePushInfo alloc] init];pushInfo.ext = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];pushInfo.iOSPushType = V2TIM_IOS_OFFLINE_PUSH_TYPE_VOIP; // 标记为 VoIP Push[V2TIMManager.sharedInstance sendMessage:messagereceiver:# your userID #groupID:# your groupID #priority:V2TIM_PRIORITY_DEFAULTonlineUserOnly:NOofflinePushInfo:pushInfoprogress:nilsucc:nilfail:nil}];
本页内容是否解决了您的问题?