Skip to content

Commit b1564a9

Browse files
committed
Android's onSpFinished handling and force logging enabled
1 parent 2b4b4a4 commit b1564a9

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

Assets/ConsentManagementProvider/Scripts/wrapper/Android/SpClientProxy.cs

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,34 @@ void onConsentReady(string spConsents)
6262
_spConsents = consents;
6363
ConsentMessenger.Broadcast<IOnConsentReady>(consents);
6464
}
65-
65+
66+
/**
67+
* It is invoked when the interaction with native WebView is done, consent sent, JSON received and CMP is ready to close the WebView
68+
*/
6669
void onSpFinished(string spConsents)
6770
{
68-
CmpDebugUtil.Log("I've reached the C# onSpFinished");
69-
SpConsents consents = JsonUnwrapper.UnwrapSpConsentsAndroid(spConsents);
70-
_spConsents = consents;
71-
ConsentMessenger.Broadcast<IOnConsentSpFinished>(consents);
72-
}
71+
CmpDebugUtil.ForceEnableNextCmpLog();
72+
CmpDebugUtil.LogWarning($"I've reached the C# onSpFinished with JSON spConsents={spConsents}");
7373

74+
try
75+
{
76+
SpConsents consents = JsonUnwrapper.UnwrapSpConsentsAndroid(spConsents);
77+
_spConsents = consents;
78+
ConsentMessenger.Broadcast<IOnConsentSpFinished>(consents);
79+
}
80+
catch (Exception e)
81+
{
82+
ConsentMessenger.Broadcast<IOnConsentError>(e);
83+
}
84+
}
7485

7586
void onError(AndroidJavaObject rawThrowableObject)
7687
{
77-
CmpDebugUtil.Log("I've reached the C# onError : " + rawThrowableObject.ToString());
88+
CmpDebugUtil.ForceEnableNextCmpLog();
89+
CmpDebugUtil.LogError("I've reached the C# onError : " + rawThrowableObject.ToString());
7890
Exception exception = CmpJavaToUnityUtils.ConvertThrowableToError(rawThrowableObject);
79-
CmpDebugUtil.Log("Exception converted successfully : " + exception.ToString());
91+
CmpDebugUtil.ForceEnableNextCmpLog();
92+
CmpDebugUtil.LogError("Exception converted successfully : " + exception.ToString());
8093
ConsentMessenger.Broadcast<IOnConsentError>(exception);
8194
}
8295

0 commit comments

Comments
 (0)