简体   繁体   中英

Codename One - Show number of unread messages in the app icon

Please look at the Signal icon in this screenshot:

在此处输入图片说明

My question is how to obtain the same result in a Codename One app. Suppose that my app has a variable like "int unreadMdg", how can I show the number of unread message in the app icon?

We currently only support this on iOS as it wasn't available on any Android device when we launched the feature and is still arguably flaky on Android.

For iOS support you can set the badge value via push notification (see the developer guide) or by using the API:

if(Display.getInstance().isBadgingSupported()) {
    Display.getInstance().setBadgeNumber(unreadCount);
}

This is for IOS

Use this to make it displays a specific number

// Objective-C

 [UIApplication sharedApplication].applicationIconBadgeNumber = number;

// Swift

  UIApplication.shared.applicationIconBadgeNumber = number

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM