Push Notification
service to your existing AppID .Bundle ID
cannot use a wildcard *
, otherwise, remote push service will not be available.Bundle ID
and other information, click Continue to proceed with Next .SSL Certificate
, one for the development environment (Development) and the other for the production environment (Production) remote push certificate, as shown below:Keychain Access - Certificate Assistant - Request a Certificate From a Certificate Authority
).*.certSigningRequest
file.*.certSigningRequest
file.Development SSL Certificate
to your local machine.Production SSL Certificate
to your local machine.SSL Certificate
for the development and production environments. The system will import it into the keychain.Apple Development IOS Push Service
) and production environment (Apple Push Services
) P12
files respectively.P12
file, make sure to set a password.// Request the DeviceToken from Apple's backend- (void)registNotification{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)];}}// The deviceToken will be returned in the callback of AppDelegate, and it needs to be reported to Tencent Cloud backend after login-(void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken{// Record the deviceToken returned by Apple_deviceToken = deviceToken;}
- (void)onReportToken:(NSData *)deviceToken{if (deviceToken) {V2TIMAPNSConfig *confg = [[V2TIMAPNSConfig alloc] init];// Enterprise Certificate ID// Register a developer certificate with Apple, download and generate the certificate (P12 file) in the developer account, and upload the generated P12 file to the Tencent certificate console.// The console will automatically generate a certificate ID and pass it to the `busiId` parameter.confg.businessID = self.apnsCertificateID;confg.token = deviceToken;confg.isTPNSToken = NO;[[V2TIMManager sharedInstance] setAPNS:confg succ:^{NSLog(@"%s, succ", __func__);} fail:^(int code, NSString *msg) {NSLog(@"%s, fail, %d, %@", __func__, code, msg);}];}}
Nickname: Content
group name card
> nickname
. If neither is set, nothing is displayed.Name (Group Name): Content
Elem
contents in the message body. The offline message display effects of different Elem
are shown in the table below.Parameter | Description |
Text Elem | Directly Display Content |
Voice Elem | Display [Voice] |
File Elem | Display [File] |
Image Elem | Display [Image] |
Custom Elem |
SDKAppID
in multiple apps to the same value.// 1. Set the listener- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {// Listen for push notifications[V2TIMManager.sharedInstance setAPNSListener:self];// Listen for unread conversation counts[[V2TIMManager sharedInstance] setConversationListener:self];return YES;}// 2. Save the unread count after it changes- (void)onTotalUnreadMessageCountChanged:(UInt64)totalUnreadCount {self.unreadNumber = totalUnreadCount;}// 3. Report custom-defined unread count after the app is pushed to the background/** After the application enters the background, customize the app's unread count. If not handled, the default app unread count is the sum of all conversation unread counts* <pre>** - (uint32_t)onSetAPPUnreadCount {* return 100; // Custom-defined unread count* }** </pre>*/- (uint32_t)onSetAPPUnreadCount {// 1. Get the custom-defined badgeuint32_t customBadgeNumber = ...// 2. Add the IM message unread countcustomBadgeNumber += self.unreadNumber;// 3. Report to the IM server via IMSDKreturn customBadgeNumber;}
iOSSound
, and pass the audio filename to iOSSound
.V2TIMOfflinePushInfo *pushInfo = [[V2TIMOfflinePushInfo alloc] init];pushInfo.title = @"push title";pushInfo.iOSSound = @"phone_ringing.mp3"; // your voice file's name[[V2TIMManager sharedInstance] sendMessage:msg receiver:receiver groupID:groupID priority:V2TIM_PRIORITY_DEFAULT onlineUserOnly:NO offlinePushInfo:pushInfo progress:nil succ:^{} fail:^(int code, NSString *msg) {}];
AndroidSound
, and pass the audio filename to AndroidSound
.V2TIMOfflinePushInfo *pushInfo = [[V2TIMOfflinePushInfo alloc] init];pushInfo.title = @"push title";pushInfo.AndroidSound = @"phone_ringing"; // your voice file's name[[V2TIMManager sharedInstance] sendMessage:msg receiver:receiver groupID:groupID priority:V2TIM_PRIORITY_DEFAULT onlineUserOnly:NO offlinePushInfo:pushInfo progress:nil succ:^{} fail:^(int code, NSString *msg) {}];
title
and desc
. After setting title
, the push content will additionally display the title
content. After setting desc
, the push content will become the desc
content.V2TIMOfflinePushInfo *info = [[V2TIMOfflinePushInfo alloc] init];info.title = @"Harvy"; // Title of the offline push display.info.desc = @"You have a call invitation."; // Content of the offline push display.// receiver and groupID cannot both be empty, and only one can exist at a time[[V2TIMManager sharedInstance] sendMessage:msg receiver:receiver groupID:groupID priority:V2TIM_PRIORITY_DEFAULT onlineUserOnly:NO offlinePushInfo:pushInfo progress:nil succ:^{} fail:^(int code, NSString *msg) {}];
mutable-content
field in conjunction with NSNotification Service Extension
to customize the display content.ext
. When a user receives an offline push message to start the App, they can obtain the ext
field in the AppDelegate -> didReceiveRemoteNotification
system callback, and then redirect to the specified UI interface based on the content of the ext
field.ext
when sending the message:// Denny sets offlinePushInfo and specifies the ext field when sending the messageV2TIMMessage *msg = [[V2TIMManager sharedInstance] createTextMessage:@"Text Message"];V2TIMOfflinePushInfo *info = [[V2TIMOfflinePushInfo alloc] init];info.ext = @"jump to denny";[[V2TIMManager sharedInstance] sendMessage:msg receiver:@"vinson" groupID:nil priority:V2TIM_PRIORITY_DEFAULTonlineUserOnly:NO offlinePushInfo:info progress:^(uint32_t progress) {} succ:^{} fail:^(int code, NSString *msg) {}];
// After Vinson starts the app, the following callbacks will be received- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfofetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler {// Parsing the push extension field descif ([userInfo[@"ext"] isEqualToString:@"jump to denny"]) {// Jump to the chat interface with Denny}}
deviceToken
from Apple may fail. This problem is not found in the production environment, you can switch to the production environment for testing.desc
field during sendMessage. The desc
information will by default be displayed during push.config
parameter of the setAPNS API to nil
. This feature has been supported starting from version 5.6.1200.- application:didRegisterForRemoteNotificationsWithDeviceToken:
callback returns the production environment's token. At this time, set the `businessID` to the production environment's Certificate ID.- application:didRegisterForRemoteNotificationsWithDeviceToken:
callback will return a development environment token. At this time, the businessID needs to be set to the development environment's Certificate ID.V2TIMAPNSConfig *confg = [[V2TIMAPNSConfig alloc] init];/* Register a developer certificate with Apple, download and generate the certificate (P12 file) in the developer account, and upload the generated P12 file to the Tencent certificate console. The console will automatically generate a certificate ID and pass it to the `busiId` parameter. */// Push certificate IDconfg.businessID = sdkBusiId;confg.token = self.deviceToken;[[V2TIMManager sharedInstance] setAPNS:confg succ:^{} fail:^(int code, NSString *msg) {}];