应用长时间关闭后不会调用OnMessageReceived

时间:2020-03-24 10:51:56

标签: android firebase firebase-cloud-messaging

我正在尝试使用FireBase的数据消息接收应用程序上的数据,即使该数据被杀死或处于后台。 如果该应用程序在最近两天内(大约)被使用过,但是此后,onMessageReceived()就再也不会调用了。

为什么会这样?

@Override
public void onMessageReceived(@NonNull RemoteMessage remoteMessage) {
    Map<String, String> response = remoteMessage.getData();
    SharedPreferences sharedPref = getSharedPreferences("tokens", Context.MODE_PRIVATE);
    if(!response.get("sender").equals(sharedPref.getString("FMC_token", "Error2"))) {
        StorageService.getInstance().downloadFile(response.get("image_path"), "crt", getApplicationContext());
    }
}

0 个答案:

没有答案
相关问题