Skip to content

Commit

Permalink
iOS SDK 4.0.0 and Phone auth
Browse files Browse the repository at this point in the history
  • Loading branch information
Juan Fernando Semaan authored and Juan Fernando Semaan committed May 31, 2017
1 parent c765744 commit f9b7e80
Show file tree
Hide file tree
Showing 70 changed files with 2,996 additions and 181 deletions.
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# UPDATED TO IOS SDK 4
This update was done to test phone authentication in iOS. All other methods haven't been tested.

# cordova-plugin-firebase
This plugin brings push notifications, analytics, event tracking, crash reporting and more from Google Firebase to your Cordova project!
Android and iOS supported (including iOS 10).
Expand Down Expand Up @@ -327,3 +330,37 @@ window.FirebasePlugin.setDefaults(defaults);
// or, specify a namespace
window.FirebasePlugin.setDefaults(defaults, "namespace");
```

### Phone Authetication (iOS only)

IMPORTANT: SETUP YOUR PUSH NOTIFICATIONS FIRST, AND VERIFY THAT THEY ARE ARRIVING TO YOUR PHYSICAL DEVICE BEFORE YOU TEST THIS METHOD. USE THE APNS AUTH KEY TO GENERATE THE .P8 FILE AND UPLOAD IT TO FIREBASE.
WHEN YOU CALL THIS METHOD, FCM SENDS A SILENT PUSH TO THE DEVICE TO VERIFY IT.

This method sends an SMS to the user with the SMS_code and gets the verification id you need to continue the sign in process, with the Firebase JS SDK.

```
window.FirebasePlugin.getVerificationID("+573123456789",function(id) {
console.log("verificationID: "+id);
}, function(error) {
console.error(error);
});
```

Using Ionic2?
```
(<any>window).FirebasePlugin.getVerificationID("+573123456789", id => {
console.log("verificationID: " + id);
this.verificationId = id;
}, error => {
console.log("error: " + error);
});
```
Get the intermediate AuthCredential object
```
var credential = firebase.auth.PhoneAuthProvider.credential(verificationId, SMS_code);
```
Then, you can sign in the user with the credential:
```
firebase.auth().signInWithCredential(credential);
```
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"author": {
"name": "Robert Arnesson"
"name": "Robert Arnesson, Juan Semaan"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/arnesson/cordova-plugin-firebase"
"url": "https://github.com/silverio/cordova-plugin-firebase"
},
"name": "cordova-plugin-firebase",
"version": "0.1.21",
Expand All @@ -25,6 +25,7 @@
"cordova-browser",
"firebase",
"push",
"notifications"
"notifications",
"phone auth"
]
}
4 changes: 4 additions & 0 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,16 @@ xmlns:android="http://schemas.android.com/apk/res/android">

<framework custom="true" src="src/ios/Firebase/Analytics/FirebaseAnalytics.framework" />
<framework custom="true" src="src/ios/Firebase/Analytics/FirebaseCore.framework" />
<framework custom="true" src="src/ios/Firebase/Analytics/FirebaseCoreDiagnostics.framework" />
<framework custom="true" src="src/ios/Firebase/Analytics/FirebaseInstanceID.framework" />
<framework custom="true" src="src/ios/Firebase/Analytics/FirebaseNanoPB.framework" />
<framework custom="true" src="src/ios/Firebase/Analytics/GoogleToolboxForMac.framework" />
<framework custom="true" src="src/ios/Firebase/Messaging/Protobuf.framework" />
<framework custom="true" src="src/ios/Firebase/Messaging/FirebaseMessaging.framework" />
<framework custom="true" src="src/ios/Firebase/Crash/FirebaseCrash.framework" />
<framework custom="true" src="src/ios/Firebase/RemoteConfig/FirebaseRemoteConfig.framework" />
<framework custom="true" src="src/ios/Firebase/Auth/FirebaseAuth.framework" />
<framework custom="true" src="src/ios/Firebase/Auth/GTMSessionFetcher.framework" />
</platform>

<platform name="browser">
Expand Down
2 changes: 1 addition & 1 deletion scripts/after_prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ if (directoryExists("platforms/ios")) {
if (fileExists(paths[i])) {
try {
var contents = fs.readFileSync(paths[i]).toString();
fs.writeFileSync("platforms/ios/" + name + "/Resources/GoogleService-Info.plist", contents)
fs.writeFileSync("platforms/ios/" + name + "/Resources/Resources/GoogleService-Info.plist", contents)
} catch(err) {
process.stdout.write(err);
}
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#import "FIRAnalytics.h"

NS_ASSUME_NONNULL_BEGIN

/**
* Provides App Delegate handlers to be used in your App Delegate.
*
Expand Down Expand Up @@ -29,14 +31,14 @@
* updated and a new snapshot can be taken.
*/
+ (void)handleEventsForBackgroundURLSession:(NSString *)identifier
completionHandler:(void (^)(void))completionHandler;
completionHandler:(nullable void (^)(void))completionHandler;

/**
* Handles the event when the app is launched by a URL.
*
* Call this method from [UIApplicationDelegate application:openURL:options:] (on iOS 9.0 and
* above), or [UIApplicationDelegate application:openURL:sourceApplication:annotation:] (on iOS 8.x
* and below) in your app.
* Call this method from [UIApplicationDelegate application:openURL:options:] &#40;on iOS 9.0 and
* above&#41;, or [UIApplicationDelegate application:openURL:sourceApplication:annotation:] &#40;on
* iOS 8.x and below&#41; in your app.
*
* @param url The URL resource to open. This resource can be a network resource or a file.
*/
Expand All @@ -55,3 +57,6 @@
+ (void)handleUserActivity:(id)userActivity;

@end

NS_ASSUME_NONNULL_END

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#import <Foundation/Foundation.h>

#import "FIRAnalyticsSwiftNameSupport.h"
#import "FIREventNames.h"
#import "FIRParameterNames.h"
#import "FIRUserPropertyNames.h"
Expand All @@ -9,6 +10,7 @@ NS_ASSUME_NONNULL_BEGIN
/// The top level Firebase Analytics singleton that provides methods for logging events and setting
/// user properties. See <a href="http://goo.gl/gz8SLz">the developer guides</a> for general
/// information on using Firebase Analytics in your apps.
FIR_SWIFT_NAME(Analytics)
@interface FIRAnalytics : NSObject

/// Logs an app event. The event can have up to 25 parameters. Events with the same name must have
Expand All @@ -17,6 +19,12 @@ NS_ASSUME_NONNULL_BEGIN
///
/// The following event names are reserved and cannot be used:
/// <ul>
/// <li>ad_activeview</li>
/// <li>ad_click</li>
/// <li>ad_exposure</li>
/// <li>ad_impression</li>
/// <li>ad_query</li>
/// <li>adunit_exposure</li>
/// <li>app_clear_data</li>
/// <li>app_remove</li>
/// <li>app_update</li>
Expand All @@ -28,23 +36,26 @@ NS_ASSUME_NONNULL_BEGIN
/// <li>notification_open</li>
/// <li>notification_receive</li>
/// <li>os_update</li>
/// <li>screen_view</li>
/// <li>session_start</li>
/// <li>user_engagement</li>
/// </ul>
///
/// @param name The name of the event. Should contain 1 to 40 alphanumeric characters or
/// underscores. The name must start with an alphabetic character. Some event names are
/// reserved. See FIREventNames.h for the list of reserved event names. The "firebase_" prefix
/// is reserved and should not be used. Note that event names are case-sensitive and that
/// logging two events whose names differ only in case will result in two distinct events.
/// reserved. See FIREventNames.h for the list of reserved event names. The "firebase_",
/// "google_", and "ga_" prefixes are reserved and should not be used. Note that event names are
/// case-sensitive and that logging two events whose names differ only in case will result in
/// two distinct events.
/// @param parameters The dictionary of event parameters. Passing nil indicates that the event has
/// no parameters. Parameter names can be up to 40 characters long and must start with an
/// alphabetic character and contain only alphanumeric characters and underscores. Only NSString
/// and NSNumber (signed 64-bit integer and 64-bit floating-point number) parameter types are
/// supported. NSString parameter values can be up to 100 characters long. The "firebase_"
/// prefix is reserved and should not be used for parameter names.
/// supported. NSString parameter values can be up to 100 characters long. The "firebase_",
/// "google_", and "ga_" prefixes are reserved and should not be used for parameter names.
+ (void)logEventWithName:(NSString *)name
parameters:(nullable NSDictionary<NSString *, NSObject *> *)parameters;
parameters:(nullable NSDictionary<NSString *, id> *)parameters
FIR_SWIFT_NAME(logEvent(_:parameters:));

/// Sets a user property to a given value. Up to 25 user property names are supported. Once set,
/// user property values persist throughout the app lifecycle and across sessions.
Expand All @@ -59,9 +70,10 @@ NS_ASSUME_NONNULL_BEGIN
/// @param value The value of the user property. Values can be up to 36 characters long. Setting the
/// value to nil removes the user property.
/// @param name The name of the user property to set. Should contain 1 to 24 alphanumeric characters
/// or underscores and must start with an alphabetic character. The "firebase_" prefix is
/// reserved and should not be used for user property names.
+ (void)setUserPropertyString:(nullable NSString *)value forName:(NSString *)name;
/// or underscores and must start with an alphabetic character. The "firebase_", "google_", and
/// "ga_" prefixes are reserved and should not be used for user property names.
+ (void)setUserPropertyString:(nullable NSString *)value forName:(NSString *)name
FIR_SWIFT_NAME(setUserProperty(_:forName:));

/// Sets the user ID property. This feature must be used in accordance with
/// <a href="https://www.google.com/policies/privacy">Google's Privacy Policy</a>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#ifndef FIR_SWIFT_NAME

#import <Foundation/Foundation.h>

// NS_SWIFT_NAME can only translate factory methods before the iOS 9.3 SDK.
// Wrap it in our own macro if it's a non-compatible SDK.
#ifdef __IPHONE_9_3
#define FIR_SWIFT_NAME(X) NS_SWIFT_NAME(X)
#else
#define FIR_SWIFT_NAME(X) // Intentionally blank.
#endif // #ifdef __IPHONE_9_3

#endif // FIR_SWIFT_NAME
Loading

0 comments on commit f9b7e80

Please sign in to comment.