https://github.com/hansemannn/titanium-firebase-analytics
Use the Firebase Analytics SDK in Axway Titanium ๐
https://github.com/hansemannn/titanium-firebase-analytics
appcelerator axway firebase firebase-analytics javascript native titanium
Last synced: about 2 months ago
JSON representation
Use the Firebase Analytics SDK in Axway Titanium ๐
- Host: GitHub
- URL: https://github.com/hansemannn/titanium-firebase-analytics
- Owner: hansemannn
- License: other
- Created: 2017-10-15T21:35:40.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2025-02-28T12:26:43.000Z (3 months ago)
- Last Synced: 2025-03-29T01:12:34.456Z (2 months ago)
- Topics: appcelerator, axway, firebase, firebase-analytics, javascript, native, titanium
- Language: Objective-C
- Size: 114 MB
- Stars: 34
- Watchers: 7
- Forks: 19
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Firebase Analytics - Titanium Module
Use the native Firebase SDK in Axway Titanium. This repository is part of the [Titanium Firebase](https://github.com/hansemannn/titanium-firebase) project.โ ๏ธ This module complies to the EU General Data Protection Regulation ([GDPR](https://www.eugdpr.org/)) regulation already.
Use the `enabled` property to enable or disable Analytics and `resetAnalyticsData()` to make Cambridge Analytica angry ๐.## Supporting this effort
The whole Firebase support in Titanium is developed and maintained by the community (`@hansemannn` and `@m1ga`). To keep
this project maintained and be able to use the latest Firebase SDK's, please see the "Sponsor" button of this repository,
thank you!## Requirements
- [x] The [Firebase Core](https://github.com/hansemannn/titanium-firebase-core) module (iOS only)
- [x] iOS: Titanium SDK 6.2.0+
- [x] Android: Titanium SDK 7.0.0+## Installation
In general, make sure to follow the general instructions described in the [main project](https://github.com/hansemannn/titanium-firebase/blob/master/README.md#๏ธ-android-note).
### iOS
No additional setup required for Firebase Analytics on iOS.
## Android
There are a few additional requirements for Firebase Analytics on Android:
1. Copy the following code under the `` tag of your tiapp.xml. Please note to replace
all occurrences of `MY_PACKAGE_NAME` with your actual package name (= `` in your tiapp.xml):```xml
```
2. Create a file `strings.xml` that is located at:
- Alloy: `/app/platform/android/res/values/strings.xml`
- Classic: `/platform/android/res/values/strings.xml`with your Firebase Application ID (mobilesdk_app_id from the JSON file) content:
```xmlYOUR_FIREBASE_APPLICATION_ID
```
### Disable AD_ID
If you get a warning about AD_ID usage you can try the following tiapp.xml lines to remove it:
```xml
```
It might impact you analytics data so only use it if you are sure you don't need it. Check [Google Support: Advertising ID](https://support.google.com/googleplay/android-developer/answer/6048248?hl=en) for more information.## Download
- [x] [Stable release](https://github.com/hansemannn/titanium-firebase-analytics/releases)
- [x] [](http://gitt.io/component/firebase.analytics)## API's
### `FirebaseAnalytics`
#### Methods
##### `log(name, parameters)`
- `name` (String)
- `parameters` (Dictionary, optional)Logs an app event. The event can have up to 25 parameters. Events with the same name must
have the same parameters. Up to 500 event names are supported.Make sure to check the [Log Events](https://firebase.google.com/docs/analytics/android/events) docs to validate
that you are using a valid event name (1st parameter) and parameter structure (2nd event).##### `saveUserProperty(parameters)`
- `parameters` (Dictionary)
- `value` (String)
- `name` (String)Sets a user property to a given value. Up to 25 user property names are supported. Once set, user
property values persist throughout the app lifecycle and across sessions.##### `setScreenNameAndScreenClass(parameters)`
- `parameters` (Dictionary)
- `screenName` (String)
- `screenClass` (String, defaults to `TiController`)Sets the current screen name, which specifies the current visual context in your app. This helps identify
the areas in your app where users spend their time and how they interact with your app.##### `resetAnalyticsData()` (iOS-only, on Android requires /lib version > 11.6.0)
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.##### `userID` (String, set)
The user ID to ascribe to the user of this app on this device, which must be
non-empty and no more than 256 characters long. Setting userID to `null` removes the user ID.## Example
```js
// Require the Firebase Core module (own project!)
if (OS_IOS) {
var FirebaseCore = require('firebase.core');
FirebaseCore.configure();
}// Require the Firebase Analytics module
var FirebaseAnalytics = require('firebase.analytics');// Get the App Instance ID
Ti.API.info('App Instance ID: ' + FirebaseAnalytics.appInstanceID);// Log to the Firebase console
FirebaseAnalytics.log('My_Event', { /* Optional arguments */ });// Set user-property string
FirebaseAnalytics.setUserPropertyString({
name: 'My_Name',
value: 'My Value'
});// Set User-ID
FirebaseAnalytics.userID = 'MyUserID';// Set screen-name and screen-class
FirebaseAnalytics.setScreenNameAndScreenClass({
screenName: 'ScreenName',
screenClass: 'ScreenClass'
});// Toogle analytics on/off (default: on / true)
FirebaseAnalytics.enabled = false;
```## Update SDK's
- [x] Android: Using Gradle command `gradle getDeps`
- [x] iOS: Downloading the [latest framework](https://firebase.google.com/download/ios)## Build
```js
cd ios
appc run -p [ios|android] --build-only
```## Legal
This module is Copyright (c) 2017-Present by Hans Knรถchel. All Rights Reserved.