-
Notifications
You must be signed in to change notification settings - Fork 4
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
Feature_MC-1970 #88
base: develop
Are you sure you want to change the base?
Feature_MC-1970 #88
Changes from 1 commit
fd91978
3a2e05d
17fea76
18a24ac
16ccd1d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using CleverTapSDK.Native; | ||
using CleverTapSDK.Utilities; | ||
|
||
#if (!UNITY_IOS && !UNITY_ANDROID) || UNITY_EDITOR | ||
namespace Native.UnityNativeWrapper | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix namespace to be CleverTapSDK.Native and remove it from the usings. |
||
{ | ||
internal class UnityNativeMetadataResponseInterceptor : IUnityNativeResponseInterceptor | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The response interceptor is unused, it is not added to the engine interceptors. |
||
{ | ||
private readonly UnityNativeNetworkEngine _networkEngine; | ||
public UnityNativeMetadataResponseInterceptor(string accountId, UnityNativeNetworkEngine networkEngine) | ||
{ | ||
_networkEngine = networkEngine; | ||
} | ||
|
||
UnityNativeResponse IUnityNativeResponseInterceptor.Intercept(UnityNativeResponse response) | ||
{ | ||
Dictionary<string,object> responseContent = Json.Deserialize(response.Content) as Dictionary<string,object>; | ||
if (responseContent == null || responseContent.Count <= 0) | ||
return response; | ||
// Handle i | ||
try { | ||
if (responseContent.TryGetValue("_i", out var value)) { | ||
long i = long.Parse(value.ToString()); | ||
_networkEngine.SetI(i); | ||
} | ||
} catch (Exception t) { | ||
// Ignore | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do not ignore the exception. |
||
} | ||
|
||
// Handle j | ||
try { | ||
if (responseContent.TryGetValue("_j", out var value)) { | ||
long j = long.Parse(value.ToString()); | ||
_networkEngine.SetJ(j); | ||
} | ||
} catch (Exception t) { | ||
// Ignore | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do not ignore the exception. |
||
} | ||
|
||
return response; | ||
} | ||
} | ||
} | ||
#endif |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it is better for the interceptor to not have a reference to the network engine. This creates a circular reference since the engine adds and holds the interceptors.
The options on top of my head are:
_i
and_j
in the preferences and the engine to use them from there. The interceptor can get the preference manager using the account id.I believe it might be cleaner to go with 1. since you also already started with that approach.