我正在尝试使用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());
}
}