@KaMyLL is correct. I had the same problem with our application and I was able to solve it by replacing the IntentService (which we started at onTokenRefresh()) with JobIntentService.
, JobScheduler JobIntentService docs , - . , , .
?
Android 8 , :
, , . , , . . , Service.stopSelf() .
:
JobScheduler.
, Android 7.x startService(), ( ), . Android 8 . , JobScheduler. JobScheduler IntentService , IntentService . , , JobScheduler, . Android OS , , . , . , .
, if-else. , , : JobIntentService, .
?
, " , ". , ( onTokenRefresh() Firebase), startService(). 5-10 . , IllegalStateException .
, , .
IntenService JobIntentService?
FirebaseInstanceIdService.onTokenRefresh() :
a) BIND_JOB_SERVICE:
<service android:name=".fcm.FcmRegistrationJobIntentService"
android:exported="false"
android:permission="android.permission.BIND_JOB_SERVICE"/>
b) IntentService android.support.v4.app.JobIntentService, onHandleIntent(Intent) onHandleWork(Intent) enqueueWork (Context, Intent):
public class FcmRegistrationJobIntentService extends JobIntentService
{
static final int JOB_ID = 42;
public static void enqueueWork(Context context, Intent work) {
enqueueWork(context, FcmRegistrationJobIntentService.class, JOB_ID, work);
}
@Override
protected void onHandleWork(@NonNull Intent intent) {
}
}
c) enqueueWork():
public class ComfyFirebaseInstanceIdService extends FirebaseInstanceIdService {
@Override
public void onTokenRefresh() {
Intent intent = new Intent(this, FcmRegistrationJobIntentService.class);
FcmRegistrationJobIntentService.enqueueWork(this, intent);
}
}
, . Android 8, Android 7.