blob: 9a3309be4b65af67e103038cb9e78d3a30a63252 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
package de.pixart.messenger.services;
import android.content.Intent;
import android.support.v4.content.ContextCompat;
import android.util.Log;
import com.google.firebase.iid.FirebaseInstanceIdService;
import de.pixart.messenger.Config;
import de.pixart.messenger.utils.Compatibility;
public class InstanceIdService extends FirebaseInstanceIdService {
@Override
public void onTokenRefresh() {
final Intent intent = new Intent(this, XmppConnectionService.class);
intent.setAction(XmppConnectionService.ACTION_FCM_TOKEN_REFRESH);
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");
}
}
}
|