首页 > 解决方案 > 无法在华为设备中显示通知

问题描述

我正在开发一个消息应用程序,我必须在每条新消息上显示通知。

在所有其他设备上它工作正常,只有在华为设备上我无法显示通知,如果用户将通知方法设置为设置->通知中的数字。

NotificationCompat.Builder notificationCompatBuilder;
Notification notification;
 notificationCompatBuilder =
                    new NotificationCompat.Builder(context, messageDefaultNotificationChannelId);
 notification = notificationCompatBuilder
                .setSmallIcon(R.drawable.ic_app_notification)
                .setContentTitle(Html.fromHtml(contentTitle))
                .setStyle(messagingStyle)
                .setSound(getDefaultURI())
                .setContentIntent(mainPendingIntent)
                .setCategory(Notification.CATEGORY_MESSAGE)
                .addAction(addReply(mainPendingIntent, notificationId, messageNotification.getDate()))
                .addAction(addMarkasRead(mainPendingIntent, notificationId))
                .setContentText(messageNotification.getMessageList().get(0).getText())
                .setDefaults(DEFAULT_ALL)
                .setNumber(number)
                .setGroup(GROUP_KEY_CHAT).build();

 notificationManager.notify(notificationId, notification);                                  

在清单中,我还添加了一些与华为设备相关的权限

 <uses-permission android:name="com.huawei.android.launcher.permission.CHANGE_BADGE"/>
 <uses-permission android:name="com.huawei.android.launcher.permission.READ_SETTINGS"/>
 <uses-permission android:name="com.huawei.android.launcher.permission.WRITE_SETTINGS"/>

有人可以帮我弄清楚如何处理华为设备中的通知。我用谷歌搜索但找不到任何解决方案。

标签: android

解决方案


推荐阅读