Hi!
I have trouble getting getPushNotification() to run with NotificationsLifecycleFacade cloned from here.
When getPushNotification() with default AppLifecycleFacade instance it only notifies listeners about the notification if the app is running, but not if fully closed.
However running same function with notificationsLifecycleFacade in place of default facade passed to function as an argument, it works fine if the app is running (foreground/background doesn't make the difference), but crashes the app when it tries to start from fully closed.
The full error is:
``` java.lang.RuntimeException: Requested enabled DevSupportManager, but DevSupportManagerImpl class was not found or could not be created
at com.facebook.react.devsupport.DevSupportManagerFactory.create(DevSupportManagerFactory.java:79)
at com.facebook.react.ReactInstanceManager.<init>(ReactInstanceManager.java:336)
at com.facebook.react.ReactInstanceManagerBuilder.build(ReactInstanceManagerBuilder.java:233)
at com.facebook.react.ReactNativeHost.createReactInstanceManager(ReactNativeHost.java:84)
at com.reactnativenavigation.react.NavigationReactGateway$ReactNativeHostImpl.createReactInstanceManager(NavigationReactGateway.java:145)
at com.facebook.react.ReactNativeHost.getReactInstanceManager(ReactNativeHost.java:41)
at com.reactnativenavigation.react.NavigationReactGateway.getReactInstanceManager(NavigationReactGateway.java:59)
at com.reactnativenavigation.react.NavigationReactGateway.getReactContext(NavigationReactGateway.java:50)
at com.voxiosapp.NotificationsLifecycleFacade.getRunningReactContext(NotificationsLifecycleFacade.java:54)
at com.wix.reactnativenotifications.core.notification.PushNotification.notifyReceivedToJS(PushNotification.java:169)
at com.wix.reactnativenotifications.core.notification.PushNotification.onReceived(PushNotification.java:61)
at com.wix.reactnativenotifications.gcm.GcmMessageHandlerService.onMessageReceived(GcmMessageHandlerService.java:20)
at com.google.android.gms.gcm.GcmListenerService.zzo(Unknown Source)
at com.google.android.gms.gcm.GcmListenerService.zzn(Unknown Source)
at com.google.android.gms.gcm.GcmListenerService.zzm(Unknown Source)
at com.google.android.gms.gcm.GcmListenerService.zza(Unknown Source)
at com.google.android.gms.gcm.GcmListenerService$1.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at com.facebook.react.devsupport.DevSupportManagerFactory.create(DevSupportManagerFactory.java:72)
... 19 more
Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
at android.os.Handler.<init>(Handler.java:200)
at android.os.Handler.<init>(Handler.java:114)
at com.facebook.react.devsupport.DevServerHelper.<init>(DevServerHelper.java:124)
at com.facebook.react.devsupport.DevSupportManagerImpl.<init>(DevSupportManagerImpl.java:193)
... 21 more
```
Not sure if it's my fault or specific app configuration, so let me know if you need more information from my side.
Found a way around thanks to: #124
Solution in #124 does fix the crash when app is fully closed indeed. However it still causes the crash when another app is opened on the top of my app. That is:
This is caused by calling digestNotification() in pause state:
context = reactGateway.getReactContext(); //this is returned null in pause state
context.getCurrentActivity();
Solution I have used is to override this function in my Lifecycle Facade:
@Override
public ReactContext getRunningReactContext() {
final ReactGateway reactGateway = NavigationApplication.instance.getReactGateway();
if (reactGateway == null) {
return null;
}
if(isReactInitialized()) {
return reactGateway.getReactContext();
}
return null;
}
@Lastin Can you also make PR of this fix so other people get fixed version right away? :)
Sorry, didn't check git for a while. Will make PR when I get a free moment.
Hi, since getRunningReactContext() might return null, it might be a good idea to check reactContext before calling getCurrentActivity()
protected void digestNotification() {
if (!mAppLifecycleFacade.isReactInitialized()) {
setAsInitialNotification();
launchOrResumeApp();
return;
}
final ReactContext reactContext = mAppLifecycleFacade.getRunningReactContext();
if (reactContext.getCurrentActivity() == null) {
setAsInitialNotification();
}
if (mAppLifecycleFacade.isAppVisible()) {
dispatchImmediately();
} else {
dispatchUponVisibility();
}
}
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you believe the issue is still relevant, please test on the latest Detox and report back. Thank you for your contributions.
The issue has been closed for inactivity.