aboutsummaryrefslogtreecommitdiffstats
path: root/src/standardPush/java/de/pixart/messenger/services/InstanceIdService.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/standardPush/java/de/pixart/messenger/services/InstanceIdService.java')
-rw-r--r--src/standardPush/java/de/pixart/messenger/services/InstanceIdService.java14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/standardPush/java/de/pixart/messenger/services/InstanceIdService.java b/src/standardPush/java/de/pixart/messenger/services/InstanceIdService.java
index 465f974e6..9a3309be4 100644
--- a/src/standardPush/java/de/pixart/messenger/services/InstanceIdService.java
+++ b/src/standardPush/java/de/pixart/messenger/services/InstanceIdService.java
@@ -15,11 +15,15 @@ public class InstanceIdService extends FirebaseInstanceIdService {
public void onTokenRefresh() {
final Intent intent = new Intent(this, XmppConnectionService.class);
intent.setAction(XmppConnectionService.ACTION_FCM_TOKEN_REFRESH);
- if (Compatibility.runsAndTargetsTwentySix(this)) {
- intent.putExtra(EventReceiver.EXTRA_NEEDS_FOREGROUND_SERVICE, true);
- ContextCompat.startForegroundService(this, intent);
- } else {
- startService(intent);
+ try {
+ if (Compatibility.runsAndTargetsTwentySix(this)) {
+ intent.putExtra(EventReceiver.EXTRA_NEEDS_FOREGROUND_SERVICE, true);
+ ContextCompat.startForegroundService(this, intent);
+ } else {
+ startService(intent);
+ }
+ } catch (IllegalStateException e) {
+ Log.e(Config.LOGTAG, "InstanceIdService is not allowed to start service");
}
}
} \ No newline at end of file