image
在这里配置应用的推送通道
image
image
代码中配置
/**
* TODO 适配 Android8.0 创建通知渠道
* tips:可以写在MainActivity中,也可以写在Application中,实际上可以写在程序的任何位置,
* 只需要保证在通知弹出之前调用就可以了。并且创建通知渠道的代码只在第一次执行的时候才会创建,
* 以后每次执行创建代码系统会检测到该通知渠道已经存在了,因此不会重复创建,也并不会影响任何效率。
*/
public static final String NEW_MESSAGE = "chat";
public static final String OTHER_MESSAGE = "other";
public static void setNotificationChannel(Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
String channelId= NEW_MESSAGE;
String channelName= "新消息通知";
createNotificationChannel(context, channelId, channelName, NotificationManager.IMPORTANCE_HIGH);
channelId= OTHER_MESSAGE;
channelName= "其他通知";
createNotificationChannel(context, channelId, channelName, NotificationManager.IMPORTANCE_HIGH);
}
}
推送的时候选择通道
image
这样就能收到了