HI我正在使用 cordova 插件“FCM”推送通知,我能够显示通知的文本,当从服务器推送通知时,事情工作正常,但我不能显示图像,我有一个包含图像的jpg格式的URL,有人能告诉他如何显示图像吗
我导入了import { FCM } from '@ionic-native/fcm';
if (device.platform == "Android" || device.platform == "iOS") {
fcm.getToken().then(token => {
//console.log("FCM Token generation :: " + token);
fcm.onNotification().subscribe(data => {
if (data.wasTapped) {
// console.log("onNotification", JSON.stringify(data))
}
else {
// console.log("onNotification", JSON.stringify(data))
}
});
}
我需要显示图像,有人能帮我吗
这是我的c#代码,我用来把数据推到firebase控制台
var fcmUrl = "https://fcm.googleapis.com/fcm/send";
var serverKey = "serverKey";
var senderId = "9866455";
string sResponseFromServer = string.Empty;
try
{
//WebRequest request = WebRequest.Create(fcmUrl);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(fcmUrl);
request.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;
request.Method = "post";
request.ContentType = "application/json";
var data = new
{
to = "/topics/test2",
notification = new
{
title = "Notification With Image",
body = " Message from Data",
image = "https://abcdedd.com/assets/images/loginheaderlogo.png"
}
};
var json = JsonConvert.SerializeObject(data);
Byte[] byteArray = Encoding.UTF8.GetBytes(json);
request.Headers.Add(string.Format("Authorization: key={0}", serverKey));
request.Headers.Add(string.Format("Sender: id={0}", senderId));
request.ContentLength = byteArray.Length;
request.Proxy = WebRequest.DefaultWebProxy;
request.Proxy.Credentials = CredentialCache.DefaultNetworkCredentials;
using (Stream dataStream = request.GetRequestStream())
{
dataStream.Write(byteArray, 0, byteArray.Length);
using (WebResponse tResponse = request.GetResponse())
{
using (Stream dataStreamResponse = tResponse.GetResponseStream())
{
using (StreamReader tReader = new StreamReader(dataStreamResponse))
{
sResponseFromServer = tReader.ReadToEnd();
}
}
}
}
var result = JsonConvert.DeserializeObject(sResponseFromServer);
Console.WriteLine(result.ToString());
}
catch (Exception ex)
{
var e = ex.Message;
Console.WriteLine(ex.ToString());
}
2条答案
按热度按时间envsm3lx1#
对于节点:工作示例:
fykwrbwg2#
这是我们可以从 Postman 处检查的通知内容,以便在通知上显示图像。您必须在清单文件中为此**https://testdemo.page.link**url添加
intent-filter