cpc

cordova-plugin-contacts-mock

Mocks cordova-plugin-contacts to allow easier browser based development of cordova applications

Showing:

Popularity

Downloads/wk

7

GitHub Stars

3

Maintenance

Last Commit

4yrs ago

Contributors

0

Package

Dependencies

0

License

ISC

Type Definitions

Tree-Shakeable

No?

Categories

Readme

Built with Gulp Build Status npm version

cordova-plugin-contacts-mock

When developing a cordova based application - such as ionic - the major development is mostly done in a local browser-based environment such as ionic serve.

It is very fast and comfortable developent environment on the one hand, however it is lack with some native services on the other - this makes the development quite harder.

This library is a mock for the apache cordova contacts plugin, if offers a similar api and usage as the native plugin, however the contacts data is read and stored in the browser's local storage instead.

By using this library you can write your code and test it with any kind of contacts data you like, and at the end just to verify that it works on the device as expected.

Installation

npm install cordova-plugin-contacts-mock --save-dev

Setup

Add the /build/contacts-mock.js script into you app index.html

<script src="path-to-cordova-contacts-plugin-mock/build/contacts-mock.js"></script>

As you dont want this script to run on the device itself it is recommended to create a different index.html files for local dev and productive use

Usage

Usage is the same as described in the cordova documentation and in $cordovaContacts

Contacts Data

cordova-plugin-contacts-mock is using the browser local storage to read and save the contacts data - the data is saved under the cordova.contacts.mock.data key on the follwing Contact structure:

[{
    "id": "123",
    "rawId": "123",
    "displayName": "",
    "name": {
      "givenName": "",
      "formatted": ""
    },
    "nickname": null,
    "phoneNumbers": [
      {
        "id": "1711",
        "pref": false,
        "value": "972+54+7777777",
        "type": "mobile"
      }
    ],
    "emails": [],
    "addresses": [],
    "ims": [],
    "organizations": null,
    "birthday": null,
    "note": "",
    "photos": null,
    "categories": null,
    "urls": null
  }]

You can use the browser dev tools to edit it youself or simply create and save it by code.

Notes

(1) Contacts must be saved in array structure

(2) It was tested on chrome only..

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial