@@ -3,7 +3,7 @@ var path = require('path');
33var 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
99var 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
2729function 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-
10380function 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
268246function 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|
391367end` ) + `
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");
0 commit comments