couchbaselabs / Couchbase-Lite-PhoneGap-Plugin

Plugin to install Couchbase Lite in your PhoneGap app on iOS or Android
183 stars 67 forks source link

Enable the ios plugin to use TCP port instead of nsurlprotocol #48

Open olebrun opened 9 years ago

olebrun commented 9 years ago

iOS version use nsurlprotocol which isn't supported (yet?) by wkwebview. Under Android, it seems that couchbase lite open a true TCP port. Is it possible to have the same behaviour on iOS (as an option) ?

Thanks,

wilk commented 8 years ago

+1

Couchbase Lite is not working with WKWebView (https://github.com/Telerik-Verified-Plugins/WKWebView) so this example (https://github.com/couchbaselabs/TodoLite-Ionic) when installing that webview.

apparition47 commented 8 years ago

+1

I, too, would like to see this. Looks like it's marked for the upcoming 1.3 milestone.

msanilkumar2020 commented 7 years ago

+1 Still we have issue in CBL 1.3.1, Couchbase Lite is not working with WKWebView.

Please let us when this issue will be fixed.

geraldapeoples commented 6 years ago

Are there any plans to WKWebView? We use the cordova plugin extensively and the lack of WKWebView support means that we are now having to look at alternatives to couchbase lite.

geraldapeoples commented 6 years ago

I have modified the plugin to start a listener on port 5984 .. but any requests to http://localhost:5984 fail with XMLHttpRequest Preflight response not successful. No matter what I try with regards to any cors settings the error persists. It looks like the server does not actually support preflight requests at all, is this the case?

olebrun commented 6 years ago

Hello @geraldapeoples, Can you share your modifications ? (doesn't matter if it's not already functional)

geraldapeoples commented 6 years ago

Hi Oliver,

I cloned the plugin from https://github.com/couchbaselabs/Couchbase-Lite-PhoneGap-Plugin.git

I modified the src/ios/CBLite.m file, updated version attached as txt file ...

CBLite.txt

I did try a couple of varations with the port number, using 0 and hardcoding to 5984. The connection works fine in both cases, it is just the preflight that gives an error which is what makes me think the cocoa webserver does not support CORS.

If I use the angular http service and set the content type to "text/plain" in the http request, there is no preflight request and it successfully connects without errors.

Ionic does update the plist file for iOS to enable localhost connections to bypass security, and I did try out updating the plugin to also allow the .local domain and using the returned cblistener.URL which again works successfully but only if the content type is set to "text/plain" ... this required modfying the plugin.xml file ...the updated version attached as plugin.txt ...

plugin.txt

I read a couple of articles online that suggested the listener would stop if the app was backgrounded so additional logic would be required to manage this ... which is where I decided to abandon ship, I am not an iOS developer so getting this far has been a challenge. Wkwebview support is really important for us with the latest release of iOS, we have a couple of apps on the app store and the experience without wkwebview is pretty diminished. If you find a fully working/tested solution to this which manages the backgrounding of the apps, I would love to hear about it.

Another thing I found was that the SSL support did not work at all, I put the necessary code into the plugin but the http server did not serve anything on https.

olebrun commented 6 years ago

Hi Gerald,

Thanks for your reporting, I'm in the same situation and after 2 years waiting without response from Couchbase team ... I'm not using couchbase anymore. But I have some existing app I want to update to wkwebview.

I will have a try when have some time and return my results to you.

Have a good day, bye

2017-11-09 12:33 GMT+01:00 Gerald Peoples notifications@github.com:

Hi Oliver,

I cloned the plugin from https://github.com/couchbaselabs/Couchbase-Lite- PhoneGap-Plugin.git

I modified the src/ios/CBLite.m file, updated version attached as txt file ...

CBLite.txt https://github.com/couchbaselabs/Couchbase-Lite-PhoneGap-Plugin/files/1457399/CBLite.txt

I did try a couple of varations with the port number, using 0 and hardcoding to 5984. The connection works fine in both cases, it is just the preflight that gives an error which is what makes me think the cocoa webserver does not support CORS.

If I use the angular http service and set the content type to "text/plain" in the http request, there is no preflight request and it successfully connects without errors.

Ionic does update the plist file for iOS to enable localhost connections to bypass security, and I did try out updating the plugin to also allow the .local domain and using the returned cblistener.URL which again works successfully but only if the content type is set to "text/plain" ... this required modfying the plugin.xml file ...the updated version attached as plugin.txt ...

plugin.txt https://github.com/couchbaselabs/Couchbase-Lite-PhoneGap-Plugin/files/1457417/plugin.txt

I read a couple of articles online that suggested the listener would stop if the app was backgrounded so additional logic would be required to manage this ... which is where I decided to abandon ship, I am not an iOS developer so getting this far has been a challenge. Wkwebview support is really important for us with the latest release of iOS, we have a couple of apps on the app store and the experience without wkwebview is pretty diminished. If you find a fully working/tested solution to this which manages the backgrounding of the apps, I would love to hear about it.

Another thing I found was that the SSL support did not work at all, I put the necessary code into the plugin but the http server did not serve anything on https.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/couchbaselabs/Couchbase-Lite-PhoneGap-Plugin/issues/48#issuecomment-343128002, or mute the thread https://github.com/notifications/unsubscribe-auth/AByxLkRLqbl8krqmttWWORyArKjbSGr6ks5s0uL0gaJpZM4D9Umc .

-- Argosoft - Olivier Lebrun Email : olebrun@argosoft.fr Téléphone : 06.71.08.79.27

geraldapeoples commented 6 years ago

@olebrun Hi Oliver, any news?

olebrun commented 6 years ago

Hi Gerald, Sorry, don't have any time to test for the moment :/ I come back to you as soon as possible.

2017-11-14 15:07 GMT+01:00 Gerald Peoples notifications@github.com:

@olebrun https://github.com/olebrun Hi Oliver, any news?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/couchbaselabs/Couchbase-Lite-PhoneGap-Plugin/issues/48#issuecomment-344269314, or mute the thread https://github.com/notifications/unsubscribe-auth/AByxLsIVOGi2k2nsHTONqWQ5tqFq_U46ks5s2Z6KgaJpZM4D9Umc .

-- Argosoft - Olivier Lebrun Email : olebrun@argosoft.fr Téléphone : 06.71.08.79.27

makbari commented 6 years ago

@geraldapeoples Hi Gerald, I know this thread is kind of old, but want to share with you modifications which we did to use couchbase-lite 2.0 with ionic 3.

This is the link for the repo cordova-plugin-couchbase-lite-2.0

Please send me your feedback and your skills for developing in Java for andriod,

geraldapeoples commented 6 years ago

@makbari Thank you for the update! Very kind of you.

When it comes to setting up replication agreements in 1.4.1, we don't use username/password, but set the Cookie from the login session -

"source": { "url": "string", "headers": { "Cookie": "string" } },

Is this possible with couchbase lite 2 and cordova? session authentication?

makbari commented 6 years ago

@geraldapeoples session authentication is implemented in couchbase 2 the replicator config (I have not tried it yet):

// Add authentication.
replConfig.authenticator = [[CBLBasicAuthenticator alloc] initWithUsername:@"john" password:@"pass"];

and also there is possibility to set authentication for the sync function (and not done yet) Generally, there is too much to add. I have not added to this commit :)

mohammad

msanilkumar2020 commented 6 years ago

Now UIWebview is depreciated in iOS 12, we are forced to use WKWebview. Please let us know when we will have support for WKWebview. https://developer.apple.com/documentation/uikit/uiwebview?changes=_6

geraldapeoples commented 6 years ago

@makbari Hi, have you been using the version 2 plugin in production? I would like to use it and contribute if I can, although I may need some guidance to get started with setting up to be able to build this plugin.

makbari commented 6 years ago

@geraldapeoples I am using it in development and I used in production (pre release version, and I have not done testing to possible bugs). I don't have any problems in development so far and it is promising.

plugin wrapper for the Android, however, is not near ready.

I will update the readme for setting up the plugin and as soon as I update it, I will let you know. However, the setting up is like any other ionic cordova plugins.

PS: I have change the Query little bit ( to use it in my app, which I will update the docs ). mohammad

geraldapeoples commented 6 years ago

@makbari Thanks for the update, let me know when you have updated the readme, in the meantime I will have have a go setting it up in my app.