(这是使用C#/ Xamarin)
是否需要使用NotificationManager.Notify()的权限。没有通知,但应该是。这是我的代码:
int myId = 123123;
Notification nt = new Notification(Resource.Drawable.Icon,"Stuff");
NotificationManager not = (NotificationManager)GetSystemService(Context.NotificationService);
not.Notify (myId, nt);
答案 0 :(得分:5)
不,发布通知不需要权限。
通知对象必须包含以下内容:
也许你错过了其中一个,因为你的构造函数只有2个参数?
在Xamarin教程中,他们使用Notification.Builder对象发布通知。也许这会起作用。
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
.SetContentTitle("Button Clicked")
.SetSmallIcon(Resource.Drawable.ic_stat_button_click)
.SetContentText(String.Format("The button has been clicked {0} times.", _count));
// Obtain a reference to the NotificationManager
NotificationManager notificationManager = (NotificationManager)GetSystemService(Context.NotificationService);
notificationManager.Notify(ButtonClickNotificationId, builder.Build());