Ho riscontrato un problema poiché alcuni dei miei dispositivi su cui sto testando la mia app non ricevono le loro notifiche e non generano eccezioni.Alcuni dispositivi non ricevono notifiche FCM
Le notifiche provengono da FCM e sto utilizzando un servizio personalizzato per mostrarle.
MyFirebaseMessaginService.java
static int count = 0;
@Override
public void onMessageReceived(final RemoteMessage remoteMessage) {
Log.i("remoteMessage",remoteMessage.toString());
switch(remoteMessage.getData().get("tipo")){
case "normal":
notificacionNormal(remoteMessage);
break;
case "imagen":
notificacionImagen(remoteMessage);
break;
case "imagen+url":
notificacionImagenUrl(remoteMessage);
break;
}
count++;
//Log.d("prueba",remoteMessage.getData().get("imagen"));
}
private void notificacionImagenUrl(RemoteMessage remoteMessage) {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(remoteMessage.getData().get("url")));
PendingIntent pendingIntent = PendingIntent.getActivity(this, 100, i, PendingIntent.FLAG_ONE_SHOT);
NotificationManager notificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notif = new Notification.Builder(this)
.setContentIntent(pendingIntent)
.setContentTitle(remoteMessage.getNotification().getTitle())
.setContentText(remoteMessage.getNotification().getBody())
.setSmallIcon(R.mipmap.ic_launcher)
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher))
.setStyle(new Notification.BigPictureStyle().bigPicture(getImagae(remoteMessage.getData().get("imagen"))))
.build();
notif.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(count, notif);
}
Al momento succede solo in un dispositivo radicata con Android 6.0.1 Speranza u mi può aiutare :)
EDIT: La richiesta di notifica HTTP mando :
"to": "/topics/general",
"notification" : {
"title": "title",
"body": "body",
},
"data": {
"tipo": "normal",
}
Puoi pubblicare il tuo payload campione? Inoltre, sta succedendo solo su alcuni dispositivi specifici o è casuale su tutti i tuoi dispositivi di test? –
@intj sta accadendo solo su un dispositivo di test e non sta ottenendo anithing (non ha nemmeno raggiunto il primo log) e i servizi di riproduzione sono installati sul dispositivo. Cosa vuoi dire con un gioco? –
Sei sicuro che il 'registrationToken' corrispondente a quel dispositivo sia un destinatario? Mi riferivo al carico utile della notifica. O stai inviando notifiche tramite la console di Firebase? –