Java 如何显示来自其他用户的通知?
我在使用android qiscus sdk实现通知时遇到一些问题 我创建类FirebaseService扩展FirebaseMessagingServiceJava 如何显示来自其他用户的通知?,java,android,android-layout,material-design,chat,Java,Android,Android Layout,Material Design,Chat,我在使用android qiscus sdk实现通知时遇到一些问题 我创建类FirebaseService扩展FirebaseMessagingService 然而,当有人和我聊天时,我无法在onMessageReceived中接收到消息。有人能帮我吗?谢谢。您必须使用QiscusFirebaseService进行扩展,并将remoteMessege设置为handleMessageReceived try { NotificationManager notificatio
然而,当有人和我聊天时,我无法在onMessageReceived中接收到消息。有人能帮我吗?谢谢。您必须使用QiscusFirebaseService进行扩展,并将remoteMessege设置为handleMessageReceived
try {
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
String title = "" + "";
PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
Uri defaultSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
if (defaultSound == null) {
defaultSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
if (defaultSound == null) {
defaultSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
}
}
Notification.Builder builder = new Notification.Builder(context)
.setContentTitle(title)
.setContentText(message)
.setContentIntent(intent)
.setSmallIcon(icon)
.setLights(Color.BLUE, 20, 80)
.setAutoCancel(true)
.setSound(defaultSound);
if (bitmap != null) {
builder.setLargeIcon(bitmap);
}
Notification not = new Notification.BigTextStyle(builder).bigText(message).build();
if (defaultSound == null) {
not.defaults |= Notification.DEFAULT_VIBRATE;
not.defaults |= Notification.DEFAULT_SOUND;
}
notificationManager.notify(0, not);
}
catch (Exception e) {
e.printStackTrace();
}`
QiscusFirebaseService.handleMessageReceivedremoteMessage
举个详细的例子
我希望它能帮助你解决你的问题