How to get IMEI in ionic2 on an android device

匿名 (未验证) 提交于 2019-12-03 02:28:01

问题:

I am trying to obtain the imei of an android device in ionic 2, but so far no luck.

In ionic 1 l just used an ngCordova plugin like cordova-uid https://github.com/hygieiasoft/cordova-plugin-uid.

Is there a plugin for ionic-native that I can use to obtain the imei or is there any other way to get the imei.

回答1:

Can use this code.

cordova plugin add org.hygieiasoft.cordova.uid

Or

cordova plugin add https://github.com/hygieiasoft/cordova-plugin-uid

For test use console.log

  declare var cordova: any;    export class MyApp {    constructor(platform: Platform ) {     platform.ready().then(() => {        console.log(cordova.plugins.uid.IMEI);     });   }


回答2:

Check this link https://www.npmjs.com/package/cordova-plugin-sim

Install plugin via

cordova plugin add cordova-plugin-sim

use code

import { Sim } from 'ionic-native';  Sim.getSimInfo().then(   (info) => console.log('Sim info: ', info),   (err) => console.log('Unable to get sim info: ', err) );  Sim.hasReadPermission().then(   (info) => console.log('Has permission:', info) );  Sim.requestReadPermission().then(   () => console.log('Permission granted'),   () => console.log('Permission denied') );


易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!