我正在使用具有云功能的firestore消息传递服务来构建通知并将其发送到设备,无论应用程序是在后台还是前台,这都有效,但是如果应用程序位于后台或已杀死,这是应用程序在后台或被杀死时我的onMessageReceived(RemoteMessage)方法的日志
Log.d(MYTAG,"profile image : " + profileImage);
Log.d(MYTAG,"name : " + author);
D/FBMsg: profile image :
D/FBMsg: name : Jon Doe
这里'作者'和' profileImage'两个字符串和作者都很好,但个人资料图片是空白的。这是相同的日志,但是从应用程序处于前台时
D/FBMsg: profile image : https://firebasestorage.googleapis.com/v0/b/
aimessage-b2502.appspot.com/o/abS2f5qVHyOpj8kN3ViEnYVTTjn1%2Fprofile_pics
%2F20180612_101808?alt=media&token=a95f4c25-af15-42fe-9629-b44815658cac
D/FBMsg: name : Jon Doe
我已经阅读了文档,如果应用程序位于前台,我会收到通知有效负载,但数据有效负载无论如何都会触发,而且无法解释为什么我会参与其中数据而不是所有人都可以帮助吗? 这是我发送通知的云功能
const payload = {
data : {
TITLE : senderName + " sent you a message.",
BODY : notificationBody,
USER_NAME : senderName,
USER_NUMBER : message['sender'],
USER_IMAGE : senderImage,
CLICK_ACTION : "MessageListActivity",
MESSAGE : message['message'],
IMAGE : imageMessage,
TYPE : message['data_type']
}
}
以下是我如何检索值加上日志和输出
String author = data.get("USER_NAME");
String title = data.get("TITLE");
String body = data.get("BODY");
String id = data.get("USER_NUMBER");
String message = data.get("MESSAGE");
String type = data.get("TYPE");
String image = data.get("IMAGE");
String profileImage = data.get("USER_IMAGE");
String shortMessage = "";
Intent intent;
Log.d(MYTAG,"sent image : " + image);
Log.d(MYTAG,"title : " + title);
Log.d(MYTAG,"body : " + body);
Log.d(MYTAG,"id : " + id);
Log.d(MYTAG,"message : " + message);
Log.d(MYTAG,"type : " + type);
Log.d(MYTAG,"image : " + image);
Log.d(MYTAG,"profile image : " + profileImage);
后台输出中的应用
D/FBMsg:sent image :
D/FBMsg: title : Jon Doe sent you a message.
D/FBMsg: body : Hi
D/FBMsg: id : abS2f5qVHyOpj8kN3ViEnYVTTjn1
D/FBMsg: message : Hi
D/FBMsg: type : TEXT
D/FBMsg: image :
D/FBMsg: profile image :
应用程序位于前景输出
D/FBMsg: sent image :
D/FBMsg: title : Jon Doe sent you a message.
D/FBMsg: body : Fvrvvr
D/FBMsg: id : abS2f5qVHyOpj8kN3ViEnYVTTjn1
D/FBMsg: message : Fvrvvr
D/FBMsg: type : TEXT
D/FBMsg: image :
D/FBMsg: profile image : https://firebasestorage.googleapis.com/v0/b/
aimessageb2502.appspot.com/o/abS2f5qVHyOpj8kN3ViEnYVTTjn1%2F
profile_pics%2F20180612_101808?alt=media&token=a95f4c25-af15-42fe-9629-
b44815658cac
似乎它只是不喜欢网址的任何想法?