Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit 99339be

Browse files
committed
Merge remote-tracking branch 'upstream/master' into feat/dep-updates
2 parents b21fa1e + 3da75a6 commit 99339be

38 files changed

+672
-991
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717

1818
<img src="docs/images/firebase-logo.png" width="116px" height="32px" alt="Firebase"/><br/>
1919

20-
> Plugin version **10.0.0** works with NativeScript 6.1 and up. Using an older version? Stick to plugin version < 10.
20+
> Plugin version **10.0.0** works with NativeScript 6.1+. Using an older version? Stick to plugin version < 10.
21+
22+
> For NativeScript 7 compatibiliy, install `@nativescript/firebase` version 11+.
2123
2224
## Features
2325
* [AdMob](docs/ADMOB.md)
@@ -58,6 +60,12 @@ From the command prompt go to your app's root folder and execute:
5860
tns plugin add nativescript-plugin-firebase
5961
```
6062

63+
or for NativeScript 7+:
64+
65+
```bash
66+
tns plugin add @nativescript/firebase
67+
```
68+
6169
This will launch an install script which will guide you through installing additional components.
6270
Check the doc links above to see what's what. You can always change your choices later.
6371

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
post_install do |installer|
2+
installer.pods_project.targets.each do |target|
3+
target.build_configurations.each do |config|
4+
config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
5+
end
6+
end
7+
end

demo-ng/app/App_Resources/iOS/build.xcconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
55
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
66
CODE_SIGN_ENTITLEMENTS = demong/demong.entitlements
77

8-
IPHONEOS_DEPLOYMENT_TARGET = 10.0
8+
IPHONEOS_DEPLOYMENT_TARGET = 12.0
99

1010
// Don't check this in because of CI
1111
// DEVELOPMENT_TEAM = 8Q5F6M3TNS

demo-ng/firebase.nativescript.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
"ml_kit_face_detection": true,
2424
"ml_kit_image_labeling": true,
2525
"ml_kit_object_detection": true,
26-
"ml_kit_automl": true,
27-
"ml_kit_custom_model": true,
28-
"ml_kit_natural_language_identification": true,
29-
"ml_kit_natural_language_translation": true,
30-
"ml_kit_natural_language_smartreply": true
26+
"ml_kit_automl": false,
27+
"ml_kit_custom_model": false,
28+
"ml_kit_natural_language_identification": false,
29+
"ml_kit_natural_language_translation": false,
30+
"ml_kit_natural_language_smartreply": false
3131
}

demo-ng/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
"nativescript": {
77
"id": "org.nativescript.firebasedemo.firestore",
88
"tns-android": {
9-
"version": "6.3.1"
9+
"version": "6.5.3"
1010
},
1111
"tns-ios": {
12-
"version": "6.3.0"
12+
"version": "6.5.3"
1313
}
1414
},
1515
"dependencies": {
@@ -25,11 +25,11 @@
2525
"nativescript-angular": "~8.0.3",
2626
"nativescript-camera": "~4.5.0",
2727
"nativescript-imagepicker": "~6.3.0",
28-
"nativescript-plugin-firebase": "file:../publish/package/nativescript-plugin-firebase-10.5.2.tgz",
28+
"nativescript-plugin-firebase": "file:../publish/package/nativescript-plugin-firebase-10.6.0.tgz",
2929
"nativescript-theme-core": "~1.0.6",
3030
"reflect-metadata": "~0.1.13",
3131
"rxjs": "~6.5.2",
32-
"tns-core-modules": "~6.3.2",
32+
"tns-core-modules": "~6.5.3",
3333
"zone.js": "~0.10.0"
3434
},
3535
"devDependencies": {

demo/app_resources/iOS/Podfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
post_install do |installer|
2+
installer.pods_project.targets.each do |target|
3+
target.build_configurations.each do |config|
4+
config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
5+
end
6+
end
7+
end

demo/app_resources/iOS/build.xcconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
55
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
66
CODE_SIGN_ENTITLEMENTS = demo/demo.entitlements
77

8+
IPHONEOS_DEPLOYMENT_TARGET = 10.0
9+
810
// DEVELOPMENT_TEAM = "Don't set this here, but store in the platforms folder when prompted (to support CI and cross-team development)"
911

1012
// DEVELOPMENT_TEAM = 8Q5F6M3TNS

demo/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"dependencies": {
33
"firebase-functions": "^2.0.5",
4-
"@nativescript/firebase": "file:../publish/package/nativescript-firebase-11.0.0-rc.6.tgz",
4+
"@nativescript/firebase": "file:../src",
55
"nativescript-theme-core": "^1.0.4",
6-
"nativescript-unit-test-runner": "0.7.0",
6+
"@nativescript/unit-test-runner": "~1.0.2",
77
"@nativescript/core": "7.0.0",
8-
"@nativescript/webpack": "3.0.0"
8+
"@nativescript/webpack": "~3.0.0"
99
},
1010
"devDependencies": {
11-
"@nativescript/ios": "7.0.0",
12-
"@nativescript/types": "7.0.0",
11+
"@nativescript/ios": "7.0.4",
12+
"@nativescript/types": "~7.0.0",
1313
"@types/jasmine": "~2.8.0",
1414
"babel-traverse": "6.12.0",
1515
"babel-types": "6.11.1",
@@ -23,7 +23,7 @@
2323
"lazy": "1.0.11",
2424
"nativescript-css-loader": "~0.26.0",
2525
"tslint": "~5.4.3",
26-
"typescript": "~3.9.7"
26+
"typescript": "~4.0.0"
2727
},
2828
"scripts": {
2929
"build.plugin": "cd ../src && npm run build",

publish/scripts/installer.js

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,6 @@ function promptQuestionsResult(result) {
253253
writePodFile(result);
254254
writeGoogleServiceCopyHook();
255255
writeBuildscriptHookForCrashlytics(isSelected(result.crashlytics));
256-
activateIOSCrashlyticsFramework(isSelected(result.crashlytics));
257256
activateIOSMLKitCameraFramework(isSelected(result.ml_kit));
258257
}
259258

@@ -319,14 +318,6 @@ function activateIOSMLKitCameraFramework(enable) {
319318
}
320319
}
321320

322-
function activateIOSCrashlyticsFramework(enable) {
323-
if (enable && fs.existsSync(path.join(directories.ios, 'TNSCrashlyticsLogger.framework-disabled'))) {
324-
fs.renameSync(path.join(directories.ios, 'TNSCrashlyticsLogger.framework-disabled'), path.join(directories.ios, 'TNSCrashlyticsLogger.framework'));
325-
} else if (!enable && fs.existsSync(path.join(directories.ios, 'TNSCrashlyticsLogger.framework'))) {
326-
fs.renameSync(path.join(directories.ios, 'TNSCrashlyticsLogger.framework'), path.join(directories.ios, 'TNSCrashlyticsLogger.framework-disabled'));
327-
}
328-
}
329-
330321
function askSaveConfigPrompt() {
331322
prompt.get({
332323
name: 'save_config',
@@ -356,10 +347,10 @@ function writePodFile(result) {
356347
// The MLVision pod requires a minimum of iOS 9, otherwise the build will fail
357348
(isPresent(result.ml_kit) ? `` : `#`) + `platform :ios, '9.0'
358349
359-
` + (!isSelected(result.external_push_client_only) ? `` : `#`) + `pod 'Firebase/Core', '~>6.16.0'
350+
` + (!isSelected(result.external_push_client_only) ? `` : `#`) + `pod 'Firebase/Core', '~>6.34.0'
360351
361352
# Analytics
362-
` + (isSelected(result.analytics) || (!isSelected(result.external_push_client_only) && !isPresent(result.analytics)) ? `` : `#`) + `pod 'Firebase/Analytics'
353+
` + (isSelected(result.analytics) || isSelected(result.crashlytics) || (!isSelected(result.external_push_client_only) && !isPresent(result.analytics)) ? `` : `#`) + `pod 'Firebase/Analytics'
363354
364355
# Authentication
365356
` + (isSelected(result.authentication) || (!isSelected(result.external_push_client_only) && !isPresent(result.external_push_client_only)) ? `` : `#`) + `pod 'Firebase/Auth'
@@ -377,8 +368,7 @@ function writePodFile(result) {
377368
` + (isSelected(result.performance_monitoring) ? `` : `#`) + `pod 'Firebase/Performance'
378369
379370
# Crashlytics
380-
` + (isSelected(result.crashlytics) ? `` : `#`) + `pod 'Fabric'
381-
` + (isSelected(result.crashlytics) ? `` : `#`) + `pod 'Crashlytics'
371+
` + (isSelected(result.crashlytics) ? `` : `#`) + `pod 'Firebase/Crashlytics'
382372
` + (!isSelected(result.crashlytics) ? `` : `
383373
# Crashlytics works best without bitcode
384374
post_install do |installer|
@@ -428,7 +418,7 @@ end`) + `
428418
` + (isSelected(result.facebook_auth) ? `` : `#`) + `pod 'FBSDKLoginKit'
429419
430420
# Google Authentication
431-
` + (isSelected(result.google_auth) ? `` : `#`) + `pod 'GoogleSignIn', '~> 5.0'`);
421+
` + (isSelected(result.google_auth) ? `` : `#`) + `pod 'GoogleSignIn', '~> 5.0.2'`);
432422
console.log('Successfully created iOS (Pod) file.');
433423
} catch (e) {
434424
console.log('Failed to create iOS (Pod) file.');
@@ -465,7 +455,7 @@ const pattern3 = /\\n\\s*\\/\\/Crashlytics 3 BEGIN[\\s\\S]*\\/\\/Crashlytics 3 E
465455
const string1 = \`
466456
//Crashlytics 1 BEGIN
467457
#else
468-
#import <Crashlytics/CLSLogging.h>
458+
@import FirebaseCrashlytics;
469459
#endif
470460
//Crashlytics 1 END
471461
\`;
@@ -475,7 +465,7 @@ const string2 = \`
475465
#if DEBUG
476466
#else
477467
static int redirect_cls(const char *prefix, const char *buffer, int size) {
478-
CLSLog(@"%s: %.*s", prefix, size, buffer);
468+
[[FIRCrashlytics crashlytics] logWithFormat:@"%s: %.*s", prefix, size, buffer];
479469
return size;
480470
}
481471
@@ -527,7 +517,7 @@ module.exports = function($logger, $projectData, hookArgs) {
527517
528518
// Xcode 10 requires 'inputPaths' set, see https://firebase.google.com/docs/crashlytics/get-started
529519
var options = {
530-
shellPath: '/bin/sh', shellScript: '\"\${PODS_ROOT}/Fabric/run\"',
520+
shellPath: '/bin/sh', shellScript: '\"\${PODS_ROOT}/FirebaseCrashlytics/run\"',
531521
inputPaths: ['"\$(SRCROOT)/$(BUILT_PRODUCTS_DIR)/$(INFOPLIST_PATH)\"']
532522
};
533523
@@ -660,7 +650,7 @@ dependencies {
660650
` + (isSelected(result.performance_monitoring) ? `` : `//`) + ` implementation "com.google.firebase:firebase-perf:19.0.5"
661651
662652
// Crashlytics
663-
` + (isSelected(result.crashlytics) ? `` : `//`) + ` implementation "com.crashlytics.sdk.android:crashlytics:2.10.1"
653+
` + (isSelected(result.crashlytics) ? `` : `//`) + ` implementation "com.google.firebase:firebase-crashlytics:17.2.2"
664654
665655
// Cloud Messaging (FCM)
666656
` + (isSelected(result.messaging) || isSelected(result.external_push_client_only) ? `` : `//`) + ` implementation "com.google.firebase:firebase-messaging:20.1.0"
@@ -705,7 +695,7 @@ dependencies {
705695
apply plugin: "com.google.gms.google-services"
706696
707697
// Crashlytics
708-
` + (isSelected(result.crashlytics) ? `` : `//`) + `apply plugin: "io.fabric"
698+
` + (isSelected(result.crashlytics) ? `` : `//`) + `apply plugin: "com.google.firebase.crashlytics"
709699
`);
710700
console.log('Successfully created Android (include.gradle) file.');
711701
} catch (e) {
@@ -961,27 +951,30 @@ module.exports = function($logger, $projectData) {
961951
if (fs.existsSync(projectBuildGradlePath)) {
962952
let buildGradleContent = fs.readFileSync(projectBuildGradlePath).toString();
963953
964-
if (buildGradleContent.indexOf("fabric.io") === -1) {
954+
if (buildGradleContent.indexOf(" google()\\n") === -1) {
965955
let repositoriesNode = buildGradleContent.indexOf("repositories", 0);
966956
if (repositoriesNode > -1) {
967957
repositoriesNode = buildGradleContent.indexOf("}", repositoriesNode);
968-
buildGradleContent = buildGradleContent.substr(0, repositoriesNode - 1) + '\\t\\tmaven { url "https://maven.fabric.io/public" }\\n\\t\\tmaven { url "https://dl.bintray.com/android/android-tools" }\\n' + buildGradleContent.substr(repositoriesNode - 1);
969-
}
970-
971-
let dependenciesNode = buildGradleContent.indexOf("dependencies", 0);
972-
if (dependenciesNode > -1) {
973-
dependenciesNode = buildGradleContent.indexOf("}", dependenciesNode);
974-
// see https://docs.fabric.io/android/changelog.html
975-
buildGradleContent = buildGradleContent.substr(0, dependenciesNode - 1) + ' classpath "io.fabric.tools:gradle:1.28.0"\\n' + buildGradleContent.substr(dependenciesNode - 1);
958+
buildGradleContent = buildGradleContent.substr(0, repositoriesNode - 1) + '\\t\\tgoogle()\\n' + buildGradleContent.substr(repositoriesNode - 1);
976959
}
977960
978-
} else if (buildGradleContent.indexOf("https://dl.bintray.com/android/android-tools") === -1) {
961+
}
962+
963+
if (buildGradleContent.indexOf("https://dl.bintray.com/android/android-tools") === -1) {
979964
let repositoriesNode = buildGradleContent.indexOf("repositories", 0);
980965
if (repositoriesNode > -1) {
981966
repositoriesNode = buildGradleContent.indexOf("}", repositoriesNode);
982967
buildGradleContent = buildGradleContent.substr(0, repositoriesNode - 1) + '\\t\\tmaven { url "https://dl.bintray.com/android/android-tools" }\\n' + buildGradleContent.substr(repositoriesNode - 1);
983968
}
984969
}
970+
971+
if (buildGradleContent.indexOf("com.google.firebase:firebase-crashlytics-gradle") === -1) {
972+
let dependenciesNode = buildGradleContent.indexOf("dependencies", 0);
973+
if (dependenciesNode > -1) {
974+
dependenciesNode = buildGradleContent.indexOf("}", dependenciesNode);
975+
buildGradleContent = buildGradleContent.substr(0, dependenciesNode - 1) + ' classpath "com.google.firebase:firebase-crashlytics-gradle:2.3.0"\\n' + buildGradleContent.substr(dependenciesNode - 1);
976+
}
977+
}
985978
986979
let gradlePattern = /classpath ('|")com\\.android\\.tools\\.build:gradle:\\d+\\.\\d+\\.\\d+('|")/;
987980
let googleServicesPattern = /classpath ('|")com\\.google\\.gms:google-services:\\d+\\.\\d+\\.\\d+('|")/;

src/crashlytics/crashlytics.android.ts

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,72 @@
11
import { ENABLE_CRASHLYTICS_HINT } from "./crashlytics-common";
2-
import { Application } from '@nativescript/core';
32

4-
declare const com: any;
3+
declare const com, java: any;
54

65
export function sendCrashLog(exception: any /* java.lang.Exception */): void {
76
if (isCrashlyticsAvailable()) {
8-
com.crashlytics.android.Crashlytics.logException(exception);
7+
com.google.firebase.crashlytics.FirebaseCrashlytics.getInstance().recordException(exception);
98
}
109
}
1110

1211
export function log(msg: string, tag?: string, priority?: number): void {
1312
if (isCrashlyticsAvailable()) {
1413
if (tag && priority) {
15-
com.crashlytics.android.Crashlytics.log(priority, tag, msg);
14+
const fullMessage = priority + '/' + tag + ': ' + msg;
15+
com.google.firebase.crashlytics.FirebaseCrashlytics.getInstance().log(fullMessage);
1616
} else {
17-
com.crashlytics.android.Crashlytics.log(msg);
17+
com.google.firebase.crashlytics.FirebaseCrashlytics.getInstance().log(msg);
1818
}
1919
}
2020
}
2121

2222
export function setString(key: string, value: string): void {
2323
if (isCrashlyticsAvailable()) {
24-
com.crashlytics.android.Crashlytics.setString(key, value);
24+
com.google.firebase.crashlytics.FirebaseCrashlytics.getInstance().setCustomKey(key, value);
2525
}
2626
}
2727

2828
export function setBool(key: string, value: boolean): void {
2929
if (isCrashlyticsAvailable()) {
30-
com.crashlytics.android.Crashlytics.setBool(key, value);
30+
com.google.firebase.crashlytics.FirebaseCrashlytics.getInstance().setCustomKey(key, value);
3131
}
3232
}
3333

3434
export function setFloat(key: string, value: number): void {
3535
if (isCrashlyticsAvailable()) {
36-
com.crashlytics.android.Crashlytics.setFloat(key, value);
36+
com.google.firebase.crashlytics.FirebaseCrashlytics.getInstance().setCustomKey(key, value);
3737
}
3838
}
3939

4040
export function setInt(key: string, value: number): void {
4141
if (isCrashlyticsAvailable()) {
42-
com.crashlytics.android.Crashlytics.setInt(key, value);
42+
com.google.firebase.crashlytics.FirebaseCrashlytics.getInstance().setCustomKey(key, value);
4343
}
4444
}
4545

4646
export function setDouble(key: string, value: number): void {
4747
if (isCrashlyticsAvailable()) {
48-
com.crashlytics.android.Crashlytics.setDouble(key, value);
48+
com.google.firebase.crashlytics.FirebaseCrashlytics.getInstance().setCustomKey(key, value);
4949
}
5050
}
5151

5252
export function setUserId(id: string): void {
5353
if (isCrashlyticsAvailable()) {
54-
com.crashlytics.android.Crashlytics.setUserIdentifier(id);
54+
com.google.firebase.crashlytics.FirebaseCrashlytics.getInstance().setUserId(id);
5555
}
5656
}
5757

5858
export function crash(): void {
5959
if (isCrashlyticsAvailable()) {
60-
com.crashlytics.android.Crashlytics.getInstance().crash();
60+
throw new java.lang.RuntimeException('Test Crash');
6161
}
6262
}
6363

6464
export function setCrashlyticsCollectionEnabled(enabled: boolean): void {
65-
if (isCrashlyticsAvailable()) {
66-
io.fabric.sdk.android.Fabric.with(
67-
Application.getNativeApplication(),
68-
[new com.crashlytics.android.Crashlytics()]);
69-
}
65+
com.google.firebase.crashlytics.FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(new java.lang.Boolean(enabled));
7066
}
7167

7268
function isCrashlyticsAvailable(): boolean {
73-
if (typeof (com.crashlytics) === "undefined" || typeof (com.crashlytics.android.Crashlytics) === "undefined") {
69+
if (typeof (com.google.firebase.crashlytics.FirebaseCrashlytics) === "undefined" || typeof (com.google.firebase.crashlytics.FirebaseCrashlytics.getInstance()) === "undefined") {
7470
console.log(ENABLE_CRASHLYTICS_HINT);
7571
return false;
7672
}

0 commit comments

Comments
 (0)