couchbaselabs / react-native-couchbase-lite

Couchbase Lite binding for React Native Android & iOS
MIT License
111 stars 54 forks source link

Use internal url instead of instantiating the listener on iOS #56

Closed jamesnocentini closed 7 years ago

jamesnocentini commented 8 years ago

The react native plugin instantiates the listener on iOS https://github.com/couchbaselabs/react-native-couchbase-lite/blob/master/ios/ReactCBLite.m#L28. But it should use the internalURL property instead as stated in https://github.com/couchbase/couchbase-lite-ios/issues/1270

In the PhoneGap plugin, the line is https://github.com/couchbaselabs/Couchbase-Lite-PhoneGap-Plugin/blob/master/src/ios/CBLite.m#L35.

jamesnocentini commented 8 years ago

There is a post on the forum about accessing the listener in a PhoneGap (Android) app while being backgrounded https://forums.couchbase.com/t/cordova-after-putting-android-app-in-background-mode-for-a-few-hours-cb-lite-is-unresponsive/8833/. I imagine that the same would apply for React Native.

@yonahforst since you have it working for iOS on your fork could you submit a PR with the fix? Thanks! Per @npomfret's comment, we can update the documentation and code review on the PR then.

npomfret commented 8 years ago

Android doesn't seem to have any of these problems. Putting it into your app background and then restarting it doesn't seem to affect CBL at all.

Although I've not tested it after a few hours of being backgrounded yet. But I shall do

npomfret commented 8 years ago

I left my android app running overnight. It doesn't seem to have had any ill effects after 8 or so hours. My fork thought is using the Android CBL 1.3 build though (1.3.0-45).

So. Are there any objects to adding the ReactCBLiteRequestHandler.m and ReactCBLiteRequestHandler.h to the project? I think we should leave the rest of the code as it is, leaving the old listener in place. The user then has the option to use the call back url, as they currently do, or the internal url. It just needs explaining in the docs.

I'll also add documentation on how to stop and start the internal listener (which is implemented in android as well now).

yonahforst commented 8 years ago

submitted PR. Just a heads up - you need to CBL 1.3, otherwise you'll run into this issue: https://github.com/couchbase/couchbase-lite-ios/issues/1045

npomfret commented 8 years ago

@jamiltz can we add @yonahforst to the contributors?

Visualizeyourcode commented 8 years ago

Great work guys! Thanks a lot! I was having just a similar problem with the CBL when the RN app went to background mode. I added the snippet @npomfret provided into the manager RN code and now it works fine.