我正在尝试使用FCM [firebase云消息传递]向我的应用程序添加推送通知功能
该通知将显示在我的Motorola Moto G6-Android 9]上>。但是,通知不会显示在我的Samsung galaxy grand Max-Android 4.4.4上
这是我的代码:
MainActivity:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { NotificationChannel channel = new NotificationChannel("MyNotifications", "MyNotifications", NotificationManager.IMPORTANCE_DEFAULT); NotificationManager manager = getSystemService(NotificationManager.class); manager.createNotificationChannel(channel); }
MyMessagingService.class:
package com......
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.NotificationManagerCompat;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
import com.innocentapps.musicplayer2.R;
public class MyMessagingService extends FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
showNotification(remoteMessage.getNotification().getTitle(), remoteMessage.getNotification().getBody());
}
public void showNotification(String title, String message) {
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, "MyNotifications")
.setContentTitle(title)
.setSmallIcon(R.drawable.ic_tap_and_play)
.setAutoCancel(true)
.setContentText(message);
NotificationManagerCompat managerCompat = NotificationManagerCompat.from(this);
managerCompat.notify(999, builder.build());
}
}
我正在尝试使用FCM [firebase云消息传递]向我的应用程序添加推送通知功能,该通知将显示在我的Motorola Moto G6-Android 9上。但是,通知将不会...
您好,该问题实际上已经解决,但手机已将其作为junk