IMSDK
IM features a comprehensive suite of solutions including global access, one-to-one chat, group chat, message push, profile and relationship chain hosting, and account authentication. It also provides complete app access and backend management APIs.
V2TIMManager+APNSabstract
Swift - V2TIMManager
Swift

Extensions on V2TIMManager

Methods

set​APNSListener(apns​Listener:​)

public func setAPNSListener(apnsListener: V2TIMAPNSListener?)  

1.1 Set the APNS listener

set​APNS(config:​succ:​fail:​)

public func setAPNS(config: V2TIMAPNSConfig?, succ: V2TIMSucc?, fail: V2TIMFail?)  

1.2 Configure offline push

config -> token:Unique identification of the iphone device which can be obtained by actively calling the system API

// Example code showing how to obtain token
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().requestAuthorization(options: [.badge, .sound, .alert]) { granted, error in
if granted {
UIApplication.shared.registerForRemoteNotifications()
}
}
} else {
let settings = UIUserNotificationSettings(types: [.badge, .sound, .alert], categories: nil)
UIApplication.shared.registerUserNotificationSettings(settings)
UIApplication.shared.registerForRemoteNotifications()
}
func application(_ application: UIApplication,  didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
// The device token param is the token we needed
}

config -> busiId:Certificate ID, which is generated after uploading the push certificate (p.12) to the IM console. For specific steps, please refer to Offline Push

  • Message offline push will be enabled after call the setAPNS API successfully. If you want to customize the format of the message when receive offline message, please refer to the sendMessage API in V2TIMManager+Message.h

  • If message offline push is enabled successfully, system push notification will be poped up when receive a message after the APP enters background.

  • After the APP enters the background, the SDK will set the APP icon badge number as the sum of all conversation unreads by default. If you need to customize the unreads of the APP, please monitor the V2TIMAPNSListener callback settings.

  • The SDK will not set the APP icon badge number when the APP is not initialized or successfully logged in. In this case, if you need to set the APP icon badge number, please call the system function setting by yourself.

  • If you want to disable offline push, please set config to nil.