锁屏时的效果 | 在后台时的效果 |
| |
Push Notification
的 Service
。Bundle ID
不能使用通配符 *,否则将无法使用远程推送服务。Bundle ID
等其他信息,单击 Continue 进行下一步。SSL Certificate
,分别用于开发环境(Development)和生产环境(Production)的远程推送证书。Keychain Access > Certificate Assistant > Request a Certificate From a Certificate Authority
)。*.certSigningRequest
文件。*.certSigningRequest
文件。Development SSL Certificate
到本地。Production SSL Certificate
下载到本地。Sandbox
)+生产(Production
)的合并证书,可以同时作为开发环境和生产环境的证书使用。SSL Certificate
,系统会将其导入钥匙串中。Apple Development IOS Push Service
)和生产环境(Apple Push Services
)的 P12 文件。P12
文件时,请务必要为其设置密码。import ImSDK_Plusfunc application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { granted, error inif let error = error {print("Error requesting authorization for notifications: \\(error)")return}DispatchQueue.main.async {application.registerForRemoteNotifications()}}return true}// 在 AppDelegate 的回调中会返回 deviceToken,需要在登录后上报给腾讯云后台func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {// 记录下 Apple 返回的 deviceTokentuiDeviceToken = deviceToken}
#import <UserNotifications/UserNotifications.h>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {[[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions:(UNAuthorizationOptionAlert + UNAuthorizationOptionSound + UNAuthorizationOptionBadge)completionHandler:^(BOOL granted, NSError * _Nullable error) {if (error) {NSLog(@"Error requesting authorization for notifications: %@", error);return;}// 向苹果后台请求 DeviceTokendispatch_async(dispatch_get_main_queue(), ^{[application registerForRemoteNotifications];});}];return YES;}// 在 AppDelegate 的回调中会返回 deviceToken,需要在登录后上报给腾讯云后台-(void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {// 记录下 Apple 返回的 deviceToken_deviceToken = deviceToken;}
import ImSDK_Plusfunc pushRegisterIfLogin() {let config = V2TIMAPNSConfig()// 用户自己到苹果注册开发者证书,在开发者帐号中下载并生成证书(p12 文件),将生成的 p12 文件传到腾讯证书管理控制台,// 控制台会自动生成一个证书 ID,将证书 ID 传入以下 businessID 参数中。config.businessID = 1234;// 苹果后台服务器获取的 deviceTokenconfig.token = tuiDeviceToken;V2TIMManager.sharedInstance().setAPNS(config) {} fail: { code, msg in}}
#import <ImSDK_Plus/ImSDK_Plus.h>- (void)pushRegisterIfLogin {V2TIMAPNSConfig *config = [[V2TIMAPNSConfig alloc] init];// 用户自己到苹果注册开发者证书,在开发者帐号中下载并生成证书(p12 文件),将生成的 p12 文件传到腾讯证书管理控制台,// 控制台会自动生成一个证书 ID,将证书 ID 传入以下 businessID 参数中。config.businessID = 1234;// 苹果后台服务器获取的 deviceTokenconfig.token = _deviceToken;[[V2TIMManager sharedInstance] setAPNS:config succ:^{} fail:^(int code, NSString *msg) {}];}
import TUICallKit_Swiftimport TUICallEnginelet pushInfo: TUIOfflinePushInfo = TUIOfflinePushInfo()pushInfo.title = ""pushInfo.desc = "您有一个新的通话"pushInfo.iOSPushType = .apnspushInfo.ignoreIOSBadge = falsepushInfo.iOSSound = "phone_ringing.mp3"pushInfo.androidSound = "phone_ringing"// OPPO必须设置ChannelID才可以收到推送消息,这个channelID需要和控制台一致// OPPO must set a ChannelID to receive push messages. This channelID needs to be the same as the console.pushInfo.androidOPPOChannelID = "tuikit"// FCM channel ID, you need change PrivateConstants.java and set "fcmPushChannelId"pushInfo.androidFCMChannelID = "fcm_push_channel"// VIVO message type: 0-push message, 1-System message(have a higher delivery rate)pushInfo.androidVIVOClassification = 1// HuaWei message type: https://developer.huawei.com/consumer/cn/doc/development/HMSCore-Guides/message-classification-0000001149358835pushInfo.androidHuaWeiCategory = "IM"let params = TUICallParams()params.userData = "User Data"params.timeout = 30params.offlinePushInfo = pushInfoTUICallKit.createInstance().call(userId: "123456", callMediaType: .audio, params: params) {} fail: { code, message in}
#import <TUICallKit_Swift/TUICallKit_Swift-Swift.h>#import <TUICallEngine/TUICallEngine.h>- (TUICallParams *)getCallParams {TUIOfflinePushInfo *offlinePushInfo = [self createOfflinePushInfo];TUICallParams *callParams = [TUICallParams new];callParams.offlinePushInfo = offlinePushInfo;callParams.timeout = 30;return callParams;}- (TUIOfflinePushInfo *)createOfflinePushInfo {TUIOfflinePushInfo *pushInfo = [TUIOfflinePushInfo new];pushInfo.title = @"";pushInfo.desc = @"您有一个新的通话";pushInfo.iOSPushType = TUICallIOSOfflinePushTypeAPNs;pushInfo.ignoreIOSBadge = NO;pushInfo.iOSSound = @"phone_ringing.mp3";pushInfo.AndroidSound = @"phone_ringing";// OPPO必须设置ChannelID才可以收到推送消息,这个channelID需要和控制台一致// OPPO must set a ChannelID to receive push messages. This channelID needs to be the same as the console.pushInfo.AndroidOPPOChannelID = @"tuikit";// FCM channel ID, you need change PrivateConstants.java and set "fcmPushChannelId"pushInfo.AndroidFCMChannelID = @"fcm_push_channel";// VIVO message type: 0-push message, 1-System message(have a higher delivery rate)pushInfo.AndroidVIVOClassification = 1;// HuaWei message type: https://developer.huawei.com/consumer/cn/doc/development/HMSCore-Guides/message-classification-0000001149358835pushInfo.AndroidHuaWeiCategory = @"IM";return pushInfo;}[[TUICallKit createInstance] callWithUserId:@"123456"callMediaType:TUICallMediaTypeAudioparams:[self getCallParams] succ:^{} fail:^(int code, NSString * _Nullable errMsg) {}];
- application:didRegisterForRemoteNotificationsWithDeviceToken:
回调返回的是发布环境的 token,此时 businessID 需要设置生产环境的 [证书 ID ](#businessid :缺少内容)。- application:didRegisterForRemoteNotificationsWithDeviceToken:
回调返回的是开发环境的 token,此时 businessID 需要设置开发环境的证书 ID。
本页内容是否解决了您的问题?