0

I have simple code

import { Sim } from '@ionic-native/sim';
    constructor(private navParams: NavParams, private sim: Sim, public navCtrl: NavController, private androidPermissions: AndroidPermissions) {
this.sim.requestReadPermission().then(
          () => console.log('Permission granted'),
          () => console.log('Permission denied')
      );
  public goToReport(){
            this.sim.getSimInfo().then((info) => console.log(info.phoneNumber))
    }

but i get empty string. When i try to console something like console.log(info.deviceId) /Its need READ_PHONE_STATE permissions as phone number too everything work fine

ItsMyLife
  • 458
  • 7
  • 21
  • Have you tried by wrapping the code in the constructor inside of the platform ready, like this: `this.plt.ready().then((readySource) => { // ... });`? – sebaferreras Sep 08 '17 at 09:19
  • 1
    I try do this `this.plt.ready().then((readySource) =>this.sim.getSimInfo().then((info) => console.log(info.phoneNumber)))` but itstill not working – ItsMyLife Sep 08 '17 at 09:36

1 Answers1

0

If you have a look at the docs, especially the return-object docs you will find a footnote there:

Notice: the content of phoneNumber is unreliable (see this, this, and this article). Sometimes phoneNumber is only an empty string.

David
  • 7,387
  • 3
  • 22
  • 39