从firebase控制台发送通知但显示失败状态但发送到所有设备的标记已标记为已完成

问题描述 投票:6回答:2

我已经实现了firebase的推送。

我正在发送通知,但我的状态为“失败”。当我向所有设备发送通知时,它标记为已完成,但我仍未收到设备中的消息。

即使我向单个设备发送消息,它也会显示失败,并且不会在设备上收到通知。

代码是

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

android firebase firebase-notifications
2个回答
4
投票

您的发件人ID不匹配,或者您在应用程序中输入了错误的项目ID。


1
投票

查看日志,我认为您通过注册ID发送到特定设备,但我们发现错误的发件人ID不匹配。请检查这些注册ID是否有效并应用于正确的应用程序。

© www.soinside.com 2019 - 2024. All rights reserved.