Ionic Framework is still one of the leaders in hybrid mobile application development. It allows you to create Android and iOS applications
using only HTML, JavaScript, and CSS.

Previously I wrote about how to use Couchbase in
an Ionic Framework mobile Android and iOS application
, but it made use of Couchbase
Lite as its embedded NoSQL database. This time around we’re going to look at replacing Couchbase Lite with PouchDB. Should you use one
method over the other? No, it comes down to preference in the end.

If you haven’t already seen my post regarding PouchDB
and AngularJS with Couchbase
, I encourage you to have a look as this tutorial will be using many of the same concepts and code.

What We’ll Need

There are a few requirements to the application we’re going to build. We’ll see how to obtain them along the way, but here is a
taste so you know what you’re getting yourself into.

  • Couchbase Sync Gateway
  • PouchDB 4
  • Ionic Framework 1

Getting the Couchbase Sync Gateway

This project will require the Couchbase Sync Gateway in order to succeed. If you’re unfamiliar, the Couchbase Sync Gateway is a
middleman service that handles processing data between the local application (your Ionic Framework application) and the Couchbase Server. We
won’t be using Couchbase Server in this example so the Sync Gateway will act as our in-memory storage solution in the cloud.

The Couchbase Sync Gateway can be found via the Couchbase downloads section.

Creating Our Ionic Framework Project

Before going any further it is good to note that if you’re not using a Mac, you cannot add and build for the iOS platform. Windows, Mac,
and Linux computers can build for Android, but only Mac can build for iOS.

From the Command Prompt (Windows) or Terminal (Mac and Linux), execute the following command to create a new Ionic Framework project:

Our blank template project is now ready for working with.

Including The Dependencies

If you haven’t already, download PouchDB 4 and make note of the min.js file as
we’ll be using it through the project. Copy the
PouchDB min.js file into your Ionic project’s www/js directory.

With the file in place, open your project’s www/index.html file and include the following:

This script line should appear above the app.js include line and the version information should match that of your actual
file rather than the version I included here.

Modifying The Index File

Before we jump into the AngularJS code we need to make a final revision to the project’s www/index.html file. Open it and
replace the tags with the following:

Because we’re using the AngularJS UI-Router that ships with Ionic Framework, we only need a basic www/index.html file.

Creating Our PouchDB AngularJS Service

Before we start using PouchDB, we need to make a wrapper for it so it fits nicely with AngularJS and Ionic Framework. Out of the box PouchDB
is a vanilla JavaScript library, so it isn’t necessarily the easiest to use when it comes to AngularJS.

Inside your project’s www/js/app.js file, include the following service code:

You might be thinking that code looks familiar. Well, it is the exact code I used in
the previous PouchDB example for AngularJS.
Now we can easily use PouchDB in our project.

Creating A Local Database And Start Syncing

The goal here is to create a local database when our application starts (if it doesn’t already exist) and then start syncing with the
Couchbase Sync Gateway. This can be accomplished in the AngularJS run() function of our www/js/app.js
file:

The IP addresses I used might vary for you in terms of simulators, but for production they will likely match for both iOS and
Android.

Designing A Controller For Your Views

We haven’t created our views yet, but let’s go ahead and create the controller logic for them. Open your project’s
www/js/app.js file and include the following controller:

As of right now we have a basic controller. We know we’ll be saving and deleting items which is why we’ve defined a function for such
tasks. We also have a function called back() that will pop an item (go back) in the history stack.

Let’s go bottom up and start with the back() function. It should contain the following code:

When it comes to deleting items from the database we’ll need to provide a particular document id to delete as well as the particular revision
we wish to delete. This will all be passed from the views, but the logic will be as follows:

The delete(id, rev) function makes a call to the PouchDB service that we made.

This leaves us with the save() function. Based on the simplicity of our application we’ll only be saving three data
properties, but it can easily be changed should you need to. Inside your controller, make the save() function like so:

This function does two things. It will prepare an insert or it will prepare an update should a document id and document revision
be available.

We’re not quite done yet though. Although we finished all our functions, we still need to handle listening for
changes. When we call $pouchDB.startListening(); in our controller, our PouchDB service will start making use of the
AngularJS $broadcast. While it is broadcasting we can listen for those broadcasts using something like:

Our view controller logic is now good to go!

Defining Your Ionic Framework Views

The last part of our www/js/app.js file will be for defining our views. This is done in the AngularJS
config() function like so:

We defined two views, one for all our list items and one for creating and updating new list items. The item state takes an optional
document id and document revision parameter. When they are present, it means we are going to be updating a particular document.

