Skip to content

Commit

Permalink
Added update aar file for Android 3.13.1
Browse files Browse the repository at this point in the history
Updated iOS framework file to 2.13.1
* Android and iOS bridges fully connected now and tested
  • Loading branch information
mikechoch committed Apr 9, 2020
1 parent 198c482 commit b49f59a
Show file tree
Hide file tree
Showing 9 changed files with 108 additions and 61 deletions.
37 changes: 31 additions & 6 deletions OneSignalExample/Assets/OneSignal/Example/GameControllerExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,35 @@ void Start() {
OneSignalOutcomeEventsExamples();
}


// Examples of using OneSignal External User Id
private void OneSignalExternalUserIdCallback(Dictionary<string, object> results)
{
// The results will contain push and email success statuses
Console.WriteLine("External user id updated with results: " + Json.Serialize(results));

// Push can be expected in almost every situation with a success status, but
// as a pre-caution its good to verify it exists
if (results.ContainsKey("push"))
{
Dictionary<string, object> pushStatusDict = results["push"] as Dictionary<string, object>;
if (pushStatusDict.ContainsKey("success"))
{
Console.WriteLine("External user id updated for push with results: " + pushStatusDict["success"] as string);
}
}

// Verify the email is set or check that the results have an email success status
if (results.ContainsKey("email"))
{
Dictionary<string, object> emailStatusDict = results["email"] as Dictionary<string, object>;
if (emailStatusDict.ContainsKey("success"))
{
Console.WriteLine("External user id updated for email with results: " + emailStatusDict["success"] as string);
}
}
}

