Skip to content

Commit be6fd48

Browse files
authored
Merge pull request #24 from Astrovic/master
[Android] Makes compatible with the firebase.core 11.0.4 lib to use GDPR FirebaseAnalytics.enabled property
2 parents b708efa + f570211 commit be6fd48

9 files changed

+33
-35
lines changed

README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Firebase Analytics - Titanium Module
22
Use the native Firebase SDK in Axway Titanium. This repository is part of the [Titanium Firebase](https://github.com/hansemannn/titanium-firebase) project.
33

4-
⚠️ This module already comply to the EU General Data Protection Regulation ([GDPR](https://www.eugdpr.org/)) regulation already.
4+
⚠️ This module already comply to the EU General Data Protection Regulation ([GDPR](https://www.eugdpr.org/)) regulation already.
55
Use the `enabled` property to enable or disable Analytics and `resetAnalyticsData()` to make Cambridge Analytica angry 😙.
66

77
## Requirements
@@ -21,14 +21,14 @@ No additional setup required for Firebase Analytics on iOS.
2121

2222
There are a few additional requirements for Firebase Analytics on Android:
2323

24-
1. Copy the following code under the `<application>` tag of your tiapp.xml. Please note to replace
24+
1. Copy the following code under the `<application>` tag of your tiapp.xml. Please note to replace
2525
all occurrences of `MY_PACKAGE_NAME` with your actual package name (= `<id>` in your tiapp.xml):
2626

2727
```xml
2828
<android xmlns:android="http://schemas.android.com/apk/res/android">
2929
<manifest>
3030
<application>
31-
<service android:name="com.google.android.gms.measurement.AppMeasurementService" android:enabled="true" android:exported="false" />
31+
<service android:name="com.google.android.gms.measurement.AppMeasurementService" android:enabled="true" android:exported="false" />
3232

3333
<service android:name="com.google.android.gms.measurement.AppMeasurementJobService" android:permission="android.permission.BIND_JOB_SERVICE" android:enabled="true" android:exported="false" />
3434

@@ -65,7 +65,7 @@ all occurrences of `MY_PACKAGE_NAME` with your actual package name (= `<id>` in
6565
2. Create a file `strings.xml` that is located at:
6666
- Alloy: `<project-dir>/app/platform/android/res/values/strings.xml`
6767
- Classic: `<project-dir>/platform/android/res/values/strings.xml`
68-
68+
6969
with your Firebase Application ID (mobilesdk_app_id from the JSON file) content:
7070
```xml
7171
<?xml version="1.0" encoding="UTF-8"?>
@@ -87,44 +87,44 @@ all occurrences of `MY_PACKAGE_NAME` with your actual package name (= `<id>` in
8787
##### `log(name, parameters)`
8888
- `name` (String)
8989
- `parameters` (Dictionary, optional)
90-
91-
Logs an app event. The event can have up to 25 parameters. Events with the same name must
90+
91+
Logs an app event. The event can have up to 25 parameters. Events with the same name must
9292
have the same parameters. Up to 500 event names are supported.
93-
93+
9494
Make sure to check the [Log Events](https://firebase.google.com/docs/analytics/android/events) docs to validate
9595
that you are using a valid event name (1st parameter) and parameter structure (2nd event).
96-
96+
9797
##### `setUserPropertyString(parameters)`
9898
- `parameters` (Dictionary)
9999
- `value` (String)
100100
- `name` (String)
101101

102-
Sets a user property to a given value. Up to 25 user property names are supported. Once set, user
102+
Sets a user property to a given value. Up to 25 user property names are supported. Once set, user
103103
property values persist throughout the app lifecycle and across sessions.
104104

105105
##### `setScreenNameAndScreenClass(parameters)`
106106
- `parameters` (Dictionary)
107107
- `screenName` (String)
108108
- `screenClass` (String, iOS only)
109-
110-
Sets the current screen name, which specifies the current visual context in your app. This helps identify
109+
110+
Sets the current screen name, which specifies the current visual context in your app. This helps identify
111111
the areas in your app where users spend their time and how they interact with your app.
112112

113113

114-
##### `resetAnalyticsData()`
114+
##### `resetAnalyticsData()` (iOS-only, on Android requires /lib version > 11.6.0)
115115

116116
Clears all analytics data for this app from the device and resets the app instance id.
117117

118118
#### Properties
119119

120120
##### `enabled` (Boolean, set)
121121

122-
Sets whether analytics collection is enabled for this app on this device. This setting is persisted across
122+
Sets whether analytics collection is enabled for this app on this device. This setting is persisted across
123123
app sessions. By default it is enabled.
124124

125125
##### `appInstanceID` (String, get, iOS-only)
126126

127-
Instance ID provides a unique identifier for each app instance and a mechanism to authenticate and authorize
127+
Instance ID provides a unique identifier for each app instance and a mechanism to authenticate and authorize
128128
actions (for example, sending an FCM message).
129129

130130
##### `userID` (String, set, iOS-only)
@@ -182,4 +182,4 @@ appc run -p [ios|android] --build-only
182182

183183
## Legal
184184

185-
This module is Copyright (c) 2017-Present by Hans Knöchel. All Rights Reserved.
185+
This module is Copyright (c) 2017-Present by Hans Knöchel. All Rights Reserved.

android/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ repositories {
77
}
88

99
dependencies {
10-
compile 'com.google.firebase:firebase-analytics:15.0.0'
11-
compile 'com.google.firebase:firebase-analytics-impl:15.0.0'
10+
compile 'com.google.firebase:firebase-analytics:11.0.4'
11+
compile 'com.google.firebase:firebase-analytics-impl:11.0.4'
1212
}
1313

1414
configurations.all {

android/java-sources.txt

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
"/Users/hknoechel/Documents/appcelerator_modules/titanium-firebase/titanium-firebase-analytics/android/src/firebase/analytics/TitaniumFirebaseAnalyticsModule.java"
2-
"/Users/hknoechel/Documents/appcelerator_modules/titanium-firebase/titanium-firebase-analytics/android/build/generated/java/firebase/analytics/TitaniumFirebaseAnalyticsBootstrap.java"
3-
"/Users/hknoechel/Documents/appcelerator_modules/titanium-firebase/titanium-firebase-analytics/android/build/generated/r/android/support/compat/R.java"
4-
"/Users/hknoechel/Documents/appcelerator_modules/titanium-firebase/titanium-firebase-analytics/android/build/generated/r/android/support/design/R.java"
5-
"/Users/hknoechel/Documents/appcelerator_modules/titanium-firebase/titanium-firebase-analytics/android/build/generated/r/android/support/v7/appcompat/R.java"
6-
"/Users/hknoechel/Documents/appcelerator_modules/titanium-firebase/titanium-firebase-analytics/android/build/generated/r/android/support/v7/cardview/R.java"
7-
"/Users/hknoechel/Documents/appcelerator_modules/titanium-firebase/titanium-firebase-analytics/android/build/generated/r/com/google/android/gms/R.java"
8-
"/Users/hknoechel/Documents/appcelerator_modules/titanium-firebase/titanium-firebase-analytics/android/build/generated/r/com/google/firebase/measurement/R.java"
9-
"/Users/hknoechel/Documents/appcelerator_modules/titanium-firebase/titanium-firebase-analytics/android/build/generated/r/com/google/firebase/measurement_impl/R.java"
10-
"/Users/hknoechel/Documents/appcelerator_modules/titanium-firebase/titanium-firebase-analytics/android/build/generated/r/firebase/analytics/R.java"
11-
"/Users/hknoechel/Documents/appcelerator_modules/titanium-firebase/titanium-firebase-analytics/android/build/generated/r/ti/modules/titanium/ui/R.java"
1+
"/Users/Astrovic/Dati/Applicazioni/titanium-firebase-analytics/android/src/firebase/analytics/TitaniumFirebaseAnalyticsModule.java"
2+
"/Users/Astrovic/Dati/Applicazioni/titanium-firebase-analytics/android/build/generated/java/firebase/analytics/TitaniumFirebaseAnalyticsBootstrap.java"
3+
"/Users/Astrovic/Dati/Applicazioni/titanium-firebase-analytics/android/build/generated/r/android/support/compat/R.java"
4+
"/Users/Astrovic/Dati/Applicazioni/titanium-firebase-analytics/android/build/generated/r/android/support/design/R.java"
5+
"/Users/Astrovic/Dati/Applicazioni/titanium-firebase-analytics/android/build/generated/r/android/support/v7/appcompat/R.java"
6+
"/Users/Astrovic/Dati/Applicazioni/titanium-firebase-analytics/android/build/generated/r/android/support/v7/cardview/R.java"
7+
"/Users/Astrovic/Dati/Applicazioni/titanium-firebase-analytics/android/build/generated/r/firebase/analytics/R.java"
8+
"/Users/Astrovic/Dati/Applicazioni/titanium-firebase-analytics/android/build/generated/r/ti/modules/titanium/ui/R.java"
4.75 KB
Binary file not shown.
-9.69 KB
Binary file not shown.
230 KB
Binary file not shown.
-210 KB
Binary file not shown.

android/manifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# this is your module manifest and used by Titanium
33
# during compilation, packaging, distribution, etc.
44
#
5-
version: 2.1.0
5+
version: 2.1.1
66
apiversion: 4
77
architectures: arm64-v8a armeabi-v7a x86
88
description: titanium-firebase-analytics

android/src/firebase/analytics/TitaniumFirebaseAnalyticsModule.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
/**
2-
* This file was auto-generated by the Titanium Module SDK helper for Android
3-
* Appcelerator Titanium Mobile
4-
* Copyright (c) 2009-2010 by Appcelerator, Inc. All Rights Reserved.
2+
* Ti.FirebaseAnalytics
3+
* Copyright (c) 2018 by Hans Knöchel.
54
* Licensed under the terms of the Apache Public License
65
* Please see the LICENSE included with this distribution for details.
7-
*
86
*/
7+
98
package firebase.analytics;
109

1110
import org.appcelerator.kroll.annotations.Kroll;
@@ -39,7 +38,7 @@ private FirebaseAnalytics analyticsInstance()
3938
if (mFirebaseAnalytics == null) {
4039
mFirebaseAnalytics = FirebaseAnalytics.getInstance(getActivity().getApplicationContext());
4140
}
42-
41+
4342
return mFirebaseAnalytics;
4443
}
4544

@@ -52,7 +51,9 @@ public void log(String name, @Kroll.argument(optional = true) KrollDict paramete
5251
@Kroll.method
5352
public void resetAnalyticsData()
5453
{
55-
this.analyticsInstance().resetAnalyticsData();
54+
// TODO: Uncomment once Ti.PlayServices >= 11.6.0 is used
55+
// this.analyticsInstance().resetAnalyticsData();
56+
Log.e("FirebaseAnalytics", "The \"resetAnalyticsData()\" method on Android requires Ti.PlayServices >= 11.6.0");
5657
}
5758

5859
@Kroll.method @Kroll.setProperty

0 commit comments

Comments
 (0)