gpt4 book ai didi

android - 无法读取来自 postman 的 firebase 通知

转载 作者:行者123 更新时间:2023-11-30 00:23:33 25 4
gpt4 key购买 nike

我可以从 firebase 通知面板接收通知,但不能从 POSTMAN 接收通知。
这是我在使用 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"
}

对我有用

关于android - 无法读取来自 postman 的 firebase 通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45834593/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com