Naphthalene Possum Management
Wondering what’s next for npm?Check out our public roadmap! »

cordova-plugin-contacts-mock

1.0.1 • Public • Published

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 a 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.

Chrome DevTools

Notes

(1) Contacts must be saved in array structure

(2) It was tested on chrome only..

Install

npm i cordova-plugin-contacts-mock

DownloadsWeekly Downloads

10

Version

1.0.1

License

ISC

Last publish

Collaborators

  • avatar