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

Commit d0bc9b8

Browse files
Not able to add screen logs in Firebase Analytics on android device after upgrading to version from 9.1.1 to 10.0.0 #1415
1 parent d12db3d commit d0bc9b8

File tree

8 files changed

+63
-100
lines changed

8 files changed

+63
-100
lines changed

demo-ng/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"nativescript-angular": "~8.0.3",
2626
"nativescript-camera": "~4.5.0",
2727
"nativescript-imagepicker": "~6.2.0",
28-
"nativescript-plugin-firebase": "file:../publish/package/nativescript-plugin-firebase-10.0.2.tgz",
28+
"nativescript-plugin-firebase": "file:../publish/package/nativescript-plugin-firebase-10.1.0.tgz",
2929
"nativescript-theme-core": "~1.0.6",
3030
"reflect-metadata": "~0.1.13",
3131
"rxjs": "~6.5.2",

demo-push/app/push-view-model.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import * as firebase from "nativescript-plugin-firebase";
2+
import { Message, messaging } from "nativescript-plugin-firebase/messaging";
3+
import * as applicationSettings from "tns-core-modules/application-settings";
14
import { Observable } from "tns-core-modules/data/observable";
2-
import { messaging, Message } from "nativescript-plugin-firebase/messaging";
3-
import { alert, confirm } from "tns-core-modules/ui/dialogs";
45
import * as platform from "tns-core-modules/platform";
5-
import * as applicationSettings from "tns-core-modules/application-settings";
6+
import { alert, confirm } from "tns-core-modules/ui/dialogs";
67

78
const getCircularReplacer = () => {
89
const seen = new WeakSet;
@@ -26,6 +27,7 @@ export class PushViewModel extends Observable {
2627
if (applicationSettings.getBoolean(PushViewModel.APP_REGISTERED_FOR_NOTIFICATIONS, false)) {
2728
this.doRegisterPushHandlers();
2829
}
30+
this.setScreenName("push-demo-view");
2931
}
3032

3133
public doRequestConsent(): void {
@@ -241,4 +243,13 @@ export class PushViewModel extends Observable {
241243
okButtonText: "Okay, very interesting"
242244
});
243245
}
246+
247+
private setScreenName(screenName): void {
248+
firebase.analytics.setScreenName(
249+
{
250+
screenName
251+
})
252+
.then(() => console.log("Analytics screen name set to: " + screenName))
253+
.catch(err => console.log("Analytics error: " + err));
254+
}
244255
}

