Skip to content

Commit 65bb6d8

Browse files
authored
Merge pull request #84 from Astrovic/master
feat(ios/android): update the Firebase iOS SDK to 10.25.0 and Android SDK to 22.0.0
2 parents 6d61c8b + bab1443 commit 65bb6d8

File tree

1,390 files changed

+80111
-28342
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,390 files changed

+80111
-28342
lines changed

README.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,15 @@ Make sure to check the [Log Events](https://firebase.google.com/docs/analytics/a
116116
- `value` (String)
117117
- `name` (String)
118118

119+
Set up [consent mode](https://developers.google.com/tag-platform/security/guides/app-consent?consentmode=advanced) for apps
120+
121+
##### `setConsent(parameters)`
122+
- `parameters` (Dictionary)
123+
- `analyticsStorage` (Boolean)
124+
- `adStorage` (Boolean)
125+
- `adUserData` (Boolean)
126+
- `adPersonalization` (Boolean)
127+
119128
Sets a user property to a given value. Up to 25 user property names are supported. Once set, user
120129
property values persist throughout the app lifecycle and across sessions.
121130

@@ -166,11 +175,19 @@ Ti.API.info('App Instance ID: ' + FirebaseAnalytics.appInstanceID);
166175
FirebaseAnalytics.log('My_Event', { /* Optional arguments */ });
167176

168177
// Set user-property string
169-
FirebaseAnalytics.setUserPropertyString({
170-
name: 'My_Name',
178+
FirebaseAnalytics.saveUserProperty({
179+
name: 'My Name',
171180
value: 'My Value'
172181
});
173182

183+
// Set consents
184+
FirebaseAnalytics.setConsent({
185+
analyticsStorage: true,
186+
adStorage: true,
187+
adUserData: true,
188+
adPersonalization: true
189+
});
190+
174191
// Set User-ID
175192
FirebaseAnalytics.userID = 'MyUserID';
176193

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ repositories {
33
}
44

55
dependencies {
6-
implementation 'com.google.firebase:firebase-analytics:22.2.0'
6+
implementation 'com.google.firebase:firebase-analytics:22.4.0'
77
implementation 'com.google.firebase:firebase-installations:18.0.0'
88
}

android/java-sources.txt

Lines changed: 0 additions & 50 deletions
This file was deleted.

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: 5.3.0
5+
version: 5.4.0
66
apiversion: 4
77
architectures: arm64-v8a armeabi-v7a x86 x86_64
88
description: titanium-firebase-analytics

android/src/firebase/analytics/TitaniumFirebaseAnalyticsModule.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@
1111
import android.os.Bundle;
1212

1313
import com.google.firebase.analytics.FirebaseAnalytics;
14+
import com.google.firebase.analytics.FirebaseAnalytics.ConsentStatus;
15+
import com.google.firebase.analytics.FirebaseAnalytics.ConsentType;
1416
import com.google.firebase.installations.FirebaseInstallations;
1517

1618
import java.io.IOException;
19+
import java.util.EnumMap;
1720
import java.util.Map;
1821
import org.appcelerator.kroll.KrollDict;
1922
import org.appcelerator.kroll.KrollFunction;
@@ -61,6 +64,26 @@ public void setEnabled(Boolean enabled)
6164
this.analyticsInstance().setAnalyticsCollectionEnabled(enabled);
6265
}
6366

67+
private ConsentStatus toConsentStatus(boolean granted) {
68+
return granted ? ConsentStatus.GRANTED : ConsentStatus.DENIED;
69+
}
70+
71+
@Kroll.method
72+
public void setConsent(KrollDict opts) {
73+
boolean analyticsStorage = TiConvert.toBoolean(opts, "analyticsStorage", false);
74+
boolean adStorage = TiConvert.toBoolean(opts, "adStorage", false);
75+
boolean adUserData = TiConvert.toBoolean(opts, "adUserData", false);
76+
boolean adPersonalization = TiConvert.toBoolean(opts, "adPersonalization", false);
77+
78+
Map<ConsentType, ConsentStatus> consentMap = new EnumMap<>(ConsentType.class);
79+
consentMap.put(ConsentType.ANALYTICS_STORAGE, toConsentStatus(analyticsStorage));
80+
consentMap.put(ConsentType.AD_STORAGE, toConsentStatus(adStorage));
81+
consentMap.put(ConsentType.AD_USER_DATA, toConsentStatus(adUserData));
82+
consentMap.put(ConsentType.AD_PERSONALIZATION, toConsentStatus(adPersonalization));
83+
84+
this.analyticsInstance().setConsent(consentMap);
85+
}
86+
6487
@Kroll.method
6588
@Kroll.setProperty
6689
public void setUserPropertyString(KrollDict parameters)
@@ -171,4 +194,4 @@ private Bundle mapToBundle(Map<String, Object> map)
171194

172195
return bundle;
173196
}
174-
}
197+
}

