Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DIA-2586] Іmplementation of ClearAllData() #24

Merged
merged 4 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,18 @@ import UIKit
ccpaPmId: ccpaPmId
)}()
}

@objc public func dispose() {
callbackDefault = nil
callbackOnConsentReady = nil
callbackOnConsentUIReady = nil
callbackOnConsentAction = nil
callbackOnConsentUIFinished = nil
callbackOnErrorCallback = nil
callbackOnSPFinished = nil
callbackOnSPUIFinished = nil
callbackOnCustomConsent = nil
}

// MARK: - Manage lib
@objc public func loadMessage(authId: String? = nil) {
Expand Down
5 changes: 5 additions & 0 deletions Assets/ConsentManagementProvider/Plugins/iOS/Source/Unity.mm
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,9 @@ void _customConsentGDPRWithVendors()
{
//TO-DO
}

void _dispose()
{
[swiftBridge dispose];
}
}
21 changes: 21 additions & 0 deletions Assets/ConsentManagementProvider/Scripts/facade/CMP.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,27 @@ public static void LoadMessage(string authId = null)
#endif
}

public static void ClearAllData(string authId = null)
{
if (IsEditor)
{
Debug.LogWarning("Emulating ClearAllData call... Sourcepoint CMP works only for real Android/iOS devices, not the Unity Editor.");
return;
}

#if UNITY_ANDROID
if (Application.platform == RuntimePlatform.Android)
{
SpAndroidNativeUtils.ClearAllData();
}
#elif UNITY_IOS && !UNITY_EDITOR_OSX
if (Application.platform == RuntimePlatform.IPhonePlayer)
{
ConsentWrapperIOS.Instance.ClearAllData();
}
#endif
}

public static void LoadPrivacyManager(CAMPAIGN_TYPE campaignType, string pmId, PRIVACY_MANAGER_TAB tab)
{
if (IsEditor)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using UnityEngine;
using ConsentManagementProviderLib.Json;

namespace ConsentManagementProviderLib.Android
{
internal class SpAndroidNativeUtils
{
private static AndroidJavaClass unityPlayerClass;
private static AndroidJavaObject currentActivity;

static SpAndroidNativeUtils()
{
unityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
currentActivity = unityPlayerClass.GetStatic<AndroidJavaObject>("currentActivity");
}

public static void ClearAllData()
{
AndroidJavaClass spUtilsClass = new AndroidJavaClass("com.sourcepoint.cmplibrary.util.SpUtils");

currentActivity.Call("runOnUiThread", new AndroidJavaRunnable(() =>
{
spUtilsClass.CallStatic("clearAllData", currentActivity);
}));
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ private set
private static extern void _cleanConsent();
[DllImport("__Internal")]
private static extern void _customConsentGDPRWithVendors();
[DllImport("__Internal")]
private static extern void _dispose();
#endif

public ConsentWrapperIOS()
Expand Down Expand Up @@ -132,10 +134,17 @@ public SpConsents GetSpConsents()
return iOSListener._spConsents;
}

public void Dispose()
public void ClearAllData()
{
#if UNITY_IOS && !UNITY_EDITOR_OSX
_cleanConsent();
#endif
}

public void Dispose()
{
#if UNITY_IOS && !UNITY_EDITOR_OSX
_dispose();
#endif
}
}
Expand Down
3 changes: 1 addition & 2 deletions Assets/ExampleApp/Scripts/PrivacySettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,8 @@ public void OnPrivacyManagerButtonClick()

public void OnClearDataPress()
{
PlayerPrefs.DeleteAll();
CMP.ClearAllData();
storedConsentString = null;
CMP.Dispose();
updateUI();
}

Expand Down