anotherim/src/playstore/java/eu/siacs/conversations/services/MaintenanceReceiver.java

31 lines
987 B
Java
Raw Normal View History

package eu.siacs.conversations.services;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
2021-05-13 08:27:05 +00:00
import com.google.firebase.installations.FirebaseInstallations;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.utils.Compatibility;
public class MaintenanceReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
2018-03-08 15:27:33 +00:00
Log.d(Config.LOGTAG, "received intent in maintenance receiver");
if ("eu.siacs.conversations.RENEW_INSTANCE_ID".equals(intent.getAction())) {
renewInstanceToken(context);
}
}
private void renewInstanceToken(final Context context) {
2021-05-13 08:27:05 +00:00
FirebaseInstallations.getInstance().delete().addOnSuccessListener(unused -> {
final Intent intent = new Intent(context, XmppConnectionService.class);
2018-05-19 18:05:45 +00:00
intent.setAction(XmppConnectionService.ACTION_FCM_TOKEN_REFRESH);
Compatibility.startService(context, intent);
2021-05-13 08:27:05 +00:00
});
}
}