android/timodule.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<ti:module xmlns:ti="http://ti.appcelerator.org" xmlns:android="http://schemas.android.com/apk/res/android">
3+
<android xmlns:android="http://schemas.android.com/apk/res/android">
4+
<manifest>
5+
<application>
6+
<meta-data android:name="google_analytics_default_allow_analytics_storage" android:value="true" />
7+
<meta-data android:name="google_analytics_default_allow_ad_storage" android:value="true" />
8+
<meta-data android:name="google_analytics_default_allow_ad_user_data" android:value="true" />
9+
<meta-data android:name="google_analytics_default_allow_ad_personalization_signals" android:value="true" />
10+
</application>
11+
</manifest>
12+
</android>
313
<modules>
414
<!-- Require Ti.PlayServices (https://github.com/appcelerator-modules/ti.playservices) -->
515
<module platform="android">ti.playservices</module>

example/app.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,19 @@ Ti.API.info('App Instance ID: ' + FirebaseAnalytics.appInstanceID);
1111
FirebaseAnalytics.log('My Event', { /* Optional arguments */ });
1212

1313
// Set user-property string
14-
FirebaseAnalytics.setUserPropertyString({
14+
FirebaseAnalytics.saveUserProperty({
1515
name: 'My Name',
1616
value: 'My Value'
1717
});
1818

19+
// Set consents
20+
FirebaseAnalytics.setConsent({
21+
analyticsStorage: true,
22+
adStorage: true,
23+
adUserData: true,
24+
adPersonalization: true
25+
});
26+
1927
// Set User-ID
2028
FirebaseAnalytics.setUserID('MyUserID');
2129

ios/Classes/FirebaseAnalyticsModule.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
- (void)setUserPropertyString:(id)arguments; // DEPRECATED: Use "saveUserProperty(arguments)" method instead
1717

18+
- (void)setConsent:(id)arguments;
19+
1820
- (void)setUserID:(NSString *)userID;
1921

2022
- (void)setEnabled:(NSNumber *)enabled;

ios/Classes/FirebaseAnalyticsModule.m

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,25 @@ - (void)saveUserProperty:(id)arguments
6767
forName:name];
6868
}
6969

70+
- (void)setConsent:(id)arguments
71+
{
72+
ENSURE_SINGLE_ARG(arguments, NSDictionary);
73+
74+
BOOL analyticsStorage = [TiUtils boolValue:@"analyticsStorage" properties:arguments def:NO];
75+
BOOL adStorage = [TiUtils boolValue:@"adStorage" properties:arguments def:NO];
76+
BOOL adUserData = [TiUtils boolValue:@"adUserData" properties:arguments def:NO];
77+
BOOL adPersonalization = [TiUtils boolValue:@"adPersonalization" properties:arguments def:NO];
78+
79+
NSDictionary *consentDictionary = @{
80+
FIRConsentTypeAnalyticsStorage : analyticsStorage ? FIRConsentStatusGranted : FIRConsentStatusDenied,
81+
FIRConsentTypeAdStorage : adStorage ? FIRConsentStatusGranted : FIRConsentStatusDenied,
82+
FIRConsentTypeAdUserData : adUserData ? FIRConsentStatusGranted : FIRConsentStatusDenied,
83+
FIRConsentTypeAdPersonalization : adPersonalization ? FIRConsentStatusGranted : FIRConsentStatusDenied
84+
};
85+
86+
[FIRAnalytics setConsent:consentDictionary];
87+
}
88+
7089
- (void)setUserID:(id)userID
7190
{
7291
if (IS_NULL_OR_NIL(userID)) {

ios/Classes/FirebaseAnalyticsModuleAssets.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
* This is a generated file. Do not edit or your changes will be lost
33
*/
44

5-
@interface FirebaseAnalyticsModuleAssets : NSObject
6-
{
5+
@interface FirebaseAnalyticsModuleAssets : NSObject {
6+
77
}
8-
- (NSData*) moduleAsset;
9-
- (NSData*) resolveModuleAsset:(NSString*)path;
8+
9+
- (NSData *)moduleAsset;
10+
- (NSData *)resolveModuleAsset:(NSString*)path;
1011

1112
@end

0 commit comments

Comments
 (0)