diff --git a/CHANGELOG.md b/CHANGELOG.md index 1740b08fe..203853595 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# Version 10.1.1-cli +* (iOS) Fix regression bug in `getToken()` introduced by [35a2a68e8db3808723c9f2fcb6aa176021f6c77a](https://github.com/dpa99c/cordova-plugin-firebasex/commit/35a2a68e8db3808723c9f2fcb6aa176021f6c77a). + * Resolves [#456](https://github.com/dpa99c/cordova-plugin-firebasex/issues/456). +* (iOS) Update to use Firebase SDK v6.28.0 + * Resolves [#453](https://github.com/dpa99c/cordova-plugin-firebasex/issues/453). + # Version 10.1.0-cli * (iOS) Use precompiled pod for Firestore to reduce build times. * *BREAKING CHANGE:* Requires `cocoapods>=1.9` (previously `cocoapods>=1.8`). diff --git a/README.md b/README.md index a664f745d..9013f0524 100644 --- a/README.md +++ b/README.md @@ -421,6 +421,8 @@ Similarly, if your build is failing because multiple plugins are installing diff you can try installing [cordova-android-firebase-gradle-release](https://github.com/dpa99c/cordova-android-firebase-gradle-release) to align these. ## iOS-specific +Please ensure you have the latest Xcode release version installed to build your app - direct download links can be [found here](https://stackoverflow.com/a/10335943/777265). + ### Specifying iOS library versions This plugin depends on various components such as the Firebase SDK which are pulled in at build-time by Cocoapods on iOS. This plugin pins specific versions of these in [its `plugin.xml`](https://github.com/dpa99c/cordova-plugin-firebase/blob/master/plugin.xml) where you can find the currently pinned iOS versions in the ``'s, for example: @@ -2908,6 +2910,8 @@ FirebasePlugin.fetchFirestoreCollection(collection, filters, function(documents) }); ``` + + # Credits - [@robertarnesson](https://github.com/robertarnesson) for the original [cordova-plugin-firebase](https://github.com/arnesson/cordova-plugin-firebase) from which this plugin is forked. - [@sagrawal31](https://github.com/sagrawal31) and [Wiz Panda](https://github.com/wizpanda) for contributions via [cordova-plugin-firebase-lib](https://github.com/wizpanda/cordova-plugin-firebase-lib). diff --git a/package.json b/package.json index f619d62b0..40f56f46a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-plugin-firebasex", - "version": "10.1.0-cli", + "version": "10.1.1-cli", "description": "Cordova plugin for Google Firebase", "types": "./types/index.d.ts", "author": { diff --git a/plugin.xml b/plugin.xml index ef96f3125..16c191270 100644 --- a/plugin.xml +++ b/plugin.xml @@ -1,5 +1,5 @@ - Google Firebase Plugin @@ -128,13 +128,13 @@ - - - - - - - + + + + + + + diff --git a/src/ios/FirebasePlugin.m b/src/ios/FirebasePlugin.m index 94166f8eb..2547d02cc 100644 --- a/src/ios/FirebasePlugin.m +++ b/src/ios/FirebasePlugin.m @@ -68,16 +68,16 @@ - (void)pluginInitialize { if([self getGooglePlistFlagWithDefaultValue:FIREBASE_ANALYTICS_COLLECTION_ENABLED defaultValue:YES]){ [self setPreferenceFlag:FIREBASE_ANALYTICS_COLLECTION_ENABLED flag:YES]; } - + if([self getGooglePlistFlagWithDefaultValue:FIREBASE_PERFORMANCE_COLLECTION_ENABLED defaultValue:YES]){ [self setPreferenceFlag:FIREBASE_PERFORMANCE_COLLECTION_ENABLED flag:YES]; } - + // Check for permission and register for remote notifications if granted [self _hasPermission:^(BOOL result) {}]; - + [GIDSignIn sharedInstance].presentingViewController = self.viewController; - + authCredentials = [[NSMutableDictionary alloc] init]; }@catch (NSException *exception) { [self handlePluginExceptionWithoutContext:exception]; @@ -152,11 +152,11 @@ - (void)getToken:(CDVInvokedUrlCommand *)command { @try { [[FIRInstanceID instanceID] instanceIDWithHandler:^(FIRInstanceIDResult * _Nullable result, NSError * _Nullable error) { - if (result.token != nil && error == nil) { - [self sendToken:result.token]; - }else{ - [self handleStringResultWithPotentialError:error command:command result:result.token]; + NSString* token = nil; + if (error == nil && result != nil && result.token != nil) { + token = result.token; } + [self handleStringResultWithPotentialError:error command:command result:token]; }]; }@catch (NSException *exception) { [self handlePluginExceptionWithContext:exception :command]; @@ -188,7 +188,7 @@ - (NSString *)hexadecimalStringFromData:(NSData *)data if (dataLength == 0) { return nil; } - + const unsigned char *dataBuffer = data.bytes; NSMutableString *hexString = [NSMutableString stringWithCapacity:(dataLength * 2)]; for (int i = 0; i < dataLength; ++i) { @@ -268,7 +268,7 @@ - (void)grantPermission:(CDVInvokedUrlCommand *)command { - (void)registerForRemoteNotifications { NSLog(@"registerForRemoteNotifications"); if(registeredForRemoteNotifications) return; - + [self runOnMainThread:^{ @try { [[UIApplication sharedApplication] registerForRemoteNotifications]; @@ -300,7 +300,7 @@ - (void)getBadgeNumber:(CDVInvokedUrlCommand *)command { [self runOnMainThread:^{ @try { long badge = [[UIApplication sharedApplication] applicationIconBadgeNumber]; - + CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDouble:badge]; [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; }@catch (NSException *exception) { @@ -454,7 +454,7 @@ - (void)clearAllNotifications:(CDVInvokedUrlCommand *)command { @try { [[UIApplication sharedApplication] setApplicationIconBadgeNumber:1]; [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0]; - + CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; }@catch (NSException *exception) { @@ -571,7 +571,7 @@ - (void)authenticateUserWithGoogle:(CDVInvokedUrlCommand*)command{ @try { self.googleSignInCallbackId = command.callbackId; [[GIDSignIn sharedInstance] signIn]; - + CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_NO_RESULT]; [pluginResult setKeepCallbackAsBool:YES]; [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; @@ -586,13 +586,13 @@ - (void)authenticateUserWithApple:(CDVInvokedUrlCommand*)command{ if (@available(iOS 13.0, *)) { self.appleSignInCallbackId = command.callbackId; [self startSignInWithAppleFlow]; - + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_NO_RESULT]; [pluginResult setKeepCallbackAsBool:YES]; } else { pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"OS version is too low - Apple Sign In requires iOS 13.0+"]; } - + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; }@catch (NSException *exception) { [self handlePluginExceptionWithContext:exception :command]; @@ -603,7 +603,7 @@ - (void)signInWithCredential:(CDVInvokedUrlCommand*)command { @try { FIRAuthCredential* credential = [self obtainAuthCredential:[command.arguments objectAtIndex:0] command:command]; if(credential == nil) return; - + [[FIRAuth auth] signInWithCredential:credential completion:^(FIRAuthDataResult * _Nullable authResult, NSError * _Nullable error) { @@ -621,10 +621,10 @@ - (void)reauthenticateWithCredential:(CDVInvokedUrlCommand*)command{ [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"No user is currently signed"] callbackId:command.callbackId]; return; } - + FIRAuthCredential* credential = [self obtainAuthCredential:[command.arguments objectAtIndex:0] command:command]; if(credential == nil) return; - + [user reauthenticateWithCredential:credential completion:^(FIRAuthDataResult * _Nullable authResult, NSError * _Nullable error) { [self handleAuthResult:authResult error:error command:command]; }]; @@ -637,13 +637,13 @@ - (void)linkUserWithCredential:(CDVInvokedUrlCommand*)command { @try { FIRAuthCredential* credential = [self obtainAuthCredential:[command.arguments objectAtIndex:0] command:command]; if(credential == nil) return; - + [[FIRAuth auth].currentUser linkWithCredential:credential completion:^(FIRAuthDataResult * _Nullable authResult, NSError * _Nullable error) { [self handleAuthResult:authResult error:error command:command]; }]; - + }@catch (NSException *exception) { [self handlePluginExceptionWithContext:exception :command]; } @@ -653,7 +653,7 @@ - (void)isUserSignedIn:(CDVInvokedUrlCommand*)command { @try { bool isSignedIn = [FIRAuth auth].currentUser ? true : false; [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:isSignedIn] callbackId:command.callbackId]; - + }@catch (NSException *exception) { [self handlePluginExceptionWithContext:exception :command]; } @@ -666,12 +666,12 @@ - (void)signOutUser:(CDVInvokedUrlCommand*)command { [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"No user is currently signed"] callbackId:command.callbackId]; return; } - + // Sign out of Google if([[GIDSignIn sharedInstance] currentUser] != nil){ [[GIDSignIn sharedInstance] signOut]; } - + // Sign out of Firebase NSError *signOutError; BOOL status = [[FIRAuth auth] signOut:&signOutError]; @@ -686,7 +686,7 @@ - (void)signOutUser:(CDVInvokedUrlCommand*)command { } - (void)getCurrentUser:(CDVInvokedUrlCommand *)command { - + @try { FIRUser* user = [FIRAuth auth].currentUser; if(!user){ @@ -694,14 +694,14 @@ - (void)getCurrentUser:(CDVInvokedUrlCommand *)command { return; } [self extractAndReturnUserInfo:command]; - + }@catch (NSException *exception) { [self handlePluginExceptionWithContext:exception :command]; } } - (void)reloadCurrentUser:(CDVInvokedUrlCommand *)command { - + @try { FIRUser* user = [FIRAuth auth].currentUser; if(!user){ @@ -746,9 +746,9 @@ - (void)updateUserProfile:(CDVInvokedUrlCommand*)command { [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"No user is currently signed"] callbackId:command.callbackId]; return; } - + NSDictionary* profile = [command.arguments objectAtIndex:0]; - + FIRUserProfileChangeRequest* changeRequest = [user profileChangeRequest]; if([profile objectForKey:@"name"] != nil){ changeRequest.displayName = [profile objectForKey:@"name"]; @@ -1614,17 +1614,17 @@ - (void)runOnMainThread:(void (^)(void))completeBlock { - (FIRAuthCredential*)obtainAuthCredential:(NSDictionary*)credential command:(CDVInvokedUrlCommand *)command { FIRAuthCredential* authCredential = nil; - + if(credential == nil){ NSString* errMsg = @"credential object must be passed as first and only argument"; [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:errMsg] callbackId:command.callbackId]; return authCredential; } - + NSString* key = [credential objectForKey:@"id"]; NSString* verificationId = [credential objectForKey:@"verificationId"]; NSString* code = [credential objectForKey:@"code"]; - + if(key != nil){ authCredential = [authCredentials objectForKey:key]; if(authCredential == nil){