2016-06-23 3 views
4

私はfirebaseによるプッシュを実装しました。Firebaseコンソールから通知が送信されましたが、ステータスが表示されていませんが、すべてのデバイスへの送信は完了マークとして表示されます

通知を送信していますが、ステータスが「失敗」になっています。すべてのデバイスに通知を送信すると、完了したとマークされますが、まだデバイスにメッセージが表示されません。

メッセージを1つのデバイスに送信しても、エラーが表示され、デバイス上で通知が受信されません。

コードが

private static final String TAG = "StartingAndroid"; 

@Override 
public void onMessageReceived(RemoteMessage remoteMessage) { 

    //It is optional 
    Log.e(TAG, "From: " + remoteMessage.getFrom()); 
    Log.e(TAG, "Notification Message Body: " + remoteMessage.getNotification().getBody()); 

    //Calling method to generate notification 
    sendNotification(remoteMessage.getNotification().getTitle(),remoteMessage.getNotification().getBody()); 
} 

//This method is only generating push notification 
private void sendNotification(String title, String messageBody) { 
    Intent intent = new Intent(this, MainActivity.class); 
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 
      PendingIntent.FLAG_ONE_SHOT); 

    Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); 
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) 
      .setSmallIcon(R.mipmap.ic_launcher) 
      .setContentTitle(title) 
      .setContentText(messageBody) 
      .setAutoCancel(true) 
      .setSound(defaultSoundUri) 
      .setContentIntent(pendingIntent); 

    NotificationManager notificationManager = 
      (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); 

    notificationManager.notify(0, notificationBuilder.build()); 
} 

here is console

+0

onMessageReceivedメソッドをオーバーライドする必要はありますか?私はfirebaseメッセージがデフォルトの通知を表示すると思った。 –

+0

デフォルトの通知がありません –

答えて

4

送信者IDが一致していないか、またはアプリケーションに不正なプロジェクトIDが入力されています。

+0

はい、実際に私はそれらの両方を間違って入力しましたが、今問題は解決しました。ありがとうございます –

+0

あなたはこれをどのように解決したか教えていただけますか?私は3日以来立ち往生している。 @zaeemsattar –

1

ログを見ると、私はあなたが登録IDを経由して、特定のデバイスに送信していると思いますが、我々はこれらの登録IDというをチェックid.Please不一致の送信者とのエラーが表示されます有効で、正しいアプリに適用されます。

+0

ありがとうございます私はちょうど私が間違った送信者IDを使用していたことを理解しました –

関連する問題