Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Bugfix][Android] Use JobServiceIntent to fetch the FCM token in the …
…background (#678) ### Highlights - Changes the mechanism by which the library fetches the FCM token in the background. ### Context In newer Android versions (8+), background applications cannot start `IntentService`'s. Using the notifications library in these newer Android versions will result in a lot of exceptions of the type `java.lang.IllegalStateException`. Sample stack trace: ``` java.lang.IllegalStateException: at android.app.ContextImpl.startServiceCommon (ContextImpl.java:1522) at android.app.ContextImpl.startService (ContextImpl.java:1478) at android.content.ContextWrapper.startService (ContextWrapper.java:650) at com.wix.reactnativenotifications.RNNotificationsModule.startFcmIntentService (RNNotificationsModule.java:135) at com.wix.reactnativenotifications.RNNotificationsModule.initialize (RNNotificationsModule.java:50) at com.facebook.react.bridge.ModuleHolder.doInitialize (ModuleHolder.java:222) at com.facebook.react.bridge.ModuleHolder.markInitializable (ModuleHolder.java:97) at com.facebook.react.bridge.NativeModuleRegistry.notifyJSInstanceInitialized (NativeModuleRegistry.java:102) at com.facebook.react.bridge.CatalystInstanceImpl$2.run (CatalystInstanceImpl.java:441) at android.os.Handler.handleCallback (Handler.java:790) at android.os.Handler.dispatchMessage (Handler.java:99) at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage (MessageQueueThreadHandler.java:26) at android.os.Looper.loop (Looper.java:164) at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run (MessageQueueThreadImpl.java:225) at java.lang.Thread.run (Thread.java:764) ``` Now, in order to start intents in the background, the `JobIntentService` class must be extended. This PR consists in basically the same changes proposed by @migbot in #491 (this PR was closed for inactivity a few months ago). Should close #671;
- Loading branch information