Search code examples
androidcordovaionic-frameworkcordova-pluginsionic-native

Returned objects from ionic native - Sim


I am trying to fetch the device phone number of the mobile phone on which the ionic app is installed I am using
(ionic cordova plugin add cordova-plugin-sim)
I do get an object as response,
What i need to find is what are the elements of the abject as i need to parse it.
Code below
The HTML file

<ion-content padding>
<button ion-button full (click)="getDeviceInfo()">Password Reset</button>
  <ion-item>
    {{deviceInfo}}
  </ion-item>
</ion-content>

The typescript file

getDeviceInfo(){
this.sim.getSimInfo().then((info)=>{
  this.deviceInfo = info;
  console.log(this.deviceInfo);
  alert(this.deviceInfo);
}, Error=>{
  alert('Could not capture device information!');
});
}

The response i get is an object [Object][Object]
I tried looking at the log cat in android studio but did not find anything

How do i parse this? Any advise will be great help.
Thanks in advance


Solution

  • Convert the object into a string using JSON.stringify

    console.log(JSON.stringify(this.deviceInfo));