From 075cd690ce1ea67875f909f2ad833d3f9d31eb39 Mon Sep 17 00:00:00 2001 From: Salakar Date: Mon, 17 Jul 2017 19:43:36 +0100 Subject: [PATCH] [android][ios][core] initialize app parameters no longer prefixed by platform name i.e iosClientId becomes clientId. Use react native platform module to provide platform specific options. --- .../io/invertase/firebase/RNFirebaseModule.java | 3 ++- .../io/invertase/firebase/auth/RNFirebaseAuth.java | 4 ---- ios/RNFirebase/RNFirebase.m | 4 ++-- ios/RNFirebase/auth/RNFirebaseAuth.m | 13 ++++++++++++- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/android/src/main/java/io/invertase/firebase/RNFirebaseModule.java b/android/src/main/java/io/invertase/firebase/RNFirebaseModule.java index 9b4e4a1f..2b6efef5 100644 --- a/android/src/main/java/io/invertase/firebase/RNFirebaseModule.java +++ b/android/src/main/java/io/invertase/firebase/RNFirebaseModule.java @@ -53,12 +53,13 @@ public class RNFirebaseModule extends ReactContextBaseJavaModule implements Life public void initializeApp(String name, ReadableMap options, Callback callback) { FirebaseOptions.Builder builder = new FirebaseOptions.Builder(); - builder.setApplicationId(options.getString("androidAppId")); + builder.setApplicationId(options.getString("appId")); builder.setGcmSenderId(options.getString("messagingSenderId")); builder.setApiKey(options.getString("apiKey")); builder.setProjectId(options.getString("projectId")); builder.setDatabaseUrl(options.getString("databaseURL")); builder.setStorageBucket(options.getString("storageBucket")); + // todo firebase sdk has no client id setter FirebaseApp.initializeApp(getReactApplicationContext(), builder.build(), name); diff --git a/android/src/main/java/io/invertase/firebase/auth/RNFirebaseAuth.java b/android/src/main/java/io/invertase/firebase/auth/RNFirebaseAuth.java index 44942be7..b13e3a9a 100644 --- a/android/src/main/java/io/invertase/firebase/auth/RNFirebaseAuth.java +++ b/android/src/main/java/io/invertase/firebase/auth/RNFirebaseAuth.java @@ -47,10 +47,6 @@ import io.invertase.firebase.Utils; @SuppressWarnings("ThrowableResultOfMethodCallIgnored") class RNFirebaseAuth extends ReactContextBaseJavaModule { private static final String TAG = "RNFirebaseAuth"; - - // itts been a while ;p - - private ReactContext mReactContext; private HashMap mAuthListeners = new HashMap<>(); diff --git a/ios/RNFirebase/RNFirebase.m b/ios/RNFirebase/RNFirebase.m index e8769800..4089fe4d 100644 --- a/ios/RNFirebase/RNFirebase.m +++ b/ios/RNFirebase/RNFirebase.m @@ -31,11 +31,11 @@ RCT_EXPORT_METHOD(initializeApp: FIRApp *existingApp = [FIRApp appNamed:name]; if (!existingApp) { - FIROptions *firOptions = [[FIROptions alloc] initWithGoogleAppID:[options valueForKey:@"iosAppId"] GCMSenderID:[options valueForKey:@"messagingSenderId"]]; + FIROptions *firOptions = [[FIROptions alloc] initWithGoogleAppID:[options valueForKey:@"appId"] GCMSenderID:[options valueForKey:@"messagingSenderId"]]; firOptions.APIKey = [options valueForKey:@"apiKey"]; firOptions.projectID = [options valueForKey:@"projectId"]; - firOptions.clientID = [options valueForKey:@"iosClientId"]; + firOptions.clientID = [options valueForKey:@"clientId"]; firOptions.trackingID = [options valueForKey:@"trackingId"]; firOptions.databaseURL = [options valueForKey:@"databaseURL"]; firOptions.storageBucket = [options valueForKey:@"storageBucket"]; diff --git a/ios/RNFirebase/auth/RNFirebaseAuth.m b/ios/RNFirebase/auth/RNFirebaseAuth.m index c8b0e56b..bb3c94e4 100644 --- a/ios/RNFirebase/auth/RNFirebaseAuth.m +++ b/ios/RNFirebase/auth/RNFirebaseAuth.m @@ -972,7 +972,18 @@ RCT_EXPORT_METHOD(fetchProvidersForEmail:(NSString *) appName @return NSDictionary */ - (NSDictionary *)firebaseUserToDict:(FIRUser *)user { - NSMutableDictionary *userDict = [@{@"uid": user.uid, @"email": user.email ? user.email : [NSNull null], @"emailVerified": @(user.emailVerified), @"isAnonymous": @(user.anonymous), @"displayName": user.displayName ? user.displayName : [NSNull null], @"refreshToken": user.refreshToken, @"providerId": [user.providerID lowercaseString], @"providerData": [self convertProviderData:user.providerData]} mutableCopy]; + NSMutableDictionary *userDict = [ + @{ + @"uid": user.uid, + @"email": user.email ? user.email : [NSNull null], + @"emailVerified": @(user.emailVerified), + @"isAnonymous": @(user.anonymous), + @"displayName": user.displayName ? user.displayName : [NSNull null], + @"refreshToken": user.refreshToken, + @"providerId": [user.providerID lowercaseString], + @"providerData": [self convertProviderData:user.providerData] + } mutableCopy + ]; if ([user valueForKey:@"photoURL"] != nil) { [userDict setValue:[user.photoURL absoluteString] forKey:@"photoURL"];