diff --git a/Assets/ConsentManagementProvider/Scripts/wrapper/iOS/CMPiOSListenerHelper.cs b/Assets/ConsentManagementProvider/Scripts/wrapper/iOS/CMPiOSListenerHelper.cs index 60dc1e6f..a4f6ecbc 100644 --- a/Assets/ConsentManagementProvider/Scripts/wrapper/iOS/CMPiOSListenerHelper.cs +++ b/Assets/ConsentManagementProvider/Scripts/wrapper/iOS/CMPiOSListenerHelper.cs @@ -42,15 +42,22 @@ private void Awake() self=this; gameObject.name = "CMPiOSListenerHelper"; #if UNITY_IOS && !UNITY_EDITOR_OSX - CmpDebugUtil.Log("Constructing CMPiOSListenerHelper game object..."); - DontDestroyOnLoad(this.gameObject); - _setCallbackDefault(Callback); - _setCallbackOnConsentReady(OnConsentReady); - _setCallbackOnConsentUIReady(OnConsentUIReady); - _setCallbackOnConsentAction(OnConsentAction); - _setCallbackOnConsentUIFinished(OnConsentUIFinished); - _setCallbackOnErrorCallback(OnErrorCallback); - _setCallbackOnCustomConsent(OnCustomConsentGDPRCallback); + CmpDebugUtil.Log("Constructing CMPiOSListenerHelper game object..."); + DontDestroyOnLoad(this.gameObject); + SetBridgeCallbacks(); +#endif + } + + internal void SetBridgeCallbacks() + { +#if UNITY_IOS && !UNITY_EDITOR_OSX + _setCallbackDefault(Callback); + _setCallbackOnConsentReady(OnConsentReady); + _setCallbackOnConsentUIReady(OnConsentUIReady); + _setCallbackOnConsentAction(OnConsentAction); + _setCallbackOnConsentUIFinished(OnConsentUIFinished); + _setCallbackOnErrorCallback(OnErrorCallback); + _setCallbackOnCustomConsent(OnCustomConsentGDPRCallback); #endif } @@ -158,5 +165,14 @@ static void OnCustomConsentGDPRCallback(string jsonSPGDPRConsent) } } } + + public void Dispose() + { + if (self != null) + { + Destroy(self.gameObject); + self = null; + } + } } } \ No newline at end of file diff --git a/Assets/ConsentManagementProvider/Scripts/wrapper/iOS/ConsentWrapperIOS.cs b/Assets/ConsentManagementProvider/Scripts/wrapper/iOS/ConsentWrapperIOS.cs index 1630f71f..b159ad54 100644 --- a/Assets/ConsentManagementProvider/Scripts/wrapper/iOS/ConsentWrapperIOS.cs +++ b/Assets/ConsentManagementProvider/Scripts/wrapper/iOS/ConsentWrapperIOS.cs @@ -96,6 +96,12 @@ public void InitializeLib( { #if UNITY_IOS && !UNITY_EDITOR_OSX _initLib(); + if(iOSListener == null) + { + CmpDebugUtil.Log("Creating iosListener"); + CreateHelperIOSListener(); + } + int campaignsAmount = spCampaigns.Count; int[] campaignTypes = new int[campaignsAmount]; foreach(SpCampaign sp in spCampaigns) @@ -200,6 +206,7 @@ public SpConsents GetSpConsents() public void ClearAllData() { #if UNITY_IOS && !UNITY_EDITOR_OSX + iOSListener._spConsents = null; _cleanConsent(); #endif } @@ -208,6 +215,7 @@ public void Dispose() { #if UNITY_IOS && !UNITY_EDITOR_OSX _dispose(); + iOSListener.Dispose(); #endif } } diff --git a/Assets/ExampleApp/Scenes/SourcepointSampleScene.unity b/Assets/ExampleApp/Scenes/SourcepointSampleScene.unity index 381013de..d981e4e9 100644 --- a/Assets/ExampleApp/Scenes/SourcepointSampleScene.unity +++ b/Assets/ExampleApp/Scenes/SourcepointSampleScene.unity @@ -236,9 +236,6 @@ MonoBehaviour: accountId: 22 propertyId: 16893 propertyName: mobile.multicampaign.demo - useGDPR: 1 - useCCPA: 1 - useUSNAT: 1 gdprPmId: 488393 ccpaPmId: 509688 usnatPmId: 943886 diff --git a/CHANGELOG.md b/CHANGELOG.md index 397ad1c5..eec4e98a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# 2.3.1 +* [DIA-3844](https://sourcepoint.atlassian.net/browse/DIA-3844) Destroy CMPiOSListenerHelper GameObject in Dispose() call and re-initialize it in CMP.Initialize() call if needed. Also, ClearAllData() method for IOS clears cached value in c# [#53](https://github.com/SourcePointUSA/unity-sdk/pull/53) + # 2.3.0 * [DIA-3046](https://sourcepoint.atlassian.net/browse/DIA-3046) Implemented USNat company for IOS [#47](https://github.com/SourcePointUSA/unity-sdk/pull/47) * [DIA-3630](https://sourcepoint.atlassian.net/browse/DIA-3630) Implemented USNat company for Android [#48](https://github.com/SourcePointUSA/unity-sdk/pull/48) diff --git a/package.json b/package.json index 388bcfc8..9d5c4f39 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "com.sourcepoint.unitycmp", "displayName": "Sourcepoint Consent Message Plugin", - "version": "2.3.0", + "version": "2.3.1", "unity": "2021.3", "description": "Native UI Privacy Manager for both GDPR and CCPA legislations.", "author": { diff --git a/unitypackage/ConsentManagementProvider.unitypackage b/unitypackage/ConsentManagementProvider.unitypackage index bbdd94e4..7602ccb2 100644 Binary files a/unitypackage/ConsentManagementProvider.unitypackage and b/unitypackage/ConsentManagementProvider.unitypackage differ