我想启用所有通知选项,但是我不能启用(请参阅sreenshot)。我安装了电报,并且默认情况下启用了所有选项。为什么以及如何?
当前我有以下代码:
import Radium from 'radium';
some = Radium(some);
const customPanelStyle = {
'background-color': 'red',
'border': '1px solid green',
':hover':{
'background': 'blue'
}
}
NotificationManager notifManager=(NotificationManager)getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel mChannel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, "My Notifications", NotificationManager.IMPORTANCE_HIGH);
// Configure the notification channel.
mChannel.setDescription("Common notifications");
mChannel.enableLights(true);
mChannel.setLightColor(Color.RED);
mChannel.setVibrationPattern(new long[]{0, 1000, 500, 1000});
mChannel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
mChannel.enableVibration(true);
notifManager.createNotificationChannel(mChannel);
}
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(getApplicationContext(), NOTIFICATION_CHANNEL_ID)
.setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setWhen(System.currentTimeMillis())
.setSmallIcon(icon)
.setColor(color)
.setTicker("")
.setContentTitle("Title")
.setContentText("ContextText")
.setContentInfo("Info")
.setVisibility(Notification.VISIBILITY_PUBLIC)
.setAutoCancel(true);
答案 0 :(得分:-1)
我将此权限添加到Android Manifest文件中。它对我有用。
<uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY" />