Ad

Xamarin Android Cannot Recieve Hands Up Notifications (Banner Notifications)

I'm building the notification system on my app but problem is in Andorid Os particularly Huawei p20 lite i cannot get notification Banner on top of the screen

I have tried a lot of tutorials

(https://snag.gy/xy2ImQ.jpg) Picture I want this to be true or activated

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());

    }

Local Server :

{"to":"MYTOKEN","notification":{"title":"Working Good","body":"Okok" ,"sound": "default",
      "icon": "icon_desc"},"priority":"high",
}
Ad

Answer

I found my solution i created custom Channel

internal static readonly string CHANNEL_ID = "test";

and i did set properties straight from JSON Payload file

{
   "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"
            }
        } 
}
Ad
source: stackoverflow.com
Ad