10

내 응용 프로그램을 테스트하고있는 장치 중 일부에서 알림을받지 못하고 예외가 발생하지 않으므로 문제가 있습니다.일부 장치는 FCM 알림을 수신하지 않습니다.

알림은 FCM에서 제공되며 사용자 지정 서비스를 사용하여 표시하고 있습니다.

단지 안드로이드 6.0.1 희망을 뿌리 장치에서 일어나는 순간 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); 

} 

u는 나를 도울 수 :

이 편집 : 는 알림 HTTP 요청 I 보내 :

"to": "/topics/general", 
     "notification" : { 
      "title": "title", 
      "body": "body", 
     }, 
     "data": { 
      "tipo": "normal", 
     } 
+0

샘플 페이로드를 게시 할 수 있습니까? 또한 일부 특정 장치에서만 발생하거나 모든 테스트 장치에서 무작위로 발생합니까? –

+0

@intj 하나의 테스트 장치에서만 일어나는 일이며 anithing을받지 못합니다 (첫 번째 로그에 도달하지 못함). 그리고 재생 서비스가 장치에 설치됩니다. Wath는 재생 목록을 의미합니까? –

+0

해당 장치에 해당하는 'registrationToken'이 수신자입니까? 나는 통보 페이로드를 언급했다. 아니면 Firebase 콘솔을 통해 알림을 보내고 있습니까? –

답변

1

테스트 할 수있는 장치 중 일부는 구글 플레이 서비스 또는 그것의 업데이트 된 버전. 귀하의 활동에서 Google Play 서비스를 확인하십시오. 이 기능을 대답으로 사용할 수 있습니다. here :

protected boolean checkPlayServices() { 
final int resultCode = 

GooglePlayServicesUtil.isGooglePlayServicesAvailable(activity()); 
    if (resultCode != ConnectionResult.SUCCESS) { 
     if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) { 
      Dialog dialog = GooglePlayServicesUtil.getErrorDialog(resultCode, activity(), 
        PLAY_SERVICES_RESOLUTION_REQUEST); 
      if (dialog != null) { 
       dialog.show(); 
       dialog.setOnDismissListener(new OnDismissListener() { 
        public void onDismiss(DialogInterface dialog) { 
         if (ConnectionResult.SERVICE_INVALID == resultCode) activity().finish(); 
        } 
       }); 
       return false; 
      } 
     } 
     new CSAlertDialog(this).show("Google Play Services Error", 
       "This device is not supported for required Goole Play Services", "OK", new Call() { 
        public void onCall(Object value) { 
         activity().finish(); 
        } 
       }); 
     return false; 
    } 
    return true; 
} 
+0

이미 확인한 결과 doenst가 문제인 것처럼 보입니다.하지만 어떻게 든 tcm은 fcm 서비스를 찾지 못합니다. :에스 –

0

때때로 로우 엔드 장치에서 발생합니다. 한 가지 해결책은 Google Play 서비스 앱의 앱 데이터 및 캐시를 삭제하는 것입니다. 나를 위해 일하는이.

0

이 방법이 작동하는지 모르겠지만 원시 JSON 본문이 잘못되었습니다. 외부 {}을 JSON 개체로 잊어 버렸습니다. 아래는 귀하의 메시지입니다.

{ 
    "to": "/topics/general", 
    "notification" : { 
     "title": "title", 
     "body": "body", 
    }, 
    "data": { 
     "tipo": "normal", 
    } 
} 
관련 문제