Skip to content

Commit

Permalink
Step 13.1: Implement getNumber with native ionic
Browse files Browse the repository at this point in the history
  • Loading branch information
dotansimha authored and DAB0mB committed Feb 13, 2017
1 parent 2a8d062 commit d044e82
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/services/phone.ts
Expand Up @@ -2,13 +2,25 @@ import { Injectable } from '@angular/core';
import { Accounts } from 'meteor/accounts-base';
import { Meteor } from 'meteor/meteor';
import { Platform } from 'ionic-angular';
import { Sim } from 'ionic-native';

@Injectable()
export class PhoneService {
constructor(private platform: Platform) {

}

getNumber(): Promise<string> {
if (!this.platform.is('cordova') ||
!this.platform.is('mobile')) {
return Promise.resolve('');
}

return Sim.getSimInfo().then((info) => {
return '+' + info.phoneNumber;
});
}

verify(phoneNumber: string): Promise<void> {
return new Promise<void>((resolve, reject) => {
Accounts.requestPhoneVerification(phoneNumber, (e: Error) => {
Expand Down

0 comments on commit d044e82

Please sign in to comment.