Apache CouchDB – Forms to iOS

Viewing 4 reply threads
  • Author
    Posts
  • July 30, 2019 at 9:59 AM #36122

    Eddzo
    Participant

    Syncing is WAY more solid using Apache CouchDB than iCloud sync.

    With iCloud sync anytime there was a new form it would show up when you opened the iOS device automatically and ask if you want to download it with the little cloud icon in the corner.

    I notice that doesn’t happen with CouchDB.

    I used Airdrop to move the from the Macbook pro to the iPad and iPhone.
    Once they are there and I’m at home wtihin the network,
    New data syncs like a BOSS…..

    I’m just slithering my way through this though…

    Does this sound like the right thing to do?
    Use air drop to move forms to the other devices?

    How do you send a from to the Desktops?

    July 30, 2019 at 1:27 PM #36127

    Sam Moffatt
    Participant

    Out of the gate, AirDrop is the way to go to get up and running. Takes some time but reliably gets your data from A to B. If you’ve already got a document, that’s your best bet.

    If you are starting a brand new document that you expect to sync via CouchDB, what you can do is create it so you get the document ID, set up iCloud Sync so that it creates the placeholder in iCloud for all of your devices and then disable iCloud Sync on the original device and switch to CouchDB. This means iCloud has an empty document in it which you can use to open up new devices easily and then you disable iCloud sync on that device and point it to your CouchDB server. TapForms will take the empty document and then pull down via sync the full contents. If you are planning ahead, then this is a neat trick to get up and running quickly. If you don’t want to use iCloud, you can obviously create the document, close TapForms and keep a copy of that empty document somewhere and use that to bootstrap new instances as well however I find iCloud easier here or if I’m going down that pathway, I can just use TapForms to send the document across.

    At one point I was experimenting with a way of building an empty TapForms document that could include a document ID to serve as a way of getting new documents from a CouchDB instance into an iOS instance (or Mac but generally that’s easier to shuffle around). I got this sort of working but it wasn’t consistent enough for my liking.

    August 2, 2019 at 12:16 AM #36182

    Guillaume Kuster
    Participant

    I switched to CouchDB yesterday, hosted on a vps I already had. Seems solid so far in my testing, but so did iCloud in the beginning. Time will tell.

    CouchDB is way, way faster indeed to sync but definitely not “Grandma collecting recipies” simple.

    I had to build it from source as apt failed to install CouchDB on my debian 9.9 server. Also, getting SSL to work requires some testing. Following Brendan’s instructions works fine on Macs, but not on iOS devices anymore as the self-signed certificate .crt generated on the server (and then airdropped to the iOS device and installed) would not appear on iOS devices under the Enable Full Trust For Root certificates under Settings > General > About > Certificate Trust Settings. So here’s what worked for me:

    – generate a certificate as stated here
    – once you CouchDB server is correctly configured for SSL and restarted, use your Mac browser to try to connect to https://<Your Server>:6984/_utils/index.html
    – your browser will display an alert saying that the SSL certificate of this website is not valid. Click through the link to visit anyway and type your session password to trust the certificate. This will store your .crt certificate in your Keychain.
    – open you Keychain and locate the previously accepted certificate (searching for the IP address) and export it
    – Airdrop this certificate to your iOS device(s) and install it. It will appear under the Enable Full Trust For Root certificates under Settings > General > About > Certificate Trust Settings as a switch. Enable it and Tap Forms will accept to sync via CouchDB using an URL in the format https://<Your Server>:6984 with your user name and password.

    And as a side note: sync with CloudDB doesn’t work great on my iOS 13 beta iPad (build 17A5534f) but that’s of course not a problem for the moment. The behaviour is as follows: where every change made everywhere else (Phone or either of my macs) are synced in seconds on all other machines, the iPad would lag behind and sometimes never sync. Changed made on the iPad would generally but not always sync to other machines, changes made on other machines would rarely sync to the iPad.

    August 2, 2019 at 12:22 AM #36184

    Guillaume Kuster
    Participant

    Does this sound like the right thing to do?
    Use air drop to move forms to the other devices?

    What I like about airdropping your db is that couchDB settings are also sent to the other devices eg if you create your database on a Mac, enable CouchDB sync with your URL and credentials and then Airdrop to an iOS device, the URL and credentials will be pre-filled under TF’s sync settings.

    August 2, 2019 at 2:21 AM #36185

    Brendan
    Keymaster

    @Guillaume, your credentials and server URL must have already been in the Keychain. Because I do not store that information in the properties file of the database document.

    The server URL and credentials are stored in the Keychain keyed on the document ID. So if the entries are found in the keychain with that document ID, that’s when that info will be filled out for you on the Security Settings screen.

    You must have logged in at some point with that same document and then maybe at some later time re-sent the document via AirDrop. Tap Forms would have picked up the credentials from the Keychain at that point.

    The only thing stored in the properties file is what sync service is selected for that document.

    I just checked my code to verify that I am correct in this. It would be a security issue if the username and password were stored within the document itself.

    My code to fetch that info from the Keychain (it’s nothing fancy):

    if ([selectedProvider isEqualToString:kTFCouchDBServiceProvider]) {
    	self.selectedServiceIndex = @1;
    		
    	self.cloudUserName = [TFKeychainUtils passwordForService:self.databaseDocument.documentID
    														 account:kTFCouchDBUserKey];
    		
    	self.cloudPassword = [TFKeychainUtils passwordForService:self.databaseDocument.documentID
    														 account:kTFCouchDBPasswordKey];
    		
    	self.cloudServerAddress = [TFKeychainUtils passwordForService:self.databaseDocument.documentID
    															  account:kTFCouchDBServerKey];
    		
    }
    August 2, 2019 at 2:24 AM #36187

    Guillaume Kuster
    Participant

    You must have logged in at some point with that same document and then maybe at some later time re-sent the document via AirDrop. Tap Forms would have picked up the credentials from the Keychain at that point.

    That was probably the case as I did a fair amount of testing yesterday.

    Thanks for sharing the code. The behaviour I described would indeed be a security issue, you’re right!


    @Eddzo
    : sorry if I gave you false hopes ;)

    August 2, 2019 at 9:00 PM #36203

    Sam Moffatt
    Participant

    Is it possible that it could pick it up from iCloud Keychain as well if that is enabled?

Viewing 4 reply threads

You must be logged in to reply to this topic.