From e48f60852da1e899d714f66e416beef30abb5cf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hans=20Kn=C3=B6chel?= Date: Thu, 23 Mar 2023 16:06:10 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20add=20new=20=E2=80=9CfetchAppInstanceID?= =?UTF-8?q?=E2=80=9D=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 13 ++++++------- android/manifest | 2 +- .../TitaniumFirebaseAnalyticsModule.java | 15 +++++++++++++++ ios/Classes/FirebaseAnalyticsModule.m | 6 ++++++ ios/manifest | 2 +- ios/titanium.xcconfig | 2 +- 6 files changed, 30 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 6ff1c62..92227e8 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ all occurrences of `MY_PACKAGE_NAME` with your actual package name (= `` in - + @@ -61,7 +61,7 @@ all occurrences of `MY_PACKAGE_NAME` with your actual package name (= `` in - + ``` 2. Create a file `strings.xml` that is located at: @@ -117,6 +117,10 @@ the areas in your app where users spend their time and how they interact with yo Clears all analytics data for this app from the device and resets the app instance id. +##### `fetchAppInstanceID(callback)` + +Fetches the app instance ID. + #### Properties ##### `enabled` (Boolean, set) @@ -124,11 +128,6 @@ Clears all analytics data for this app from the device and resets the app instan Sets whether analytics collection is enabled for this app on this device. This setting is persisted across app sessions. By default it is enabled. -##### `appInstanceID` (String, get, iOS-only) - -Instance ID provides a unique identifier for each app instance and a mechanism to authenticate and authorize -actions (for example, sending an FCM message). - ##### `userID` (String, set) The user ID to ascribe to the user of this app on this device, which must be diff --git a/android/manifest b/android/manifest index ba2a213..4819cba 100644 --- a/android/manifest +++ b/android/manifest @@ -2,7 +2,7 @@ # this is your module manifest and used by Titanium # during compilation, packaging, distribution, etc. # -version: 5.1.1 +version: 5.2.0 apiversion: 4 architectures: arm64-v8a armeabi-v7a x86 x86_64 description: titanium-firebase-analytics diff --git a/android/src/firebase/analytics/TitaniumFirebaseAnalyticsModule.java b/android/src/firebase/analytics/TitaniumFirebaseAnalyticsModule.java index b83d53b..2671aeb 100644 --- a/android/src/firebase/analytics/TitaniumFirebaseAnalyticsModule.java +++ b/android/src/firebase/analytics/TitaniumFirebaseAnalyticsModule.java @@ -98,6 +98,21 @@ public void fetchInstallationID(KrollFunction callback) { }); } + @Kroll.method + public void fetchAppInstanceID(KrollFunction callback) { + mFirebaseAnalytics.getAppInstanceId().addOnCompleteListener(task -> { + KrollDict data = new KrollDict(); + if (!task.isSuccessful()) { + data.put("success", false); + } else { + data.put("success", true); + } + + data.put("appInstanceID", task.getResult()); + callback.callAsync(getKrollObject(), data); + }); + } + @Kroll.method @Kroll.setProperty public void setScreenNameAndScreenClass(KrollDict parameters) diff --git a/ios/Classes/FirebaseAnalyticsModule.m b/ios/Classes/FirebaseAnalyticsModule.m index 7f81a0b..8bd7670 100644 --- a/ios/Classes/FirebaseAnalyticsModule.m +++ b/ios/Classes/FirebaseAnalyticsModule.m @@ -121,4 +121,10 @@ - (NSString *)appInstanceID return [FIRAnalytics appInstanceID]; } +- (void)fetchAppInstanceID:(id)callback +{ + ENSURE_SINGLE_ARG(callback, KrollCallback); + [callback call:@[@{ @"appInstanceID": [self appInstanceID]}] thisObject:self]; +} + @end diff --git a/ios/manifest b/ios/manifest index a85f651..493660f 100644 --- a/ios/manifest +++ b/ios/manifest @@ -2,7 +2,7 @@ # this is your module manifest and used by Titanium # during compilation, packaging, distribution, etc. # -version: 7.0.0 +version: 7.1.0 apiversion: 2 architectures: arm64 x86_64 description: titanium-firebase-analytics diff --git a/ios/titanium.xcconfig b/ios/titanium.xcconfig index 55eb999..a78f83c 100644 --- a/ios/titanium.xcconfig +++ b/ios/titanium.xcconfig @@ -4,7 +4,7 @@ // OF YOUR TITANIUM SDK YOU'RE BUILDING FOR // // -TITANIUM_SDK_VERSION = 11.1.0.GA +TITANIUM_SDK_VERSION = 12.0.0.GA // // THESE SHOULD BE OK GENERALLY AS-IS