无法从邮递员那里读取火力基地通知



我可以从Firebase通知面板接收通知,但不能从POSTMAN接收通知。
这是我使用邮递员
后得到的消息

{"multicast_id":5932054590706775021,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1503475843250053%00000000f9fd7ecd"}]}

这是我用来处理它的代码。

public class MyFirebaseMessagingService extends FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
if(remoteMessage.getData().size()>0){
Log.e("main hoon","opened class wahi");
Map<String, String> data = remoteMessage.getData();
//you can get your text message here.
String text= data.get("1");
sendnoti(text);
}

}
private void sendnoti(String body) {
Intent i1=new Intent(this,MainActivity.class);
i1.putExtra("word", body);
i1.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pi=PendingIntent.getActivity(this,0,i1,PendingIntent.FLAG_CANCEL_CURRENT);
Uri ns=RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder nb=new NotificationCompat.Builder(this).setSmallIcon(R.drawable.heart)
.setContentTitle("Word Of the Day")
.setContentText(body).setSmallIcon(R.drawable.heart)
.setAutoCancel(true)
.setSound(ns)
.setContentIntent(pi);
NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0,nb.build());
}
}

但我无法收到任何通知,我尝试了两种变体。

{
"to":"AAAAD3Wencs:APA91bG5eLSH6zM_AD-CnJG5a16Cj6Ydt7AaoD_42Y3laDCEQ6DjW2b7Ve6HYKaDb0KpjKfVhnhctXpdSpajpT37jszF-LqYjm1ap57euGN5zr1l2Bg****************",
"data":{
"1":"cold"
}
}

{
"to": "AAAAD3Wencs:APA91bG5eLSH6zM_AD-
CnJG5a16Cj6Ydt7AaoD_42Y3laDCEQ6DjW2b7Ve6HYKaDb0KpjKfVhnhctXpdSpajpT37jszF-
LqYjm1ap57euGN5zr1l2BgjqOL***********",
"notification": {
"title" : "title",
"body"  : "body text",
"icon"  : "ic_notification"
}
}

但是没有运气请帮忙

{
"data":{
"1": "gold"
},
"to": "/topics/NEWS"
}

为我工作

{
"to" :"e6eN8oD709M:APA91bEhusv9OdIPwTuZhd-_-rp7oMLL5LO_4RA0Q99MLYMuf_hR9-DvI_oRRDxEXsnIjUiPLnccnRkjoUZtsMzSBy7bURj-vL5vVos7dQkr*****************",
"notification" :
{
"body" : "This is a Firebase Cloud Messaging Topic Message!",
"title" : "FCM Message"
}
}

试试这个

相关内容

  • 没有找到相关文章