All our AngularJS logic is complete now. We have initialized our database, started syncing, defined our views, and planned for interaction
from our views.

Creating A List View

Here we will define how data is presented in the list. In your project’s www/templates/list.html file, add the following code:

When swiping a list item we are presented with a delete button that will call the delete() function of our controller.

Creating A Form View

Here we will define out documents will be inserted or updated in our database. Essentially, this view is only a form. In your project’s
www/templates/item.html file, add the following code:

 

The Sync Gateway Configuration

PouchDB and Ionic Framework are only half the story here. Sure they will create a nice locally running application, but we want things to sync. The Couchbase Sync Gateway is our endpoint for this and of course PouchDB works great with it.

Inside your project’s sync-gateway-config.json file, add the following:

This is one of the most basic configurations around. A few things to note about it:

  • It uses walrus:data for storage which is in memory and does not persist. Not to be used for production.
  • All data is synced via the GUEST user, so there is no authentication happening here, but there could be.
  • We are fixing CORS issues by allowing requests on localhost:9000 in case you wanted to serve with Python for browser testing.

Testing The Application

At this point all our code is in place and our Sync Gateway is ready to be run. Start up the Sync Gateway by running the following in a
Command Prompt or Terminal:

The Sync Gateway should now be running and you can validate this by visiting http://localhost:4984 in your web browser.

Testing For Android

With a device connected or a simulator running, from the Command Prompt or Terminal, run the following two commands to build and
install the APK file:

Testing For iOS

There are two good ways to do this. You can either build the project and open it with Xcode, or you can build and
emulate the application without launching Xcode. The first can be done like so:

Then open the project’s platform/ios/ directory and launch the Xcode project file.

If you’ve installed the Node Package Manager (NPM) package ios-sim, you can do the following:

Conclusion

You saw now that there are two ways you can use Couchbase in your Ionic Framework mobile Android and iOS application. You can use the
Apache Cordova Couchbase plugin as demonstrated in
the previous blog series, or you can
use PouchDB. Both of these are very suitable options when it comes to cross platform data storage and sync in your application.

You can obtain the full working source code to this blog post via
our Couchbase Labs GitHub repository.

Posted by Nic Raboy, Developer Advocate, Couchbase

Nic Raboy is an advocate of modern web and mobile development technologies. He has experience in Java, JavaScript, Golang and a variety of frameworks such as Angular, NativeScript, and Apache Cordova. Nic writes about his development experiences related to making web and mobile development easier to understand.

