Skip to content

Commit

Permalink
Merge branch 'master' into cli_build
Browse files Browse the repository at this point in the history
  • Loading branch information
dpa99c committed Jul 15, 2020
2 parents aa760b5 + d49c6d7 commit 3cf3ae1
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 40 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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`).
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<pod>`'s, for example:
Expand Down Expand Up @@ -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).
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
16 changes: 8 additions & 8 deletions plugin.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<plugin id="cordova-plugin-firebasex" version="10.1.0-cli"
<plugin id="cordova-plugin-firebasex" version="10.1.1-cli"
xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android">
<name>Google Firebase Plugin</name>
Expand Down Expand Up @@ -128,13 +128,13 @@
<source url="https://cdn.cocoapods.org/"/>
</config>
<pods use-frameworks="true">
<pod name="Firebase/Core" spec="6.27.0"/>
<pod name="Firebase/Auth" spec="6.27.0"/>
<pod name="Firebase/Messaging" spec="6.27.0"/>
<pod name="Firebase/Performance" spec="6.27.0"/>
<pod name="Firebase/RemoteConfig" spec="6.27.0"/>
<pod name="FirebaseFirestore" git="https://github.com/invertase/firestore-ios-sdk-frameworks.git" tag="6.27.0"/>
<pod name="Firebase/Crashlytics" spec="6.27.0"/>
<pod name="Firebase/Core" spec="6.28.0"/>
<pod name="Firebase/Auth" spec="6.28.0"/>
<pod name="Firebase/Messaging" spec="6.28.0"/>
<pod name="Firebase/Performance" spec="6.28.0"/>
<pod name="Firebase/RemoteConfig" spec="6.28.0"/>
<pod name="FirebaseFirestore" git="https://github.com/invertase/firestore-ios-sdk-frameworks.git" tag="6.28.0"/>
<pod name="Firebase/Crashlytics" spec="6.28.0"/>
<pod name="GoogleSignIn" spec="5.0.2"/>
</pods>
</podspec>
Expand Down
62 changes: 31 additions & 31 deletions src/ios/FirebasePlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -268,7 +268,7 @@ - (void)grantPermission:(CDVInvokedUrlCommand *)command {
- (void)registerForRemoteNotifications {
NSLog(@"registerForRemoteNotifications");
if(registeredForRemoteNotifications) return;

[self runOnMainThread:^{
@try {
[[UIApplication sharedApplication] registerForRemoteNotifications];
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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];
Expand All @@ -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];
Expand All @@ -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) {
Expand All @@ -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];
}];
Expand All @@ -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];
}
Expand All @@ -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];
}
Expand All @@ -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];
Expand All @@ -686,22 +686,22 @@ - (void)signOutUser:(CDVInvokedUrlCommand*)command {
}

- (void)getCurrentUser:(CDVInvokedUrlCommand *)command {

@try {
FIRUser* user = [FIRAuth auth].currentUser;
if(!user){
[self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"No user is currently signed"] callbackId:command.callbackId];
return;
}
[self extractAndReturnUserInfo:command];

}@catch (NSException *exception) {
[self handlePluginExceptionWithContext:exception :command];
}
}

- (void)reloadCurrentUser:(CDVInvokedUrlCommand *)command {

@try {
FIRUser* user = [FIRAuth auth].currentUser;
if(!user){
Expand Down Expand Up @@ -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"];
Expand Down Expand Up @@ -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){
Expand Down

0 comments on commit 3cf3ae1

Please sign in to comment.