Push от HMS не появляются в трее
Настроил эту беду у huawei. Тестовые уведомления получаю. А вот с уведомлениями с php сервера проблема. Данные в onMessageReceived(@NonNull RemoteMessage remoteMessage) приходит.
public void onMessageReceived(@NonNull RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
if (!remoteMessage.getData().isEmpty()) {
sendNotification(remoteMessage);
}
}
private void sendNotification(mess) {
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
NotificationChannel channel = new NotificationChannel(PRIMARY_CHANNEL_ID, PRIMARY_CHANNEL_NAME, NotificationManager.IMPORTANCE_DEFAULT);
notificationManager.createNotificationChannel(channel);
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 1, intent, PendingIntent.FLAG_IMMUTABLE);
// Log.w("UUU", "channel: " + channel);
Bitmap largeIconBitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.icon);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, PRIMARY_CHANNEL_ID)
.setSmallIcon(R.drawable.ic_notification)
.setLargeIcon(largeIconBitmap)
.setContentTitle(TITLE_NOTIFICATION_FROM_WEBSITE)
.setContentText(NOTIFICATION_FROM_WEBSITE)
.setAutoCancel(true)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setContentIntent(pendingIntent);
notificationManager.notify(0, notificationBuilder.build());
}
Внутри sendNotification(mess) тоже вроде всё есть. А вот уведомления на телефоне нет). Кто нибудь знает куда копать?
Ответы (1 шт):
Автор решения: Олег Никифоров
→ Ссылка
Разобрался. Без BroadcastReceiver не работает.Вызвал уведомление через него и всё завелось.