Skip to content

Commit 580eb82

Browse files
committed
Android Unity GDPR Support
• Adds support for Android to be able to use the GDPR privacy consent methods
1 parent e85015b commit 580eb82

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed
Binary file not shown.

OneSignalExample/Assets/OneSignal/src/OneSignal.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ private static void initOneSignalPlatform() {
385385

386386
#if ONESIGNAL_PLATFORM && UNITY_ANDROID
387387
private static void initAndroid() {
388-
oneSignalPlatform = new OneSignalAndroid(gameObjectName, builder.googleProjectNumber, builder.appID, inFocusDisplayType, logLevel, visualLogLevel);
388+
oneSignalPlatform = new OneSignalAndroid(gameObjectName, builder.googleProjectNumber, builder.appID, inFocusDisplayType, logLevel, visualLogLevel, requiresUserConsent);
389389
}
390390
#endif
391391

OneSignalExample/Assets/OneSignal/src/OneSignalAndroid.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
public class OneSignalAndroid : OneSignalPlatform {
3535
private static AndroidJavaObject mOneSignal = null;
3636

37-
public OneSignalAndroid(string gameObjectName, string googleProjectNumber, string appId, OneSignal.OSInFocusDisplayOption displayOption, OneSignal.LOG_LEVEL logLevel, OneSignal.LOG_LEVEL visualLevel) {
38-
mOneSignal = new AndroidJavaObject("com.onesignal.OneSignalUnityProxy", gameObjectName, googleProjectNumber, appId, (int)logLevel, (int)visualLevel);
37+
public OneSignalAndroid(string gameObjectName, string googleProjectNumber, string appId, OneSignal.OSInFocusDisplayOption displayOption, OneSignal.LOG_LEVEL logLevel, OneSignal.LOG_LEVEL visualLevel, bool requiresUserConsent) {
38+
mOneSignal = new AndroidJavaObject("com.onesignal.OneSignalUnityProxy", gameObjectName, googleProjectNumber, appId, (int)logLevel, (int)visualLevel, requiresUserConsent);
3939
SetInFocusDisplaying(displayOption);
4040
}
4141

@@ -127,6 +127,18 @@ public void removeEmailSubscriptionObserver() {
127127
mOneSignal.Call("removeEmailSubscriptionObserver");
128128
}
129129

130+
public void UserDidProvideConsent(bool consent) {
131+
mOneSignal.Call("provideUserConsent", consent);
132+
}
133+
134+
public bool UserProvidedConsent() {
135+
return mOneSignal.Call<bool>("userProvidedPrivacyConsent");
136+
}
137+
138+
public void SetRequiresUserPrivacyConsent(bool required) {
139+
mOneSignal.Call("setRequiresUserPrivacyConsent", required);
140+
}
141+
130142
public OSPermissionSubscriptionState getPermissionSubscriptionState() {
131143
return OneSignalPlatformHelper.parsePermissionSubscriptionState(this, mOneSignal.Call<string>("getPermissionSubscriptionState"));
132144
}

0 commit comments

Comments
 (0)