Xamarin Android 无法接收举手通知(横幅通知)
Posted
技术标签:
【中文标题】Xamarin Android 无法接收举手通知(横幅通知)【英文标题】:Xamarin Android Cannot Recieve Hands up Notifications (Banner Notifications) 【发布时间】:2019-05-26 10:19:48 【问题描述】:我正在我的应用程序上构建通知系统,但问题出在 Andorid Os 中,尤其是华为 p20 lite 我无法在屏幕顶部获得通知横幅
我已经尝试了很多教程
(https://snag.gy/xy2ImQ.jpg) 图片 我希望这是真的或激活
Xamarin:
var intent = new Intent(this, typeof(MainActivity));
intent.AddFlags(ActivityFlags.ClearTop);
intent.PutExtra("SomeSpecialKey", "some special value");
foreach (var key in data.Keys)
intent.PutExtra(key, data[key]);
var pendingIntent = PendingIntent.GetActivity(this,
MainActivity.NOTIFICATION_ID,
intent,
PendingIntentFlags.OneShot);
var notificationBuilder = new NotificationCompat.Builder(this, MainActivity.CHANNEL_ID)
.SetSmallIcon(Resource.Drawable.ic_stat_ic_notification)
.SetContentTitle(title)
.SetContentText(messageBody)
.SetPriority(5)
.SetDefaults(1)
.SetVibrate(new long[0])
.SetContentIntent(pendingIntent);
/* NotificationChannel channel = new NotificationChannel(
MainActivity.CHANNEL_ID,
new Java.Lang.String("Channel"),
NotificationImportance.High
); */
var notificationManager = NotificationManagerCompat.From(this);
notificationManager.Notify(MainActivity.NOTIFICATION_ID, notificationBuilder.Build());
本地服务器:
"to":"MYTOKEN","notification":"title":"Working Good","body":"Okok" ,"sound": "default",
"icon": "icon_desc","priority":"high",
【问题讨论】:
【参考方案1】:我找到了我创建自定义频道的解决方案
internal static readonly string CHANNEL_ID = "test";
我确实直接从 JSON Payload 文件设置了属性
"to": "fOBdGjbftTI:APA91bEV1G39J3sF-CBQMANdlW7ely-XGC8zQ9Fp00H31iHFsmxB5hcgFCMr8-Plh9w4bDHO9eDQ5Fr_SCbYjNJ93iaFvh-zcUe_e1sAKHmRo5u73vGMuGovmfvUuTIuak1xcoRTrOtQ",
"notification":
"title":"New Notification!",
"body":"Test",
"android_channel_id":"test"
,
"priority":"High",
"android":
"notification":
"sound": "default"
【讨论】:
以上是关于Xamarin Android 无法接收举手通知(横幅通知)的主要内容,如果未能解决你的问题,请参考以下文章
如何在 Xamarin/Android 上启用多个 BLE 特征通知?
Android - 所有 Android 版本都可以接收 Firebase 推送通知吗