Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refresh SDK samples from example project #739

Merged
merged 2 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions com.onesignal.unity.core/Samples~/OneSignalExampleBehaviour.cs
shepherd-l marked this conversation as resolved.
Show resolved Hide resolved
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
Loading