【发布时间】:2022-02-14 09:22:31
【问题描述】:
我最近在我的应用程序中使用了 FirebasePushNotificationPlugin,一切都很好...... 但是当我发送通知时,图像不显示,所有其他文本都显示 我已经搜索并尝试过但无济于事: 这是该工具的链接: https://github.com/CrossGeeks/FirebasePushNotificationPlugin 这是我的代码: 安卓:
[Application]
public class MainApplication : Application
{
public MainApplication(IntPtr handle, JniHandleOwnership transer) : base(handle, transer)
{
}
public override void OnCreate()
{
base.OnCreate();
//Set the default notification channel for your app when running Android Oreo
if (Build.VERSION.SdkInt >= BuildVersionCodes.O)
{
//Change for your default notification channel id here
FirebasePushNotificationManager.DefaultNotificationChannelId = "GeneralChannel";
//Change for your default notification channel name here
FirebasePushNotificationManager.DefaultNotificationChannelName = "General";
FirebasePushNotificationManager.DefaultNotificationChannelImportance = NotificationImportance.Max;
}
//If debug you should reset the token each time.
#if DEBUG
FirebasePushNotificationManager.Initialize(this, true);
#else
FirebasePushNotificationManager.Initialize(this, false);
#endif
//Handle notification when app is closed here
CrossFirebasePushNotification.Current.OnNotificationReceived += Current_OnNotificationReceived;
}
private void Current_OnNotificationReceived(object source, FirebasePushNotificationDataEventArgs e)
{
}
}
主活动:
FirebasePushNotificationManager.ProcessIntent(this, Intent);
在后端我使用了 FireBase 管理插件:
public async void SendToAllUser(Notification notification, Dictionary<string, string> MsgData)
{
var message = new Message()
{
Data = MsgData,
Topic = "all",
Notification = notification,
Apns = new ApnsConfig
{
Aps = new Aps
{
ContentAvailable = true,
MutableContent = true
}
}
};
string response = await FirebaseMessaging.DefaultInstance.SendAsync(message);
Console.WriteLine("Successfully sent message: " + response);
}
通知控制器:
[HttpPost("UserName={UserName}&Password={Password}&Key={Key}&Value={Value}")]
public ActionResult<Notification> SendToAllDevice(string UserName, string Password, string Key, string Value, Notification notification)
{
int UserRole = URole.CheckUserRolee(UserName, Password);
if (UserRole != 1)
{
return StatusCode(403);
}
var Dataa = new Dictionary<string, string>() { { Key, Value } };
SendFCMessage.SendToAllUser(notification, Dataa);
return Ok();
}
【问题讨论】:
标签: c# xamarin xamarin.forms xamarin.android