Skip to content

Commit

Permalink
Merge pull request arnesson#636 from Moventes/master
Browse files Browse the repository at this point in the history
added back ios phone authentication
  • Loading branch information
soumak77 authored Apr 18, 2018
2 parents 650a9b5 + 3d92ce7 commit e9227ee
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/ios/FirebasePlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

@interface FirebasePlugin : CDVPlugin
+ (FirebasePlugin *) firebasePlugin;
- (void)getVerificationID:(CDVInvokedUrlCommand*)command;
- (void)getInstanceId:(CDVInvokedUrlCommand*)command;
- (void)getId:(CDVInvokedUrlCommand*)command;
- (void)getToken:(CDVInvokedUrlCommand*)command;
Expand Down
32 changes: 32 additions & 0 deletions src/ios/FirebasePlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
@import FirebaseRemoteConfig;
@import FirebasePerformance;
@import FirebaseCrash;
@import FirebaseAuth;

#if defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
@import UserNotifications;
Expand Down Expand Up @@ -154,6 +155,37 @@ - (void)grantPermission:(CDVInvokedUrlCommand *)command {
];

return;
}

- (void)getVerificationID:(CDVInvokedUrlCommand *)command {
NSString* number = [command.arguments objectAtIndex:0];

[[FIRPhoneAuthProvider provider]
verifyPhoneNumber:number
completion:^(NSString *_Nullable verificationID,
NSError *_Nullable error) {
NSDictionary *message;
if (error) {

// Verification code not sent.
message = @{
@"code": [NSNumber numberWithInteger:error.code],
@"description": error.description == nil ? [NSNull null] : error.description
};

CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:message];

[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];

} else {
// Successful.
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:verificationID];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}
}];



}

- (void)setBadgeNumber:(CDVInvokedUrlCommand *)command {
Expand Down
6 changes: 6 additions & 0 deletions www/firebase-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ exports.getVerificationID = function (number, success, error) {
}
};

exports.getVerificationID = function (number, success, error) {
if (typeof success === 'function') {
success();
}
};

exports.getInstanceId = function (success, error) {
if (typeof success === 'function') {
success();
Expand Down
4 changes: 4 additions & 0 deletions www/firebase.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
var exec = require('cordova/exec');

exports.getVerificationID = function (number, success, error) {
exec(success, error, "FirebasePlugin", "getVerificationID", [number]);
};

exports.getInstanceId = function (success, error) {
exec(success, error, "FirebasePlugin", "getInstanceId", []);
};
Expand Down

0 comments on commit e9227ee

Please sign in to comment.