demo-push/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
}
1010
},
1111
"dependencies": {
12-
"nativescript-plugin-firebase": "file:../publish/package/nativescript-plugin-firebase-10.0.2.tgz",
12+
"nativescript-plugin-firebase": "file:../publish/package/nativescript-plugin-firebase-10.1.0.tgz",
1313
"nativescript-theme-core": "~1.0.6",
1414
"nativescript-unit-test-runner": "0.7.0",
1515
"tns-core-modules": "~6.1.1"

demo-vue/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
}
1515
},
1616
"dependencies": {
17-
"nativescript-plugin-firebase": "file:../publish/package/nativescript-plugin-firebase-10.0.2.tgz",
17+
"nativescript-plugin-firebase": "file:../publish/package/nativescript-plugin-firebase-10.1.0.tgz",
1818
"nativescript-theme-core": "~1.0.6",
1919
"nativescript-vue": "~2.4.0",
2020
"tns-core-modules": "~6.1.1"

demo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
},
1111
"dependencies": {
1212
"firebase-functions": "^2.0.5",
13-
"nativescript-plugin-firebase": "file:../publish/package/nativescript-plugin-firebase-10.0.2.tgz",
13+
"nativescript-plugin-firebase": "file:../publish/package/nativescript-plugin-firebase-10.1.0.tgz",
1414
"nativescript-theme-core": "^1.0.4",
1515
"nativescript-unit-test-runner": "0.7.0",
1616
"tns-core-modules": "~6.1.1"

publish/scripts/installer.js

Lines changed: 22 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ var path = require('path');
33
var prompt = require('prompt-lite');
44

55
// Default settings for a few prompts
6-
var usingiOS = false, usingAndroid = false, externalPushClientOnly = false;
6+
var usingiOS = false, usingAndroid = false, externalPushClient = false;
77

88
// The directories where the Podfile and include.gradle are stored
99
var directories = {
@@ -22,6 +22,8 @@ function mergeConfig(result) {
2222
for (var key in result) {
2323
config[key] = isSelected(result[key]);
2424
}
25+
// note that the semantics of "external_push_client_only" changed to "external push client" with plugin version 10.1.0
26+
externalPushClient = isSelected(config["external_push_client_only"]);
2527
}
2628

2729
function saveConfig() {
@@ -48,32 +50,13 @@ if (process.argv.indexOf("config") === -1 && fs.existsSync(pluginConfigPath)) {
4850
console.log("Config file exists (" + pluginConfigFile + ")");
4951
askiOSPromptResult(config);
5052
askAndroidPromptResult(config);
51-
askExternalPushMessagingOnlyPromptResult(config);
5253
promptQuestionsResult(config);
5354
} else if (!isInteractive()) {
5455
console.log("No existing " + pluginConfigFile + " config file found and terminal is not interactive! Default configuration will be used.");
5556
} else {
5657
console.log("No existing " + pluginConfigFile + " config file found, so let's configure the Firebase plugin!");
5758
prompt.start();
58-
askExternalPushMessagingOnlyPrompt();
59-
}
60-
61-
/**
62-
* Prompt the user if they are integrating Firebase with iOS
63-
*/
64-
function askExternalPushMessagingOnlyPrompt() {
65-
prompt.get({
66-
name: 'external_push_client_only',
67-
description: 'Are you using this plugin ONLY as a Push Notification client for an external (non-Firebase) Push service? (y/n)',
68-
default: 'n'
69-
}, function (err, result) {
70-
if (err) {
71-
return console.log(err);
72-
}
73-
mergeConfig(result);
74-
askExternalPushMessagingOnlyPromptResult(result);
75-
askiOSPrompt();
76-
});
59+
askiOSPrompt();
7760
}
7861

7962
/**
@@ -94,12 +77,6 @@ function askiOSPrompt() {
9477
});
9578
}
9679

97-
function askExternalPushMessagingOnlyPromptResult(result) {
98-
if (isSelected(result.external_push_client_only)) {
99-
externalPushClientOnly = true;
100-
}
101-
}
102-
10380
function askiOSPromptResult(result) {
10481
if (isSelected(result.using_ios)) {
10582
usingiOS = true;
@@ -120,11 +97,8 @@ function askAndroidPrompt() {
12097
}
12198
mergeConfig(result);
12299
askAndroidPromptResult(result);
123-
if ((usingiOS || usingAndroid) && !externalPushClientOnly) {
100+
if (usingiOS || usingAndroid) {
124101
promptQuestions();
125-
} else if (externalPushClientOnly) {
126-
promptQuestionsResult(result);
127-
askSaveConfigPrompt();
128102
} else {
129103
askSaveConfigPrompt();
130104
}
@@ -165,6 +139,10 @@ function promptQuestions() {
165139
name: 'performance_monitoring',
166140
description: 'Are you using Performance Monitoring? (y/n)',
167141
default: 'n'
142+
}, {
143+
name: 'external_push_client_only',
144+
description: 'Are you using this plugin as a Push Notification client for an external (NOT Firebase Cloud Messaging) Push service? (y/n)',
145+
default: 'n'
168146
}, {
169147
name: 'messaging',
170148
description: 'Are you using Firebase Cloud Messaging? (y/n)',
@@ -267,9 +245,7 @@ function promptQuestions() {
267245

268246
function promptQuestionsResult(result) {
269247
if (usingiOS) {
270-
if (!externalPushClientOnly) {
271-
writePodFile(result);
272-
}
248+
writePodFile(result);
273249
writeGoogleServiceCopyHook();
274250
writeBuildscriptHookForCrashlytics(isSelected(result.crashlytics));
275251
writeBuildscriptHookForFirestore(isSelected(result.firestore));
@@ -280,7 +256,7 @@ function promptQuestionsResult(result) {
280256
writeGoogleServiceCopyHook();
281257
writeGoogleServiceGradleHook(result);
282258
echoAndroidManifestChanges(result);
283-
activateAndroidPushNotificationsLib(isSelected(result.messaging) || externalPushClientOnly);
259+
activateAndroidPushNotificationsLib(isSelected(result.messaging) || isSelected(result.external_push_client_only));
284260
activateAndroidMLKitCustomModelLib(isSelected(result.ml_kit) && isSelected(result.ml_kit_custom_model));
285261
}
286262

@@ -359,13 +335,13 @@ function writePodFile(result) {
359335
(isPresent(result.ml_kit) ? `` : `#`) + `platform :ios, '9.0'
360336
361337
# Analytics
362-
` + (!externalPushClientOnly && (!isPresent(result.analytics) || isSelected(result.analytics)) ? `` : `#`) + `pod 'Firebase/Analytics'
338+
` + (isSelected(result.analytics) || (!isSelected(result.external_push_client_only) && !isPresent(result.analytics)) ? `` : `#`) + `pod 'Firebase/Analytics'
363339
364340
# Authentication
365-
` + (!isPresent(result.authentication) || isSelected(result.authentication) ? `` : `#`) + `pod 'Firebase/Auth'
341+
` + (isSelected(result.authentication) || (!isSelected(result.external_push_client_only) && !isPresent(result.external_push_client_only)) ? `` : `#`) + `pod 'Firebase/Auth'
366342
367343
# Realtime DB
368-
` + (!isPresent(result.realtimedb) || isSelected(result.realtimedb) ? `` : `#`) + `pod 'Firebase/Database'
344+
` + (isSelected(result.realtimedb) || (!isSelected(result.external_push_client_only) && !isPresent(result.realtimedb)) ? `` : `#`) + `pod 'Firebase/Database'
369345
370346
# Cloud Firestore
371347
` + (isSelected(result.firestore) ? `` : `#`) + `pod 'Firebase/Firestore'
@@ -391,7 +367,7 @@ post_install do |installer|
391367
end`) + `
392368
393369
# Firebase Cloud Messaging (FCM)
394-
` + (isSelected(result.messaging) && !isSelected(result.external_messaging) ? `` : `#`) + `pod 'Firebase/Messaging'
370+
` + (isSelected(result.messaging) ? `` : `#`) + `pod 'Firebase/Messaging'
395371
396372
# Firebase In-App Messaging
397373
` + (isSelected(result.in_app_messaging) ? `` : `#`) + `pod 'Firebase/InAppMessagingDisplay'
@@ -730,16 +706,16 @@ dependencies {
730706
731707
// make sure you have these versions by updating your local Android SDK's (Android Support repo and Google repo)
732708
733-
` + (!externalPushClientOnly && (!isPresent(result.analytics) || isSelected(result.analytics)) ? `` : `//`) + ` implementation "com.google.firebase:firebase-analytics:17.2.0"
709+
` + (isSelected(result.analytics) || (!isSelected(result.external_push_client_only) && !isPresent(result.analytics)) ? `` : `//`) + ` implementation "com.google.firebase:firebase-analytics:17.2.0"
734710
735711
// for reading google-services.json and configuration
736712
implementation "com.google.android.gms:play-services-base:$googlePlayServicesVersion"
737713
738714
// Authentication
739-
` + (!externalPushClientOnly && (!isPresent(result.authentication) || isSelected(result.authentication)) ? `` : `//`) + ` implementation "com.google.firebase:firebase-auth:19.0.0"
715+
` + (isSelected(result.authentication) || (!isSelected(result.external_push_client_only) && !isPresent(result.authentication)) ? `` : `//`) + ` implementation "com.google.firebase:firebase-auth:19.0.0"
740716
741717
// Realtime DB
742-
` + (!externalPushClientOnly && (!isPresent(result.realtimedb) || isSelected(result.realtimedb)) ? `` : `//`) + ` implementation "com.google.firebase:firebase-database:19.1.0"
718+
` + (isSelected(result.realtimedb) || (!isSelected(result.external_push_client_only) && !isPresent(result.realtimedb)) ? `` : `//`) + ` implementation "com.google.firebase:firebase-database:19.1.0"
743719
744720
// Cloud Firestore
745721
` + (isSelected(result.firestore) ? `` : `//`) + ` implementation "com.google.firebase:firebase-firestore:21.1.1"
@@ -754,8 +730,8 @@ dependencies {
754730
` + (isSelected(result.crashlytics) ? `` : `//`) + ` implementation "com.crashlytics.sdk.android:crashlytics:2.10.1"
755731
756732
// Cloud Messaging (FCM)
757-
` + (isSelected(result.messaging) || externalPushClientOnly ? `` : `//`) + ` implementation "com.google.firebase:firebase-messaging:20.0.0"
758-
// ` + (isSelected(result.messaging) || externalPushClientOnly ? `` : `//`) + ` implementation "me.leolin:ShortcutBadger:1.1.22@aar"
733+
` + (isSelected(result.messaging) || isSelected(result.external_push_client_only) ? `` : `//`) + ` implementation "com.google.firebase:firebase-messaging:20.0.0"
734+
// ` + (isSelected(result.messaging) || isSelected(result.external_push_client_only) ? `` : `//`) + ` implementation "me.leolin:ShortcutBadger:1.1.22@aar"
759735
760736
// In-App Messaging
761737
` + (isSelected(result.in_app_messaging) ? `` : `//`) + ` implementation "com.google.firebase:firebase-inappmessaging-display:19.0.0"
@@ -1000,9 +976,9 @@ var copyPlist = function(copyPlistOpts) {
1000976
return true;
1001977
}
1002978
} else if (!fs.existsSync(destinationGooglePlist)) { // single GoogleService-Info.plist modus but missing`;
1003-
if (externalPushClientOnly) {
979+
if (externalPushClient) {
1004980
beforeCheckForChangesContent += `
1005-
return true; // this is a push-only project, so this is allowed`;
981+
return true; // this may be a push-only project, so this is allowed`;
1006982
} else {
1007983
beforeCheckForChangesContent += `
1008984
copyPlistOpts.$logger.warn("nativescript-plugin-firebase: " + destinationGooglePlist + " does not exist. Please follow the installation instructions from the documentation");

src/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nativescript-plugin-firebase",
3-
"version": "10.0.2",
3+
"version": "10.1.0",
44
"description": "Fire. Base. Firebase!",
55
"main": "firebase",
66
"typings": "index.d.ts",

0 commit comments

Comments
 (0)