1

I make simple notification android app using xamarin, i want floating notification and lock screen notification enter image description here

l add users permission in manifest, also i read all reference document about notification channel however i don't know how to enable floating notification and lock screen notification in code

outlook, gmail etc. some app enable all notification when it installed

enter image description here

enter image description here

enter image description here

above screenshot is my app

i want enable all notification when installed my app necessarily Even if it is not in xamarin, a solution using kotlin or java is fine!

1 Answer 1

2

For floating notification, you should change Notification priority or NotificationChannel importance.

Android 5.0 - Android 7.1

Set notification priority to NotificationPriority.High or NotificationPriority.Max.

builder.SetPriority((int)NotificationPriority.High) 

Set ringtone and vibrations. You can use SetDefaults.

 // Turn on sound if the sound switch is on: notification.Defaults |= NotificationDefaults.Sound; // Turn on vibrate if the sound switch is on: notification.Defaults |= NotificationDefaults.Vibrate; 

Android 8.0 and higher

Set notification channel priority to NotificationImportance.High or NotificationImportance.Max.

 var channel = new NotificationChannel(CHANNEL_ID1, name, NotificationImportance.Max) { Description = description }; 

For lock notifications, you could set the Visibility.

Beginning with Android 5.0, the visibility setting is available to control how much notification content appears on the secure lock screen.

  • NotificationVisibility.Public – The full content of the notification is displayed on the secure lock screen.

  • NotificationVisibility.Private – Only essential information is displayed on the secure lock screen (such as the notification icon and the name of the app that posted it), but the rest of the notification's details are hidden. All notifications default to NotificationVisibility.Private.

Sign up to request clarification or add additional context in comments.

9 Comments

oh sorry my comment is to late, i changed notification importance and notificationvisiblity but i can get floating notification and lockscreen notification. i think change app notification settings. Is there any way i can change the notification settings through programming?
Could it be the problem that my test device is a Xiaomi?
Do you mean you could get floating notification and lockscreen notification? Which notification settings you want to change through programming?
Further investigation revealed that on xiaomi devices, apps that are not registered in the white list must be set by the user.
Your answer is correct. problem was just the Xiaomi device
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.