Skip to content

Commit 198c482

Browse files
committed
Wrote last connection to come back from native code to Unity
1 parent 143743e commit 198c482

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

OneSignalExample/Assets/OneSignal/src/OneSignal.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,6 +1032,31 @@ private void onPostNotificationFailed(string jsonString) {
10321032
}
10331033
}
10341034

1035+
// Called from the native SDK
1036+
private void onExternalUserIdUpdateCompletion(string jsonString) {
1037+
if (string.IsNullOrEmpty(jsonString))
1038+
return;
1039+
1040+
// Break part the jsonString which might contain a 'delegate_id' and a 'response'
1041+
var jsonObject = Json.Deserialize(jsonString) as Dictionary<string, object>;
1042+
1043+
// Check if the delegate should be processed
1044+
if (!isValidDelegate(jsonObject))
1045+
return;
1046+
1047+
var delegateId = Json.Deserialize(jsonObject["delegate_id"] as string) as Dictionary<string, object>;
1048+
var delegateIdCompletion = delegateId["completion"] as string;
1049+
1050+
var response = jsonObject["response"] as string;
1051+
var results = Json.Deserialize(response) as Dictionary<string, object>;
1052+
1053+
if (delegates.ContainsKey(delegateIdCompletion)) {
1054+
var externalUserIdUpdateCompletionDelegate = (OnExternalUserIdUpdateCompletion) delegates[delegateIdCompletion];
1055+
delegates.Remove(delegateIdCompletion);
1056+
externalUserIdUpdateCompletionDelegate(results);
1057+
}
1058+
}
1059+
10351060
// Called from the native SDK
10361061
private void onSetEmailSuccess(string jsonString) {
10371062
if (string.IsNullOrEmpty(jsonString))

0 commit comments

Comments
 (0)