【发布时间】:2018-11-14 21:42:07
【问题描述】:
当我向我的设备发送推送通知时,我收到可怕的“开发者警告包“com.mycompany.applicationame”无法在频道“null”上发布通知”Toast 消息。我正在运行 Android API 27。这是我的代码:
public class UAAutoPilot extends Autopilot {
@Override
public void onAirshipReady(@NonNull UAirship airship) {
airship.getPushManager().setUserNotificationsEnabled(true);
// Android O
if (Build.VERSION.SDK_INT >= 26) {
Context context = UAirship.getApplicationContext();
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
NotificationChannel channel = new NotificationChannel("customChannel",
context.getString(R.string.custom_channel),
NotificationManager.IMPORTANCE_DEFAULT);
notificationManager.createNotificationChannel(channel);
}
// Create a customized default notification factory
CustomNotificationFactory notificationFactory;
notificationFactory = new CustomNotificationFactory(UAirship.getApplicationContext());
// Set the factory on the PushManager
airship.getPushManager()
.setNotificationFactory(notificationFactory);
airship.getPushManager()
.getNotificationFactory()
.setNotificationChannel("customChannel");
}
}
Logcat 消息:
2018-11-14 14:00:52.821 1683-13152/system_process E/NotificationService: 找不到频道 pkg=com.mycompany.applicationame,channelId=null,id=1007,tag=null, opPkg=com.mycompany.applicationame,callingUid=10081,userId=0, incomingUserId=0, 通知
通知显示,但我收到此错误消息。 UrbanAirship 的新手。我看不出我做错了什么。
【问题讨论】:
标签: android push-notification urbanairship.com