Skip to content

Commit

Permalink
Wrote last connection to come back from native code to Unity
Browse files Browse the repository at this point in the history
  • Loading branch information
mikechoch committed Apr 7, 2020
1 parent 143743e commit 198c482
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions OneSignalExample/Assets/OneSignal/src/OneSignal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,31 @@ private void onPostNotificationFailed(string jsonString) {
}
}

// Called from the native SDK
private void onExternalUserIdUpdateCompletion(string jsonString) {
if (string.IsNullOrEmpty(jsonString))
return;

// Break part the jsonString which might contain a 'delegate_id' and a 'response'
var jsonObject = Json.Deserialize(jsonString) as Dictionary<string, object>;

// Check if the delegate should be processed
if (!isValidDelegate(jsonObject))
return;

var delegateId = Json.Deserialize(jsonObject["delegate_id"] as string) as Dictionary<string, object>;
var delegateIdCompletion = delegateId["completion"] as string;

var response = jsonObject["response"] as string;
var results = Json.Deserialize(response) as Dictionary<string, object>;

if (delegates.ContainsKey(delegateIdCompletion)) {
var externalUserIdUpdateCompletionDelegate = (OnExternalUserIdUpdateCompletion) delegates[delegateIdCompletion];
delegates.Remove(delegateIdCompletion);
externalUserIdUpdateCompletionDelegate(results);
}
}

// Called from the native SDK
private void onSetEmailSuccess(string jsonString) {
if (string.IsNullOrEmpty(jsonString))
Expand Down

0 comments on commit 198c482

Please sign in to comment.