aboutsummaryrefslogtreecommitdiffstats
path: root/src/standardPush/java/de/pixart/messenger
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2017-09-24 21:49:48 +0200
committerChristian Schneppe <christian@pix-art.de>2017-09-24 21:49:48 +0200
commitbefe4a6ea448fd6be78863d851923b153103e051 (patch)
tree872b9331cf3f6b5af3d759c94bd47a60fa15637e /src/standardPush/java/de/pixart/messenger
parent76beff245abef47c952bc59516cc88a69cce2878 (diff)
add maintanence intent to renewe instance id
Diffstat (limited to 'src/standardPush/java/de/pixart/messenger')
-rw-r--r--src/standardPush/java/de/pixart/messenger/services/MaintenanceReceiver.java41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/standardPush/java/de/pixart/messenger/services/MaintenanceReceiver.java b/src/standardPush/java/de/pixart/messenger/services/MaintenanceReceiver.java
new file mode 100644
index 000000000..5cfcbe920
--- /dev/null
+++ b/src/standardPush/java/de/pixart/messenger/services/MaintenanceReceiver.java
@@ -0,0 +1,41 @@
+package de.pixart.messenger.services;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.util.Log;
+
+import com.google.android.gms.iid.InstanceID;
+
+import java.io.IOException;
+
+import eu.siacs.conversations.Config;
+
+public class MaintenanceReceiver extends BroadcastReceiver {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ 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) {
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ InstanceID instanceID = InstanceID.getInstance(context);
+ try {
+ instanceID.deleteInstanceID();
+ Intent intent = new Intent(context, XmppConnectionService.class);
+ intent.setAction(XmppConnectionService.ACTION_GCM_TOKEN_REFRESH);
+ context.startService(intent);
+ } catch (IOException e) {
+ Log.d(Config.LOGTAG, "unable to renew instance token", e);
+ }
+ }
+ }).start();
+
+ }
+} \ No newline at end of file