问题是我没有正确设置通知生成器。
public class CustomNotificationFactory extends NotificationFactory {
Context context;
String channelID = "";
public CustomNotificationFactory(Context context, String channelID) {
super(context);
this.context = context;
this.channelID = channelID;
}
@Override
public Notification createNotification(PushMessage message, int notificationId) {
if (UAStringUtil.isEmpty(message.getAlert())) {
return null;
}
NotificationCompat.Builder builder = new NotificationCompat.Builder(getContext(),channelID)
.setContentTitle(context.getResources().getString(R.string.notification_title))
.setContentText(message.getAlert())
.setAutoCancel(true)
.setSmallIcon(R.drawable.ic_notification);
builder.extend(new ActionsNotificationExtender(getContext(), message, notificationId));
return builder.build();
}
@Override
public int getNextId(PushMessage pushMessage) {
return NotificationIdGenerator.nextID();
}
@Override
public boolean requiresLongRunningTask(PushMessage message) {
return false;
}
}