Skip to content

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

Notifications You must be signed in to change notification settings

meirotstein/cordova-plugin-contacts-mock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published