// Examples of using OneSignal In-App Message triggers
private void OneSignalInAppMessageTriggerExamples() {
// Add a single trigger
Expand Down Expand Up @@ -301,17 +330,13 @@ void OnGUI() {
count++;

if (GUI.Button(new Rect(itemOriginX, itemStartY + (count * itemHeightOffset), itemWidth, itemHeight), "SetExternalId", customTextSize)) {
extraMessage = "Setting External User Id";

OneSignal.SetExternalUserId(externalId);
OneSignal.SetExternalUserId(externalId, OneSignalExternalUserIdCallback);
}

count++;

if (GUI.Button(new Rect(itemOriginX, itemStartY + (count * itemHeightOffset), itemWidth, itemHeight), "RemoveExternalId", customTextSize)) {
extraMessage = "Removing External User Id";

OneSignal.RemoveExternalUserId();
OneSignal.RemoveExternalUserId(OneSignalExternalUserIdCallback);
}

if (requiresUserPrivacyConsent) {
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -432,12 +432,22 @@ void _setLocationShared(bool shared) {
[OneSignal setLocationShared:shared];
}

void _setExternalUserId(const char *externalId) {
[OneSignal setExternalUserId:CreateNSString(externalId)];
void _setExternalUserId(const char* delegate, const char *externalId) {
NSString* delegateId = CreateNSString(delegate);
[OneSignal setExternalUserId:CreateNSString(externalId) withCompletion:^(NSDictionary *results) {
NSString* response = dictionaryToNSString(results);
NSDictionary* data = @{ @"delegate_id" : delegateId, @"response" : response };
UnitySendMessage(unityListener, "onExternalUserIdUpdateCompletion", dictionaryToJsonChar(data));
}];
}

void _removeExternalUserId() {
[OneSignal removeExternalUserId];
void _removeExternalUserId(const char* delegate) {
NSString* delegateId = CreateNSString(delegate);
[OneSignal removeExternalUserId:^(NSDictionary *results) {
NSString* response = dictionaryToNSString(results);
NSDictionary* data = @{ @"delegate_id" : delegateId, @"response" : response };
UnitySendMessage(unityListener, "onExternalUserIdUpdateCompletion", dictionaryToJsonChar(data));
}];
}

void _addTriggers(char *triggers) {
Expand Down
Binary file modified OneSignalExample/Assets/OneSignal/Platforms/iOS/libOneSignal.a
Binary file not shown.
19 changes: 8 additions & 11 deletions OneSignalExample/Assets/OneSignal/src/OneSignal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -734,32 +734,30 @@ public static void SetRequiresUserPrivacyConsent(bool required) {

public static void SetExternalUserId(string externalId) {
#if ONESIGNAL_PLATFORM
oneSignalPlatform.SetExternalUserId(externalId);
string delegateGuidCompletion = OneSignalUnityUtils.GetNewGuid();
oneSignalPlatform.SetExternalUserId(delegateGuidCompletion, externalId);
#endif
}

public static void SetExternalUserId(string externalId, OnExternalUserIdUpdateCompletion completion) {
#if ONESIGNAL_PLATFORM
string delegateGuidCompletion = OneSignalUnityUtils.GetNewGuid();

delegates.Add(delegateGuidCompletion, completion);

oneSignalPlatform.SetExternalUserId(delegateGuidCompletion, externalId);
#endif
}

public static void RemoveExternalUserId() {
#if ONESIGNAL_PLATFORM
oneSignalPlatform.RemoveExternalUserId();
string delegateGuidCompletion = OneSignalUnityUtils.GetNewGuid();
oneSignalPlatform.RemoveExternalUserId(delegateGuidCompletion);
#endif
}

public static void RemoveExternalUserId(OnExternalUserIdUpdateCompletion completion) {
#if ONESIGNAL_PLATFORM
string delegateGuidCompletion = OneSignalUnityUtils.GetNewGuid();

delegates.Add(delegateGuidCompletion, completion);

oneSignalPlatform.RemoveExternalUserId(delegateGuidCompletion);
#endif
}
Expand Down Expand Up @@ -1044,15 +1042,14 @@ private void onExternalUserIdUpdateCompletion(string jsonString) {
if (!isValidDelegate(jsonObject))
return;

var delegateId = Json.Deserialize(jsonObject["delegate_id"] as string) as Dictionary<string, object>;
var delegateIdCompletion = delegateId["completion"] as string;
var delegateId = jsonObject["delegate_id"] 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);
if (delegates.ContainsKey(delegateId)) {
var externalUserIdUpdateCompletionDelegate = (OnExternalUserIdUpdateCompletion) delegates[delegateId];
delegates.Remove(delegateId);
externalUserIdUpdateCompletionDelegate(results);
}
}
Expand Down
8 changes: 0 additions & 8 deletions OneSignalExample/Assets/OneSignal/src/OneSignalAndroid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,18 +142,10 @@ public void SetRequiresUserPrivacyConsent(bool required) {
mOneSignal.Call("setRequiresUserPrivacyConsent", required);
}

public void SetExternalUserId(string externalId) {
mOneSignal.Call("setExternalUserId", externalId);
}

public void SetExternalUserId(string delegateId, string externalId) {
mOneSignal.Call("setExternalUserId", delegateId, externalId);
}

public void RemoveExternalUserId() {
mOneSignal.Call("removeExternalUserId");
}

public void RemoveExternalUserId(string delegateId) {
mOneSignal.Call("removeExternalUserId", delegateId);
}
Expand Down
14 changes: 0 additions & 14 deletions OneSignalExample/Assets/OneSignal/src/OneSignalIOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,9 @@ public class OneSignalIOS : OneSignalPlatform {
[System.Runtime.InteropServices.DllImport("__Internal")]
extern static public void _setLocationShared(bool enable);

[System.Runtime.InteropServices.DllImport("__Internal")]
extern static public void _setExternalUserId(string externalId);

[System.Runtime.InteropServices.DllImport("__Internal")]
extern static public void _setExternalUserId(string delegateId, string externalId);

[System.Runtime.InteropServices.DllImport("__Internal")]
extern static public void _removeExternalUserId();

[System.Runtime.InteropServices.DllImport("__Internal")]
extern static public void _removeExternalUserId(string delegateId);

Expand Down Expand Up @@ -269,18 +263,10 @@ public void SetRequiresUserPrivacyConsent(bool required) {
_setRequiresUserPrivacyConsent(required);
}

public void SetExternalUserId(string externalId) {
_setExternalUserId(externalId);
}

public void SetExternalUserId(string delegateId, string externalId) {
_setExternalUserId(delegateId, externalId);
}

public void RemoveExternalUserId() {
_removeExternalUserId();
}

public void RemoveExternalUserId(string delegateId) {
_removeExternalUserId(delegateId);
}
Expand Down
2 changes: 0 additions & 2 deletions OneSignalExample/Assets/OneSignal/src/OneSignalPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ public interface OneSignalPlatform {
bool UserProvidedConsent();
void SetRequiresUserPrivacyConsent(bool required);

void SetExternalUserId(string externalId);
void SetExternalUserId(string delegateId, string externalId);
void RemoveExternalUserId();
void RemoveExternalUserId(string delegateId);

void AddPermissionObserver();
Expand Down
71 changes: 55 additions & 16 deletions OneSignalExample/Assets/Plugins/Android/OneSignalConfig.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b49f59a

Please sign in to comment.