【发布时间】:2017-05-05 08:15:16
【问题描述】:
我已经使用 volley 库在我的应用程序中创建了通知,它调用 firebase 服务器我的问题是当我在特定用户(设备)中推送通知时,更新通知仅显示并且未读通知计数未显示,所以我想未读通知计数如何显示在我的应用程序图标中。帮帮我..
My code is:
public class MyFirebaseMessagingService extends FirebaseMessagingService {
private static final String TAG="MyMessageservice";
RemoteMessage remoteMessage;
@Override
public void onMessageReceived(RemoteMessage remoteMessage){
String title=remoteMessage.getNotification().getTitle();
String message=remoteMessage.getNotification().getBody();
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
// String click_action=remoteMessage.getNotification().getClickAction();
Intent intent=new Intent(this,VisitorList.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT);
Uri notificattionSound= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationbuilder = new NotificationCompat.Builder(this);
notificationbuilder.setContentTitle(title);
notificationbuilder.setContentText(message);
notificationbuilder.setAutoCancel(true);
notificationbuilder.setSound(notificattionSound);
notificationbuilder.setSmallIcon(R.drawable.ic_launcher);
notificationbuilder.setContentIntent(pendingIntent);
notificationbuilder.setAutoCancel(true);
notificationManager.notify(0, notificationbuilder.build());
}
}
【问题讨论】:
-
我觉得这个功能需要ROM支持。 AOSP 不支持图标角落的数字。
-
如何..?Rom和AOSP是什么意思..?
-
我认为您要查找的术语“未读通知计数”是徽章计数。
-
@Anbu AOSP 意味着 sdk 类似的东西,我同意 AL 的观点。很多厂商可能会实现这个功能,但我认为他们不会给你这个优先级来改变这个,如果你有这个权限,主屏幕会有多大。
标签: android firebase push-notification android-volley android-notifications