安卓设备组无法接收消息

几个月以来,应用程序中我没做任何更改,但是从6月11日开始,不能接收 Firebase 云消息发送的任何消息了。 已经有几个客户报告过了,我可以确认就是出问题了。 没有固件更改或任何东西,至少在我的手机是这样的。 我用的代码和,戳这里here一模一样。 发送消息,FirebaseMessagingService 中的 onMessageSent 回调被正确调用,但是我无法在其他手机上接收到使用相同帐户的任何内容。 有没有什么地方是我遗漏的? 我的配置不使用服务器,所以我不能检查任何日志服务器端。有什么建议吗?

通过FireBase支持发送了30封电子邮件之后,我的代码/项目中没有任何内容,只是它们不再支持无服务器配置。吃不吃惊?意不意外?有趣的是,也不知道为什么,更不知道它以前是如何运作的!太可笑了。他们没有对这一重大变化提出建议,因此任何基于Android设备组(无服务器)的应用程序都不能再工作了。

比较主要的指纹。 曾经也有过这样的问题,它无缘无故就停止工作了——罪魁祸首是,关键的指纹不再与控制台上的指纹相匹配(甚至不能判断他们是站在我这边还是站在他们这边)。可以试试google-services.json; 如果这个文件只损坏了一点点,那么很难发现啊(除非版本控制指出了更改)。
如果这些代码已经使用了3年,那么检查一下是否不能用了,就是功能不能用了(因为这个问题没写出代码,所以也说不清楚)。文档中的示例代码的答案可能没有那么错,因为我们可以将3年前的代码比较。我们甚至不知道,实际用的哪一个版本。

看看这个答案也许能解答:
首先,你说‘我无法在其他手机上接收到使用相同帐户的任何内容'。 是通过 FCM 进行的设备消息传递使用设备注册令牌作为联系点,而不是帐户。 因此,你可能不会在不同的设备上用相同的帐户接收来自 FCM 的消息。
其次,每个标记组只能注册20个设备。 Firebase Docs还提到,你通常需要一个应用服务器来完成设备到设备的信息传递。
请记住,这种设备对设备的消息传递只用于通知,不用于发送聊天消息或其他任何类型的消息。如果您想在没有应用程序服务器的情况下实现通知,试试这个-

import android.app.IntentService;import android.app.NotificationChannel;import android.app.NotificationManager;import android.app.PendingIntent;import android.content.Context;import android.content.Intent;import android.media.RingtoneManager;import android.net.Uri;import android.os.Build;import android.util.Log;
import androidx.annotation.NonNull;import androidx.core.app.NotificationCompat;import androidx.legacy.content.WakefulBroadcastReceiver;
import com.google.firebase.auth.FirebaseAuth;import com.google.firebase.database.DataSnapshot;import com.google.firebase.database.DatabaseError;import com.google.firebase.database.FirebaseDatabase;import com.google.firebase.database.Query;import com.google.firebase.database.ValueEventListener;
public class NotificationIntentService extends IntentService {

    private static int NOTIFICATION_ID = 1;
    private static final String ACTION_START = "ACTION_START";
    private static final String ACTION_DELETE = "ACTION_DELETE";

    public NotificationIntentService() {
        super(NotificationIntentService.class.getSimpleName());
    }

    public static Intent createIntentStartNotificationService(Context context) {
        Intent intent = new Intent(context, NotificationIntentService.class);
        intent.setAction(ACTION_START);
        return intent;
    }

    public static Intent createIntentDeleteNotification(Context context) {
        Intent intent = new Intent(context, NotificationIntentService.class);
        intent.setAction(ACTION_DELETE);
        return intent;
    }

    @Override
    protected void onHandleIntent(Intent intent) {
        Log.w(String.valueOf(new NotificationIntentService()), "onHandleIntent, started handling a notification event");
        try {
            String action = intent.getAction();
            if (ACTION_START.equals(action)) {
                processStartNotification();
            }
            if (ACTION_DELETE.equals(action)) {
                processDeleteNotification(intent);
            }
        } finally {
            WakefulBroadcastReceiver.completeWakefulIntent(intent);
        }
    }

