
Device type | Custom badge supported | Remarks |
iOS | Supported | - |
Google FCM | Follows the system | Customization not supported |
// 1. Set the listener- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {// Listen for push[V2TIMManager.sharedInstance setAPNSListener:self];// Listen for conversation unread count[[V2TIMManager sharedInstance] setConversationListener:self];return YES;}// 2. Save the unread count when it changes- (void)onTotalUnreadMessageCountChanged:(UInt64)totalUnreadCount {self.unreadNumber = totalUnreadCount;}// 3. Report the custom unread count when the app goes to the background/** After the app enters the background, customize the app unread count.* If not handled, the app unread count defaults to the sum of unread counts across all conversations.* <pre>** - (uint32_t)onSetAPPUnreadCount {* return 100; // Custom unread count* }** </pre>*/- (uint32_t)onSetAPPUnreadCount {// 1. Get the custom badgeuint32_t customBadgeNumber = ...// 2. Add the Chat message unread countcustomBadgeNumber += self.unreadNumber;// 3. Report to the Chat server through Chat SDKreturn customBadgeNumber;}
import ImSDK_Plusclass AppDelegate: UIResponder, UIApplicationDelegate, V2TIMAPNSListener, V2TIMConversationListener {// Store the unread countvar unreadNumber: UInt64 = 0// 1. Set the listenerfunc application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {// Listen for pushV2TIMManager.sharedInstance()?.setAPNSListener(self)// Listen for conversation unread countV2TIMManager.sharedInstance()?.setConversationListener(self)return true}// 2. Save the unread count when it changesfunc onTotalUnreadMessageCountChanged(_ totalUnreadCount: UInt64) {self.unreadNumber = totalUnreadCount}// 3. Report the custom unread count when the app goes to the background/// After the app enters the background, customize the app unread count./// If not handled, the app unread count defaults to the sum of unread counts across all conversations./// - Returns: Custom unread countfunc onSetAPPUnreadCount() -> UInt32 {// 1. Get the custom badgevar customBadgeNumber: UInt32 = 0 // ... Replace with your custom logic// 2. Add the Chat message unread countcustomBadgeNumber += UInt32(self.unreadNumber)// 3. Report to the Chat server through Chat SDKreturn customBadgeNumber}}
Apakah halaman ini membantu?
Anda juga dapat Menghubungi Penjualan atau Mengirimkan Tiket untuk meminta bantuan.
masukan