简体   繁体   English

代号一-在应用程序图标中显示未读消息的数量

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

Please look at the Signal icon in this screenshot: 请查看此屏幕截图中的Signal图标:

在此处输入图片说明

My question is how to obtain the same result in a Codename One app. 我的问题是如何在Codename One应用程序中获得相同的结果。 Suppose that my app has a variable like "int unreadMdg", how can I show the number of unread message in the app icon? 假设我的应用程序具有“ int unreadMdg”之类的变量,如何在应用程序图标中显示未读消息的数量?

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. 我们目前仅在iOS上支持此功能,因为当我们启动该功能时,该功能在任何Android设备上均不可用,并且在Android上仍然有些不稳定。

For iOS support you can set the badge value via push notification (see the developer guide) or by using the API: 对于iOS支持,您可以通过推送通知(请参阅开发者指南)或使用API​​来设置标志值:

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

This is for IOS 这是给IOS的

Use this to make it displays a specific number 用它来显示一个特定的数字

// Objective-C // Objective-C

 [UIApplication sharedApplication].applicationIconBadgeNumber = number;

// Swift //迅捷

  UIApplication.shared.applicationIconBadgeNumber = number

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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