28 Comments

  1. Hi, interesting article. Do you know some hosting for CouchDB to store/sync app data ?

    1. Hi,

      This is article talks about Couchbase. CouchDB is an entirely different piece of software.

      You can host Couchbase on just about anything. Popular hosting solutions are AWS and Joyent, but there are a ton more.

      Does this answer your question?

      Best,

      1. My bad, I always make the mistake…
        I\’m looking for a really simple Couchbase hosting, something like heroku for example…
        Many tutorials on PouchDB explain on how to use it locally but I can\’t find one showing real sync between devices with a server (and some recommandations for hosting, security…).

        I\’m still a bit confused on how to use PouchDB / Couchbase as primary storage for an app but I should investigate/test more 😉

        1. You might read this:

          http://blog.couchbase.com/2015

          It is part 1 of a two part series for getting Couchbase Server and Couchbase Sync Gateway working on AWS.

          Best,

          1. I\’ll check. Thanks a lot.

          2. No problem! Report back with any discoveries you make 🙂

  2. Thanks sir,for this great tutorial.

      1. Hi sir,
        Thanks i got everything right.
        Also, i was trying to add another input i.e date input. I supplied it to the save function parameter and argument.
        And it was fine after saving to db but not displaying the date value in the edit mode.
        Thanks.

        1. Hi sir,
          I eventually solve it by including this in the get function.

          $scope.inputForm.Date = new Date($scope.inputForm.Date);

  3. Hi sir,
    Thanks once again for the tutorial.
    I would like to say i encounter this throw on the console when testing the app after some time.
    I am using (windows, ionic, angularjs, chrome).

    \” (node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit \”

    Thnaks

    1. Per Nolan Lawson, the creator of PouchDB, that is merely a warning and not an error:

      http://pouchdb.com/errors.html

      He recommends updating to PouchDB 5 and increasing the limit if you want the error to go away.

      Best,

  4. Hi Nic,

    Thank you for the tutorials!

    I\’ve tried both \”Couchbase Lite PhoneGap\” & \”PouchDB + SQLite\” as a client for Sync Gateway.
    Seems that \”Couchbase Lite PhoneGap\” has some problems: https://github.com/couchbasela… and also PouchDB is more cross-platform IMHO (we can reuse the code in webapps as well) – I hope Couchbase Sync Gateway will not break the integration with PouchDB and vise-versa.

    So, I\’ve tried to upgrade your example to latest PouchDB 5.1.0 and encountered errors and problems (I think they are related to CORS integration and also similar to this one: https://github.com/pouchdb/pou

    Have you tried latest version of PouchDB 5.1.0 / or even latest nightly build which fixes some of the bugs?

    Could you please provide more information: did you intentionally used latest 4.x version: 4.0.3, because of the errors above or other issues?

    Example for PouchDB 5.x services which I wrote: https://gist.github.com/Danail

    1. Hey,

      I wrote / published this article only days before 5.x was released. It was not intentional to use an older version. I talked with Nolan Lawson, the creator of PouchDB, and he said it should work.

      I\’ll do some testing and let you know.

      Best,

      1. Thank you for your quick response!

        I have tested with latest \”Couchbase Sync Gateway Community Edition 1.1.1\” and \”PouchDB 5.0.1\” – before I was using Docker\’s image which is not latest version (latest docker image is 1.1.0 https://hub.docker.com/r/couch… and it has critical bugs – http://developer.couchbase.com….

        The migration of your test app is easy: https://github.com/DanailMinch… and doesn\’t need any specific changes.

        So the results are the same:

        When I start the app and in the app:
        1. insert first record
        2. edit the same record
        3. delete the same record
        I can see the changes in http://localhost:4985/_admin/db/test-database

        But, after this I get some weird errors in Sync Gateway console:

        2015-11-20T13:59:55.370Z Changes+: MultiChangesFeed: channels expand to channels.TimedSet{\”*\”:0x0} …
        2015-11-20T13:59:55.370Z Changes: MultiChangesFeed done
        2015-11-20T13:59:55.370Z Changes+: MultiChangesFeed: channels expand to channels.TimedSet{\”*\”:0x0} …
        2015-11-20T13:59:55.370Z Changes+: MultiChangesFeed waiting…
        2015-11-20T13:59:55.370Z Changes+: Waiting for \”test-database\”\’s count to pass 6
        2015-11-20T13:59:55.761Z HTTP: #791: GET /?_nonce=1448027995207
        2015-11-20T13:59:55.786Z HTTP: #792: GET /test-database/_local/pqPlGGz4hPigHnXAGLPSNg==?&_nonce=1448027995234
        2015-11-20T13:59:55.787Z HTTP: #792: –> 404 missing (0.4 ms)
        2015-11-20T13:59:55.824Z HTTP: #793: POST /test-database/_revs_diff?_nonce=1448027995276
        2015-11-20T13:59:55.839Z HTTP: #794: GET /test-database/_local/pqPlGGz4hPigHnXAGLPSNg==?&_nonce=1448027995290
        2015-11-20T13:59:55.840Z HTTP: #794: –> 404 missing (0.3 ms)
        2015-11-20T13:59:55.859Z HTTP: #795: POST /test-database/_bulk_docs?_nonce=1448027995309
        2015-11-20T13:59:55.860Z BulkDocs: Doc \”_local/pqPlGGz4hPigHnXAGLPSNg==\” –> 400 Invalid doc ID (400 Invalid doc ID)
        2015-11-20T13:59:56.174Z HTTP: #796: GET /?_nonce=1448027995616
        2015-11-20T13:59:56.200Z HTTP: #797: GET /test-database/_local/pqPlGGz4hPigHnXAGLPSNg==?&_nonce=1448027995646
        2015-11-20T13:59:56.200Z HTTP: #797: –> 404 missing (0.2 ms)
        2015-11-20T13:59:56.231Z HTTP: #798: POST /test-database/_revs_diff?_nonce=1448027995683
        2015-11-20T13:59:56.246Z HTTP: #799: GET /test-database/_local/pqPlGGz4hPigHnXAGLPSNg==?&_nonce=1448027995698
        2015-11-20T13:59:56.247Z HTTP: #799: –> 404 missing (0.3 ms)
        2015-11-20T13:59:56.265Z HTTP: #800: POST /test-database/_bulk_docs?_nonce=1448027995718
        2015-11-20T13:59:56.265Z BulkDocs: Doc \”_local/pqPlGGz4hPigHnXAGLPSNg==\” –> 400 Invalid doc ID (400 Invalid doc ID)
        2015-11-20T13:59:57.988Z HTTP: #801: GET /?_nonce=1448027997429
        2015-11-20T13:59:58.015Z HTTP: #802: GET /test-database/_local/pqPlGGz4hPigHnXAGLPSNg==?&_nonce=1448027997462
        2015-11-20T13:59:58.015Z HTTP: #802: –> 404 missing (0.4 ms)
        2015-11-20T13:59:58.065Z HTTP: #803: POST /test-database/_revs_diff?_nonce=1448027997511
        2015-11-20T13:59:58.087Z HTTP: #804: GET /test-database/_local/pqPlGGz4hPigHnXAGLPSNg==?&_nonce=1448027997531
        2015-11-20T13:59:58.087Z HTTP: #804: –> 404 missing (0.3 ms)
        2015-11-20T13:59:58.106Z HTTP: #805: POST /test-database/_bulk_docs?_nonce=1448027997558
        2015-11-20T13:59:58.106Z BulkDocs: Doc \”_local/pqPlGGz4hPigHnXAGLPSNg==\” –> 400 Invalid doc ID (400 Invalid doc ID)
        2015-11-20T13:59:58.545Z HTTP: #806: GET /?_nonce=1448027997993
        2015-11-20T13:59:58.574Z HTTP: #807: GET /test-database/_local/pqPlGGz4hPigHnXAGLPSNg==?&_nonce=1448027998022
        2015-11-20T13:59:58.574Z HTTP: #807: –> 404 missing (0.3 ms)

        Which keeps looping and my second record is unable to sync with the gateway.

      2. Thank you for your response!

        I have tested with latest \”Couchbase Sync Gateway Community Edition 1.1.1\” and \”PouchDB 5.0.1\” (also with Docker images)

        The results are the same:

        When I start the app and in the app:
        1. insert first record
        2. edit the same record
        3. delete the same record
        I can see the changes in http://localhost:4985/_admin/db/test-database

        But, after this I get some weird errors in Sync Gateway console:

        2015-11-20T13:59:55.370Z Changes+: MultiChangesFeed: channels expand to channels.TimedSet{\”*\”:0x0} …
        2015-11-20T13:59:55.370Z Changes: MultiChangesFeed done
        2015-11-20T13:59:55.370Z Changes+: MultiChangesFeed: channels expand to channels.TimedSet{\”*\”:0x0} …
        2015-11-20T13:59:55.370Z Changes+: MultiChangesFeed waiting…
        2015-11-20T13:59:55.370Z Changes+: Waiting for \”test-database\”\’s count to pass 6
        2015-11-20T13:59:55.761Z HTTP: #791: GET /?_nonce=1448027995207
        2015-11-20T13:59:55.786Z HTTP: #792: GET /test-database/_local/pqPlGGz4hPigHnXAGLPSNg==?&_nonce=1448027995234
        2015-11-20T13:59:55.787Z HTTP: #792: –> 404 missing (0.4 ms)
        2015-11-20T13:59:55.824Z HTTP: #793: POST /test-database/_revs_diff?_nonce=1448027995276
        2015-11-20T13:59:55.839Z HTTP: #794: GET /test-database/_local/pqPlGGz4hPigHnXAGLPSNg==?&_nonce=1448027995290
        2015-11-20T13:59:55.840Z HTTP: #794: –> 404 missing (0.3 ms)
        2015-11-20T13:59:55.859Z HTTP: #795: POST /test-database/_bulk_docs?_nonce=1448027995309
        2015-11-20T13:59:55.860Z BulkDocs: Doc \”_local/pqPlGGz4hPigHnXAGLPSNg==\” –> 400 Invalid doc ID (400 Invalid doc ID)
        2015-11-20T13:59:56.174Z HTTP: #796: GET /?_nonce=1448027995616
        2015-11-20T13:59:56.200Z HTTP: #797: GET /test-database/_local/pqPlGGz4hPigHnXAGLPSNg==?&_nonce=1448027995646
        2015-11-20T13:59:56.200Z HTTP: #797: –> 404 missing (0.2 ms)
        2015-11-20T13:59:56.231Z HTTP: #798: POST /test-database/_revs_diff?_nonce=1448027995683
        2015-11-20T13:59:56.246Z HTTP: #799: GET /test-database/_local/pqPlGGz4hPigHnXAGLPSNg==?&_nonce=1448027995698
        2015-11-20T13:59:56.247Z HTTP: #799: –> 404 missing (0.3 ms)
        2015-11-20T13:59:56.265Z HTTP: #800: POST /test-database/_bulk_docs?_nonce=1448027995718
        2015-11-20T13:59:56.265Z BulkDocs: Doc \”_local/pqPlGGz4hPigHnXAGLPSNg==\” –> 400 Invalid doc ID (400 Invalid doc ID)
        2015-11-20T13:59:57.988Z HTTP: #801: GET /?_nonce=1448027997429
        2015-11-20T13:59:58.015Z HTTP: #802: GET /test-database/_local/pqPlGGz4hPigHnXAGLPSNg==?&_nonce=1448027997462
        2015-11-20T13:59:58.015Z HTTP: #802: –> 404 missing (0.4 ms)
        2015-11-20T13:59:58.065Z HTTP: #803: POST /test-database/_revs_diff?_nonce=1448027997511
        2015-11-20T13:59:58.087Z HTTP: #804: GET /test-database/_local/pqPlGGz4hPigHnXAGLPSNg==?&_nonce=1448027997531
        2015-11-20T13:59:58.087Z HTTP: #804: –> 404 missing (0.3 ms)
        2015-11-20T13:59:58.106Z HTTP: #805: POST /test-database/_bulk_docs?_nonce=1448027997558
        2015-11-20T13:59:58.106Z BulkDocs: Doc \”_local/pqPlGGz4hPigHnXAGLPSNg==\” –> 400 Invalid doc ID (400 Invalid doc ID)
        2015-11-20T13:59:58.545Z HTTP: #806: GET /?_nonce=1448027997993
        2015-11-20T13:59:58.574Z HTTP: #807: GET /test-database/_local/pqPlGGz4hPigHnXAGLPSNg==?&_nonce=1448027998022
        2015-11-20T13:59:58.574Z HTTP: #807: –> 404 missing (0.3 ms)

        Which keeps looping and my second record is unable to sync with the gateway.

      3. Hi again,

        It seems that PouchDB 5.0.0 works with the project, but 5.1.0 doesn\’t work.

        I\’ve created an issue here: https://github.com/pouchdb/pou

        Please let me know if you managed to update to latest 5.1.0 version or any other news, thanks!

  5. FairwindTechnologies January 22, 2016 at 10:01 pm

    I am looking at using almost exactly this paradigm for solution I am developing for kids with ADHD. Would love to use Couchbase Sync to keep users data synced between the users local app in Ionic and the master DB in the cloud. I am unsure how user authentication in the DBs would work with / sync with a CAS /OAuth 2 service that will be used by Spring Security to authenticate user requests outside of the database environment from the web site and/or other mobile functions. Is there a way to sync the couchbase user accounts with other authentication services like oauth or CAS or some other token based service? My original architecture was not an offline first design and I was just going to use token based access to web services across the mobile and web components, but CouchBase with Sync looks so awesome for doing DB sync, I want to leverage that! Any thoughts would be appreciated! Do you or couchbase provide architectural consulting services? Anyway, please let me know about the user account sync!

    BTW, I am using AWS and also read through the post http://blog.couchbase.com/2015… which is also relevant to what I am trying to do. Imagine that with a web version as well and trying to keep the data AND user accounts synced across both platforms…

    Thanks,

    Rich

    1. When you say CAS are you referring to Jasig CAS? I don\’t think it would be an issue to rig this together with your single sign on solution.

      I mentioned your request for architectural consulting to my team. Can I have you email services@couchbase.com. Just reference this post in it.

      Best,

      1. FairwindTechnologies January 22, 2016 at 11:16 pm

        Nic, yes I meant JASIG CAS. I guess that in a nut shell, yes, I am trying to figure out how to best integrate CB with a token based SSO solution. I will email your services team, thanks.

        1. Awesome. I\’m sure we\’ll be in touch 🙂

  6. Hi Nic,

    Thank you very much for this tutorial!

    Though I seem to have some trouble, when I am attempting to save documents in my sync_gateway (either through walrus or a bucket on the Couchbase server ).

    I am also getting a strange output from my Sync Gateway (I am using the \’default\’ bucket):

    Tareks-MacBook-Pro:ionic-framework-pouchdb-master Tarek$ sync_gateway sync-gateway-config.json
    2016-04-26T14:36:38.840+03:00 Enabling logging: [CRUD+ REST+ Changes+ Attach+]
    2016-04-26T14:36:38.840+03:00 ==== Couchbase Sync Gateway/1.1.1(10;2fff9eb) ====
    2016-04-26T14:36:38.841+03:00 Configured Go to use all 4 CPUs; setenv GOMAXPROCS to override this
    2016-04-26T14:36:38.841+03:00 Configured process to allow 5000 open file descriptors
    2016-04-26T14:36:38.841+03:00 Opening db /default as bucket \”default\”, pool \”default\”, server <http: localhost:8091=\”\”>
    2016-04-26T14:36:38.841+03:00 Opening Couchbase database default on <http: localhost:8091=\”\”>
    2016/04/26 14:36:38 Trying with http://127.0.0.1:8091/pools/default/bucketsStreaming/default
    2016/04/26 14:36:38 Trying with selected node 0
    2016/04/26 14:36:38 Got new configuration for bucket default
    2016/04/26 14:36:38 Trying with selected node 0
    2016-04-26T14:36:38.987+03:00 Reset guest user to config
    2016-04-26T14:36:38.987+03:00 Starting admin server on 127.0.0.1:4985
    2016-04-26T14:36:38.991+03:00 Starting server on :4984 …
    2016-04-26T14:36:49.750+03:00 HTTP: #001: GET /default/?_nonce=1461670609748
    2016-04-26T14:37:49.464+03:00 HTTP: #002: GET /default/?_nonce=1461670669460
    2016-04-26T14:37:50.572+03:00 HTTP: #003: GET /default/?_nonce=1461670670570
    2016-04-26T14:37:50.833+03:00 HTTP: #004: GET /default/?_nonce=1461670670831
    2016-04-26T14:37:52.465+03:00 HTTP: #005: GET /default/?_nonce=1461670672463
    2016-04-26T14:37:52.793+03:00 HTTP: #006: GET /default/?_nonce=1461670672792
    2016-04-26T14:37:55.567+03:00 HTTP: #007: GET /default/?_nonce=1461670675566
    2016-04-26T14:37:56.393+03:00 HTTP: #008: GET /default/?_nonce=1461670676392
    2016-04-26T14:38:00.794+03:00 HTTP: #009: GET /default/?_nonce=1461670680792
    2016-04-26T14:38:02.589+03:00 HTTP: #010: GET /default/?_nonce=1461670682587

    Please let me know if you require anymore information from my side as well.

    Best regards,
    Tarek M.

    1. Hey Tarek,

      I don\’t see anything out of the ordinary in your Sync Gateway log. Can you give me more information in regards to what you\’re having trouble with when you save?

      Best,

      1. Tarek Moubarak April 26, 2016 at 8:28 pm

        Hi Nic,

        Thank you for your swift reply! The thing is, I am currently unable to see any new documents in my CouchBase Server (my main priority is to see the data in the buckets instead on using walrus). This is how I have configured my sync gateway (currently on version 1.2):

        {
        \”log\”:[\”CRUD+\”, \”REST+\”, \”Changes+\”, \”Attach+\”],
        \”databases\”: {
        \”default\”: {
        \”server\”:\”http://localhost:8091\”,
        \”bucket\”:\”default\”,
        \”sync\”:
        function (doc) {
        channel (doc.channels);
        }
        ,
        \”users\”: {
        \”GUEST\”: {
        \”disabled\”: false,
        \”admin_channels\”: [\”*\”]
        }
        }
        }
        },
        \”CORS\”: {
        \”Origin\”: [\”http://localhost:9000\”],
        \”LoginOrigin\”: [\”http://localhost:9000\”],
        \”Headers\”: [\”Content-Type\”],
        \”MaxAge\”: 17280000
        }
        }

        I tried adding the logging level on the sync gateway, but couldn\’t see any POST or PUT messages being called, nor could I see them on the sync gateway.

        I also used ran the command: python -m SimpleHTTPServer 9000 for CORS.

        perhaps I\’m missing a step or something is mis-configured?

        Thank you in advance, really appreciate your help. 🙂

        1. You\’re not trying to use Ionic Serve, Ionic Ionic-Live Reload or Ionic View, are you? They tend to not work with native plugins. Also, what do your application logs say? You probably want to start there.

          Best,

          1. Tarek Moubarak May 5, 2016 at 1:21 pm

            Hi Nic,

            Thank you very much! Initially I was trying it on ionic serve, I tried it directly on my mobile device and it worked seamlessly.
            Earlier attempts failed though because my mobile device and server where connected on different networks, which caused some confusion.

            Thank you very much Nic!

          2. No problem!

Leave a reply