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 23, 2021
2 parents f439303 + 6da019b commit c6c6990
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 62 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# Version 13.0.1-cli
* (iOS) Fix `onTokenRefresh` to return FCM token (not installation auth token).
* Resolves [#637](https://github.com/dpa99c/cordova-plugin-firebasex/issues/637)
* (Android): Increment pinned version of Crashlytics Gradle plugin to [v2.7.1](https://firebase.google.com/support/release-notes/android#crashlytics_gradle_plugin_v2-7-1) to resolve build issues with Gradle v7.
* This resolves build issues with `cordova-android@10.0.0` which defaults to Gradle v7.1.1
* Resolves [#643](https://github.com/dpa99c/cordova-plugin-firebasex/issues/643)
* (iOS) Bump pinned Firebase SDK components to [v8.4.0 - July 20, 2021](https://firebase.google.com/support/release-notes/ios#version_840_-_july_20_2021)
* (Android): Update pinned Firebase Android SDK versions from BoM v28.1.0 to ([v28.2.1 - July 09, 2021](https://firebase.google.com/support/release-notes/android#bom_v28-2-1))


# Version 13.0.0-cli
* (iOS) BREAKING CHANGE: Major version update to Firebase iOS SDK from v7 to v8 ([Version 8.1.1 - June 11, 2021](https://firebase.google.com/support/release-notes/ios#version_811_-_june_11_2021))
* Remove/replace references to previously-deprecated Firebase IID SDK component which is removed in SDK v2 with Firebase Installations SDK
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": "13.0.0-cli",
"version": "13.0.1-cli",
"description": "Cordova plugin for Google Firebase",
"types": "./types/index.d.ts",
"author": {
Expand Down
26 changes: 13 additions & 13 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@
<preference name="ANDROID_FIREBASE_ANALYTICS_VERSION" default="19.0.0" />
<preference name="ANDROID_FIREBASE_MESSAGING_VERSION" default="22.0.0" />
<preference name="ANDROID_FIREBASE_CONFIG_VERSION" default="21.0.0" />
<preference name="ANDROID_FIREBASE_PERF_VERSION" default="20.0.1" />
<preference name="ANDROID_FIREBASE_PERF_VERSION" default="20.0.2" />
<preference name="ANDROID_FIREBASE_AUTH_VERSION" default="21.0.1" />
<preference name="ANDROID_FIREBASE_FIRESTORE_VERSION" default="23.0.1" />
<preference name="ANDROID_FIREBASE_FIRESTORE_VERSION" default="23.0.2" />
<preference name="ANDROID_FIREBASE_FUNCTIONS_VERSION" default="20.0.0" />
<preference name="ANDROID_FIREBASE_IID_VERSION" default="21.1.0" />
<preference name="ANDROID_FIREBASE_INSTALLATIONS_VERSION" default="17.0.0" />
<preference name="ANDROID_FIREBASE_CRASHLYTICS_VERSION" default="18.0.1" />
<preference name="ANDROID_FIREBASE_CRASHLYTICS_NDK_VERSION" default="18.0.1" />
<preference name="ANDROID_FIREBASE_CRASHLYTICS_VERSION" default="18.1.0" />
<preference name="ANDROID_FIREBASE_CRASHLYTICS_NDK_VERSION" default="18.1.0" />
<preference name="ANDROID_GSON_VERSION" default="2.8.7" />
<preference name="ANDROID_FIREBASE_PERF_GRADLE_PLUGIN_VERSION" default="1.4.0" />

Expand Down Expand Up @@ -136,15 +136,15 @@
<source url="https://cdn.cocoapods.org/"/>
</config>
<pods use-frameworks="true">
<pod name="Firebase/Core" spec="8.1.1"/>
<pod name="Firebase/Auth" spec="8.1.1"/>
<pod name="Firebase/Messaging" spec="8.1.1"/>
<pod name="Firebase/Performance" spec="8.1.1"/>
<pod name="Firebase/RemoteConfig" spec="8.1.1"/>
<pod name="FirebaseFirestore" git="https://github.com/invertase/firestore-ios-sdk-frameworks.git" tag="8.1.1"/>
<pod name="Firebase/Crashlytics" spec="8.1.1"/>
<pod name="Firebase/Functions" spec="8.1.1"/>
<pod name="Firebase/Installations" spec="8.1.1"/>
<pod name="Firebase/Core" spec="8.4.0"/>
<pod name="Firebase/Auth" spec="8.4.0"/>
<pod name="Firebase/Messaging" spec="8.4.0"/>
<pod name="Firebase/Performance" spec="8.4.0"/>
<pod name="Firebase/RemoteConfig" spec="8.4.0"/>
<pod name="FirebaseFirestore" git="https://github.com/invertase/firestore-ios-sdk-frameworks.git" tag="8.4.0"/>
<pod name="Firebase/Crashlytics" spec="8.4.0"/>
<pod name="Firebase/Functions" spec="8.4.0"/>
<pod name="Firebase/Installations" spec="8.4.0"/>
<pod name="GoogleSignIn" spec="5.0.2"/>
</pods>
</podspec>
Expand Down
2 changes: 1 addition & 1 deletion src/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.google.gms:google-services:4.3.3'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.1.1'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.7.1'
}
}
repositories {
Expand Down
1 change: 0 additions & 1 deletion src/ios/FirebasePlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@
@property (nonatomic, copy) NSString *appleSignInCallbackId;

@property (nonatomic, retain) NSMutableArray *notificationStack;
@property (nonatomic, readwrite) NSMutableDictionary* traces;
@property(nonatomic, nullable) id<NSObject> installationIDObserver;

@end
90 changes: 48 additions & 42 deletions src/ios/FirebasePlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ @implementation FirebasePlugin
@synthesize googleSignInCallbackId;
@synthesize appleSignInCallbackId;
@synthesize notificationStack;
@synthesize traces;

static NSString*const LOG_TAG = @"FirebasePlugin[native]";
static NSInteger const kNotificationStackSize = 10;
Expand All @@ -42,6 +41,7 @@ @implementation FirebasePlugin
static NSDictionary* googlePlist;
static NSMutableDictionary* firestoreListeners;
static NSString* currentInstallationId;
static NSMutableDictionary* traces;


+ (FirebasePlugin*) firebasePlugin {
Expand Down Expand Up @@ -87,7 +87,7 @@ - (void)pluginInitialize {

authCredentials = [[NSMutableDictionary alloc] init];
firestoreListeners = [[NSMutableDictionary alloc] init];
self.traces = [NSMutableDictionary new];
traces = [[NSMutableDictionary alloc] init];
}@catch (NSException *exception) {
[self handlePluginExceptionWithoutContext:exception];
}
Expand Down Expand Up @@ -204,15 +204,25 @@ - (void)getId:(CDVInvokedUrlCommand *)command {
}

- (void)getToken:(CDVInvokedUrlCommand *)command {
[[FIRMessaging messaging] tokenWithCompletion:^(NSString *token, NSError *error) {
@try {
[self handleStringResultWithPotentialError:error command:command result:token];
}@catch (NSException *exception) {
[self handlePluginExceptionWithContext:exception :command];
}
[self _getToken:^(NSString *token, NSError *error) {
[self handleStringResultWithPotentialError:error command:command result:token];
}];
}

-(void)_getToken:(void (^)(NSString *token, NSError *error))completeBlock {
@try {
[[FIRMessaging messaging] tokenWithCompletion:^(NSString *token, NSError *error) {
@try {
completeBlock(token, error);
}@catch (NSException *exception) {
[self handlePluginExceptionWithoutContext:exception];
}
}];
}@catch (NSException *exception) {
[self handlePluginExceptionWithoutContext:exception];
}
}

- (void)getAPNSToken:(CDVInvokedUrlCommand *)command {
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:[self getAPNSToken]];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
Expand Down Expand Up @@ -430,22 +440,11 @@ - (void)onMessageReceived:(CDVInvokedUrlCommand *)command {

- (void)onTokenRefresh:(CDVInvokedUrlCommand *)command {
self.tokenRefreshCallbackId = command.callbackId;
@try {
[[FIRInstallations installations] authTokenForcingRefresh:true
completion:^(FIRInstallationsAuthTokenResult *result, NSError *error) {
@try {
if (error != nil) {
[self sendPluginErrorWithError:error command:command];
}else{
[self sendPluginStringResult:[result authToken] command:command callbackId:command.callbackId];
}
}@catch (NSException *exception) {
[self handlePluginExceptionWithContext:exception :command];
}
}];
}@catch (NSException *exception) {
[self handlePluginExceptionWithContext:exception :command];
}
[self _getToken:^(NSString *token, NSError *error) {
if(error == nil && token != nil){
[self sendToken:token];
}
}];
}

- (void)onApnsTokenReceived:(CDVInvokedUrlCommand *)command {
Expand Down Expand Up @@ -1469,13 +1468,16 @@ - (void)startTrace:(CDVInvokedUrlCommand *)command {
[self.commandDelegate runInBackground:^{
@try {
NSString* traceName = [command.arguments objectAtIndex:0];
FIRTrace* trace = [self.traces objectForKey:traceName];

@synchronized (traces) {
FIRTrace* trace = [traces objectForKey:traceName];

if (trace == nil) {
trace = [FIRPerformance startTraceWithName:traceName];
[self.traces setObject:trace forKey:traceName ];
if (trace == nil) {
trace = [FIRPerformance startTraceWithName:traceName];
[traces setObject:trace forKey:traceName ];
}
}

CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}@catch (NSException *exception) {
Expand All @@ -1490,13 +1492,15 @@ - (void)incrementCounter:(CDVInvokedUrlCommand *)command {
NSString* traceName = [command.arguments objectAtIndex:0];
NSString* counterNamed = [command.arguments objectAtIndex:1];
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
FIRTrace *trace = (FIRTrace*)[self.traces objectForKey:traceName];
@synchronized (traces) {
FIRTrace *trace = (FIRTrace*)[traces objectForKey:traceName];

if (trace != nil) {
[trace incrementMetric:counterNamed byInt:1];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
} else {
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Trace not found"];
if (trace != nil) {
[trace incrementMetric:counterNamed byInt:1];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
} else {
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Trace not found"];
}
}

[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
Expand All @@ -1511,14 +1515,16 @@ - (void)stopTrace:(CDVInvokedUrlCommand *)command {
@try {
NSString* traceName = [command.arguments objectAtIndex:0];
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
FIRTrace *trace = [self.traces objectForKey:traceName];
@synchronized (traces) {
FIRTrace *trace = [traces objectForKey:traceName];

if (trace != nil) {
[trace stop];
[self.traces removeObjectForKey:traceName];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
} else {
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Trace not found"];
if (trace != nil) {
[trace stop];
[traces removeObjectForKey:traceName];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
} else {
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Trace not found"];
}
}

[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
Expand Down
9 changes: 5 additions & 4 deletions www/firebase.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ exports._onInstallationIdChangeCallback = function(installationId){
**************/

// Notifications
exports.getId = function (success, error) {
exec(success, error, "FirebasePlugin", "getId", []);
};

exports.getToken = function (success, error) {
exec(success, error, "FirebasePlugin", "getToken", []);
};
Expand Down Expand Up @@ -443,6 +439,11 @@ exports.functionsHttpsCallable = function (name, args, success, error) {
exec(success, error, "FirebasePlugin", "functionsHttpsCallable", [name, args]);
};

// Installations
exports.getId = function (success, error) {
exec(success, error, "FirebasePlugin", "getId", []);
};

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

0 comments on commit c6c6990

Please sign in to comment.