Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Notification sending from firebase console but its showing failed status but sending to all device is mark as completed

I have implemented push by firebase.

I'm sending notifications but I am getting status of "Failed". When I send notification to all devices it is marking as completed but I am still not getting messages in device.

Even when I send messages to single devices it will also show failed and will not receive notification on device.

The code is

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

like image 967
Zaeem Sattar Avatar asked Jun 23 '16 22:06

Zaeem Sattar


2 Answers

Your sender ID mismatched or you have entered incorrect project ID in your Application.

like image 100
Muhammad Khurram Mushtaq Avatar answered Oct 20 '22 05:10

Muhammad Khurram Mushtaq


Looking at logs, I think you are sending to specific devices via registration id but we see an error with mismatched sender id.Please check that these registration ids are valid and apply to the correct app.

like image 26
Ian McDowall Avatar answered Oct 20 '22 05:10

Ian McDowall