Skip to content

Commit

Permalink
Refresh SDK samples from example project (#739)
Browse files Browse the repository at this point in the history
  • Loading branch information
brismithers authored Jun 5, 2024
1 parent 4b4951b commit d5650a4
Show file tree
Hide file tree
Showing 2 changed files with 2,550 additions and 283 deletions.
27 changes: 24 additions & 3 deletions com.onesignal.unity.core/Samples~/OneSignalExampleBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
using OneSignalSDK;
using OneSignalSDK.Notifications;
using OneSignalSDK.InAppMessages;
using OneSignalSDK.User;
using OneSignalSDK.User.Models;
using OneSignalSDK.Debug.Models;
using OneSignalSDK.Debug.Utilities;
Expand Down Expand Up @@ -145,7 +146,7 @@ public class OneSignalExampleBehaviour : MonoBehaviour {
/// </summary>
private void Start() {
// Enable lines below to debug issues with OneSignal
OneSignal.Debug.LogLevel = LogLevel.Info;
OneSignal.Debug.LogLevel = LogLevel.Verbose;
OneSignal.Debug.AlertLevel = LogLevel.Fatal;

_log($"Initializing with appId <b>{appId}</b>");
Expand Down Expand Up @@ -226,8 +227,8 @@ private void _pushSubscriptionChanged(object sender, PushSubscriptionChangedEven
}

private void _userStateChanged(object sender, UserStateChangedEventArgs e) {
_log($"OneSignalId changed : {JsonUtility.ToJson(e.State.Current.OneSignalId)}");
_log($"ExternalId changed : {JsonUtility.ToJson(e.State.Current.ExternalId)}");
_log($"OneSignalId changed : {e.State.Current.OneSignalId}");
_log($"ExternalId changed : {e.State.Current.ExternalId}");
}

/*
Expand Down Expand Up @@ -317,6 +318,16 @@ public void RemoveAlias() {
OneSignal.User.RemoveAlias(aliasKey);
}

public void GetOneSignalId() {
string onesignalId = OneSignal.User.OneSignalId ?? "null";
_log($"Get OneSignalId <b>{onesignalId}</b>");
}

public void GetExternalId() {
string externalId = OneSignal.User.ExternalId ?? "null";
_log($"Get ExternalId <b>{externalId}</b>");
}

/*
* Push
*/
Expand Down Expand Up @@ -390,6 +401,16 @@ public void AddTag() {
public void RemoveTag() {
_log($"Removing tag for key <b>{tagKey}</b>");
OneSignal.User.RemoveTag(tagKey);

}

public void GetTags() {
Dictionary<string, string> dict = OneSignal.User.GetTags();
string dictionaryString = "{";
foreach(KeyValuePair <string, string> keyValues in dict) {
dictionaryString += keyValues.Key + " : " + keyValues.Value + ", ";
}
_log($"Get all user tags " + dictionaryString.TrimEnd(',', ' ') + "}");
}

/*
Expand Down
Loading

0 comments on commit d5650a4

Please sign in to comment.