    private void processDeleteNotification(Intent intent) {
        // Log something?
    }

    private void processStartNotification() {

        // Do something. For example, fetch fresh data from backend to create a rich notification?

        NOTIFICATION_ID += 1;

        Intent intent = new Intent(NotificationIntentService.this, MainActivity.class);
        PendingIntent pendingIntent = PendingIntent.getActivity(NotificationIntentService.this, 0 /* Request code */, intent,
                                        PendingIntent.FLAG_UPDATE_CURRENT);

         String channelId = getString(R.string.default_notification_channel_id);
         Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
         NotificationCompat.Builder notificationBuilder =
                                        new NotificationCompat.Builder(NotificationIntentService.this, channelId)
                                                .setSmallIcon(R.drawable.chat)
                                                .setContentTitle("Title")
                                                .setContentText("Text")
                                                .setAutoCancel(true)
                                                .setSound(defaultSoundUri)
                                                .setContentIntent(pendingIntent);

                                notificationBuilder.setContentIntent(pendingIntent);
                                notificationBuilder.setDeleteIntent(NotificationEventReceiver.getDeleteIntent(NotificationIntentService.this));

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

                                // Since android Oreo notification channel is needed.
                                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                                    NotificationChannel channel = new NotificationChannel(channelId,
                                            "channel_id",
                                            NotificationManager.IMPORTANCE_DEFAULT);
                                    notificationManager.createNotificationChannel(channel);
                                }

                                notificationManager.notify(NOTIFICATION_ID, notificationBuilder.build());

    }}
import android.app.AlarmManager;import android.app.PendingIntent;import android.content.Context;import android.content.Intent;import android.util.Log;
import androidx.legacy.content.WakefulBroadcastReceiver;
import java.util.Calendar;import java.util.Date;
public class NotificationEventReceiver extends WakefulBroadcastReceiver {

    private static final String ACTION_START_NOTIFICATION_SERVICE = "ACTION_START_NOTIFICATION_SERVICE";
    private static final String ACTION_DELETE_NOTIFICATION = "ACTION_DELETE_NOTIFICATION";
    private static final int NOTIFICATIONS_INTERVAL_IN_FIFTEEN_MINUTES = 0;

    public static void setupAlarm(Context context) {
        AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
        PendingIntent alarmIntent = getStartPendingIntent(context);
        alarmManager.setRepeating(AlarmManager.RTC_WAKEUP,
                getTriggerAt(new Date()),
                600000,
                alarmIntent);
    }

    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        Intent serviceIntent = null;
        if (ACTION_START_NOTIFICATION_SERVICE.equals(action)) {
            Log.w(getClass().getSimpleName(), "onReceive from alarm, starting notification service");
            serviceIntent = NotificationIntentService.createIntentStartNotificationService(context);
        } else if (ACTION_DELETE_NOTIFICATION.equals(action)) {
            Log.w(getClass().getSimpleName(), "onReceive delete notification action, starting notification service to handle delete");
            serviceIntent = NotificationIntentService.createIntentDeleteNotification(context);
        }

        if (serviceIntent != null) {
            startWakefulService(context, serviceIntent);
        }
    }

    private static long getTriggerAt(Date now) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(now);
        //calendar.add(Calendar.HOUR, NOTIFICATIONS_INTERVAL_IN_HOURS);
        return calendar.getTimeInMillis();
    }

    private static PendingIntent getStartPendingIntent(Context context) {
        Intent intent = new Intent(context, NotificationEventReceiver.class);
        intent.setAction(ACTION_START_NOTIFICATION_SERVICE);
        return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    }

    public static PendingIntent getDeleteIntent(Context context) {
        Intent intent = new Intent(context, NotificationEventReceiver.class);
        intent.setAction(ACTION_DELETE_NOTIFICATION);
        return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    }}
import android.content.BroadcastReceiver;import android.content.Context;import android.content.Intent;
public final class NotificationServiceStarterReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        NotificationEventReceiver.setupAlarm(context);
    }}

在没有看到你代码之前也就能说这么多了。
希望这能有所帮助。