Skip to content

Commit b49f59a

Browse files
committed
Added update aar file for Android 3.13.1
Updated iOS framework file to 2.13.1 * Android and iOS bridges fully connected now and tested
1 parent 198c482 commit b49f59a

File tree

9 files changed

+108
-61
lines changed

9 files changed

+108
-61
lines changed

OneSignalExample/Assets/OneSignal/Example/GameControllerExample.cs

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,35 @@ void Start() {
7171
OneSignalOutcomeEventsExamples();
7272
}
7373

74+
75+
// Examples of using OneSignal External User Id
76+
private void OneSignalExternalUserIdCallback(Dictionary<string, object> results)
77+
{
78+
// The results will contain push and email success statuses
79+
Console.WriteLine("External user id updated with results: " + Json.Serialize(results));
80+
81+
// Push can be expected in almost every situation with a success status, but
82+
// as a pre-caution its good to verify it exists
83+
if (results.ContainsKey("push"))
84+
{
85+
Dictionary<string, object> pushStatusDict = results["push"] as Dictionary<string, object>;
86+
if (pushStatusDict.ContainsKey("success"))
87+
{
88+
Console.WriteLine("External user id updated for push with results: " + pushStatusDict["success"] as string);
89+
}
90+
}
91+
92+
// Verify the email is set or check that the results have an email success status
93+
if (results.ContainsKey("email"))
94+
{
95+
Dictionary<string, object> emailStatusDict = results["email"] as Dictionary<string, object>;
96+
if (emailStatusDict.ContainsKey("success"))
97+
{
98+
Console.WriteLine("External user id updated for email with results: " + emailStatusDict["success"] as string);
99+
}
100+
}
101+
}
102+
74103
// Examples of using OneSignal In-App Message triggers
75104
private void OneSignalInAppMessageTriggerExamples() {
76105
// Add a single trigger
@@ -301,17 +330,13 @@ void OnGUI() {
301330
count++;
302331

303332
if (GUI.Button(new Rect(itemOriginX, itemStartY + (count * itemHeightOffset), itemWidth, itemHeight), "SetExternalId", customTextSize)) {
304-
extraMessage = "Setting External User Id";
305-
306-
OneSignal.SetExternalUserId(externalId);
333+
OneSignal.SetExternalUserId(externalId, OneSignalExternalUserIdCallback);
307334
}
308335

309336
count++;
310337

311338
if (GUI.Button(new Rect(itemOriginX, itemStartY + (count * itemHeightOffset), itemWidth, itemHeight), "RemoveExternalId", customTextSize)) {
312-
extraMessage = "Removing External User Id";
313-
314-
OneSignal.RemoveExternalUserId();
339+
OneSignal.RemoveExternalUserId(OneSignalExternalUserIdCallback);
315340
}
316341

317342
if (requiresUserPrivacyConsent) {
Binary file not shown.

OneSignalExample/Assets/OneSignal/Platforms/iOS/OneSignalUnityRuntime.m

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -432,12 +432,22 @@ void _setLocationShared(bool shared) {
432432
[OneSignal setLocationShared:shared];
433433
}
434434

435-
void _setExternalUserId(const char *externalId) {
436-
[OneSignal setExternalUserId:CreateNSString(externalId)];
435+
void _setExternalUserId(const char* delegate, const char *externalId) {
436+
NSString* delegateId = CreateNSString(delegate);
437+
[OneSignal setExternalUserId:CreateNSString(externalId) withCompletion:^(NSDictionary *results) {
438+
NSString* response = dictionaryToNSString(results);
439+
NSDictionary* data = @{ @"delegate_id" : delegateId, @"response" : response };
440+
UnitySendMessage(unityListener, "onExternalUserIdUpdateCompletion", dictionaryToJsonChar(data));
441+
}];
437442
}
438443

439-
void _removeExternalUserId() {
440-
[OneSignal removeExternalUserId];
444+
void _removeExternalUserId(const char* delegate) {
445+
NSString* delegateId = CreateNSString(delegate);
446+
[OneSignal removeExternalUserId:^(NSDictionary *results) {
447+
NSString* response = dictionaryToNSString(results);
448+
NSDictionary* data = @{ @"delegate_id" : delegateId, @"response" : response };
449+
UnitySendMessage(unityListener, "onExternalUserIdUpdateCompletion", dictionaryToJsonChar(data));
450+
}];
441451
}
442452

443453
void _addTriggers(char *triggers) {
Binary file not shown.

OneSignalExample/Assets/OneSignal/src/OneSignal.cs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -734,32 +734,30 @@ public static void SetRequiresUserPrivacyConsent(bool required) {
734734

735735
public static void SetExternalUserId(string externalId) {
736736
#if ONESIGNAL_PLATFORM
737-
oneSignalPlatform.SetExternalUserId(externalId);
737+
string delegateGuidCompletion = OneSignalUnityUtils.GetNewGuid();
738+
oneSignalPlatform.SetExternalUserId(delegateGuidCompletion, externalId);
738739
#endif
739740
}
740741

741742
public static void SetExternalUserId(string externalId, OnExternalUserIdUpdateCompletion completion) {
742743
#if ONESIGNAL_PLATFORM
743744
string delegateGuidCompletion = OneSignalUnityUtils.GetNewGuid();
744-
745745
delegates.Add(delegateGuidCompletion, completion);
746-
747746
oneSignalPlatform.SetExternalUserId(delegateGuidCompletion, externalId);
748747
#endif
749748
}
750749

751750
public static void RemoveExternalUserId() {
752751
#if ONESIGNAL_PLATFORM
753-
oneSignalPlatform.RemoveExternalUserId();
752+
string delegateGuidCompletion = OneSignalUnityUtils.GetNewGuid();
753+
oneSignalPlatform.RemoveExternalUserId(delegateGuidCompletion);
754754
#endif
755755
}
756756

757757
public static void RemoveExternalUserId(OnExternalUserIdUpdateCompletion completion) {
758758
#if ONESIGNAL_PLATFORM
759759
string delegateGuidCompletion = OneSignalUnityUtils.GetNewGuid();
760-
761760
delegates.Add(delegateGuidCompletion, completion);
762-
763761
oneSignalPlatform.RemoveExternalUserId(delegateGuidCompletion);
764762
#endif
765763
}
@@ -1044,15 +1042,14 @@ private void onExternalUserIdUpdateCompletion(string jsonString) {
10441042
if (!isValidDelegate(jsonObject))
10451043
return;
10461044

1047-
var delegateId = Json.Deserialize(jsonObject["delegate_id"] as string) as Dictionary<string, object>;
1048-
var delegateIdCompletion = delegateId["completion"] as string;
1045+
var delegateId = jsonObject["delegate_id"] as string;
10491046

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

1053-
if (delegates.ContainsKey(delegateIdCompletion)) {
1054-
var externalUserIdUpdateCompletionDelegate = (OnExternalUserIdUpdateCompletion) delegates[delegateIdCompletion];
1055-
delegates.Remove(delegateIdCompletion);
1050+
if (delegates.ContainsKey(delegateId)) {
1051+
var externalUserIdUpdateCompletionDelegate = (OnExternalUserIdUpdateCompletion) delegates[delegateId];
1052+
delegates.Remove(delegateId);
10561053
externalUserIdUpdateCompletionDelegate(results);
10571054
}
10581055
}

OneSignalExample/Assets/OneSignal/src/OneSignalAndroid.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -142,18 +142,10 @@ public void SetRequiresUserPrivacyConsent(bool required) {
142142
mOneSignal.Call("setRequiresUserPrivacyConsent", required);
143143
}
144144

145-
public void SetExternalUserId(string externalId) {
146-
mOneSignal.Call("setExternalUserId", externalId);
147-
}
148-
149145
public void SetExternalUserId(string delegateId, string externalId) {
150146
mOneSignal.Call("setExternalUserId", delegateId, externalId);
151147
}
152148

153-
public void RemoveExternalUserId() {
154-
mOneSignal.Call("removeExternalUserId");
155-
}
156-
157149
public void RemoveExternalUserId(string delegateId) {
158150
mOneSignal.Call("removeExternalUserId", delegateId);
159151
}

OneSignalExample/Assets/OneSignal/src/OneSignalIOS.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,9 @@ public class OneSignalIOS : OneSignalPlatform {
121121
[System.Runtime.InteropServices.DllImport("__Internal")]
122122
extern static public void _setLocationShared(bool enable);
123123

124-
[System.Runtime.InteropServices.DllImport("__Internal")]
125-
extern static public void _setExternalUserId(string externalId);
126-
127124
[System.Runtime.InteropServices.DllImport("__Internal")]
128125
extern static public void _setExternalUserId(string delegateId, string externalId);
129126

130-
[System.Runtime.InteropServices.DllImport("__Internal")]
131-
extern static public void _removeExternalUserId();
132-
133127
[System.Runtime.InteropServices.DllImport("__Internal")]
134128
extern static public void _removeExternalUserId(string delegateId);
135129

@@ -269,18 +263,10 @@ public void SetRequiresUserPrivacyConsent(bool required) {
269263
_setRequiresUserPrivacyConsent(required);
270264
}
271265

272-
public void SetExternalUserId(string externalId) {
273-
_setExternalUserId(externalId);
274-
}
275-
276266
public void SetExternalUserId(string delegateId, string externalId) {
277267
_setExternalUserId(delegateId, externalId);
278268
}
279269

280-
public void RemoveExternalUserId() {
281-
_removeExternalUserId();
282-
}
283-
284270
public void RemoveExternalUserId(string delegateId) {
285271
_removeExternalUserId(delegateId);
286272
}

OneSignalExample/Assets/OneSignal/src/OneSignalPlatform.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ public interface OneSignalPlatform {
5959
bool UserProvidedConsent();
6060
void SetRequiresUserPrivacyConsent(bool required);
6161

62-
void SetExternalUserId(string externalId);
6362
void SetExternalUserId(string delegateId, string externalId);
64-
void RemoveExternalUserId();
6563
void RemoveExternalUserId(string delegateId);
6664

6765
void AddPermissionObserver();

OneSignalExample/Assets/Plugins/Android/OneSignalConfig.meta

Lines changed: 55 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)