in android/src/main/java/com/aliyun/ams/push/AliyunPushModule.java [578:615]
public void isNotificationEnabled(String id, Promise promise) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationManager manager = (NotificationManager) mContext.getSystemService(
Context.NOTIFICATION_SERVICE);
if (!manager.areNotificationsEnabled()) {
promise.resolve(false);
return;
}
if (id == null) {
promise.resolve(true);
return;
}
List<NotificationChannel> channels = manager.getNotificationChannels();
for (NotificationChannel channel : channels) {
if (channel.getId().equals(id)) {
if (channel.getImportance() == NotificationManager.IMPORTANCE_NONE) {
promise.resolve(false);
return;
} else {
if (channel.getGroup() != null) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.P) {
NotificationChannelGroup group = manager
.getNotificationChannelGroup(channel.getGroup());
promise.resolve(!group.isBlocked());
return;
}
}
promise.resolve(true);
return;
}
}
}
// channel 未定义,返回false
promise.resolve(false);
} else {
promise.resolve(NotificationManagerCompat.from(mContext).areNotificationsEnabled());
}
}