GithubHelp home page GithubHelp logo

alexandruantonica / nativescript-telephony Goto Github PK

View Code? Open in Web Editor NEW

This project forked from roblav96/nativescript-telephony

0.0 2.0 0.0 1.39 MB

A Nativescript plugin to get the device's SIM data (carrier name, mcc mnc, country code, telephonenumber, etc)

License: Other

TypeScript 100.00%

nativescript-telephony's Introduction

NativeScript-Telephony

This is a Nativescript plugin to get data from the SIM card like the carrier name, mcc, mnc and country code and other system dependent additional info.

Contributors

Peter Bakondy for his work on cordova-plugin-sim. Basically this is his plugin. I followed his source code as a guide.

Supported Platforms

  • Android
  • iOS

Installation

tns plugin add nativescript-telephony

Usage

Typescript

import {Telephony} from 'nativescript-telephony';

Telephony().then(function(resolved) {
	console.log('resolved >', resolved)
	console.dir(resolved);
}).catch(function(error) {
	console.error('error >', error)
	console.dir(error);
})

ES6 Promises

If you are unfamiliar with Promises, read up on these:

iOS Quirks

Promise.Resolves

{
  "carrierName": String,
  "countryCode": String,
  "mcc": String,
  "mnc": String,
  "allowsVOIP": Boolean,
}

Sadly there's nothing more we can get here.

Promise.Rejects

When using an emulator or a sim card does not exist.

Android Quirks

All permission dialogues are built into the Telephony function.

Promise.Resolves

When Permission is DENIED to READ_PHONE_STATE
{
	"countryCode": String,
	"simOperator": String,
	"carrierName": String,
	"callState": Number,
	"dataActivity": Number,
	"networkType": Number,
	"phoneType": Number,
	"simState": Number,
	"isNetworkRoaming": Boolean,
	"mcc": String,
	"mnc": String,
}
When Permission is GRANTED to READ_PHONE_STATE
{
	// START GRANTED PERMISSIONS
	"phoneNumber": String,
	"deviceId": String,
	"deviceSoftwareVersion": String,
	"simSerialNumber": String,
	"subscriberId": String,
	// END GRANTED PERMISSIONS
	"countryCode": String,
	"simOperator": String,
	"carrierName": String,
	"callState": Number,
	"dataActivity": Number,
	"networkType": Number,
	"phoneType": Number,
	"simState": Number,
	"isNetworkRoaming": Boolean,
	"mcc": String,
	"mnc": String,
}

Promise.Rejects

Never.

Demo

npm run setup
# iOS
npm run demo.ios
# Android
npm run demo.android

License

This plugin is licensed under the MITlicense by Rob Laverty

nativescript-telephony's People

Contributors

roblav96 avatar sis0k0 avatar

Watchers

James Cloos avatar Alexandru C Antonica avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.