Skip to content

Commit

Permalink
feat: add new “fetchAppInstanceID” API
Browse files Browse the repository at this point in the history
  • Loading branch information
hansemannn committed Mar 23, 2023
1 parent 1b663fe commit e48f608
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 10 deletions.
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ all occurrences of `MY_PACKAGE_NAME` with your actual package name (= `<id>` in
<intent-filter>
<action android:name="com.google.android.gms.measurement.UPLOAD" />
</intent-filter>
</receiver>
</receiver>

<!-- Only add the GCM-related tags if you are using push notifications as well -->
<service android:name="MY_PACKAGE_NAME.gcm.GcmIntentService" android:exported="false">
Expand All @@ -61,7 +61,7 @@ all occurrences of `MY_PACKAGE_NAME` with your actual package name (= `<id>` in
</service>
</application>
</manifest>
</android>
</android>
```

2. Create a file `strings.xml` that is located at:
Expand Down Expand Up @@ -117,18 +117,17 @@ 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)

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
Expand Down
2 changes: 1 addition & 1 deletion android/manifest
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions ios/Classes/FirebaseAnalyticsModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion ios/manifest
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ios/titanium.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e48f608

Please sign in to comment.