Skip to content
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
OneSignalExample/.idea/

.DS_Store
.gradle/
11 changes: 11 additions & 0 deletions OneSignalExample/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
#
# Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore
#
/.utmp/
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
/[Ll]ogs/
/[Mm]emoryCaptures/
/UserSettings/

# Asset meta data should only be ignored when the corresponding asset is also ignored
!/[Aa]ssets/**/*.meta
Expand Down Expand Up @@ -58,3 +60,12 @@ sysinfo.txt
# Crashlytics generated file
crashlytics-build.properties

# User-specific Unity Editor settings
/[Uu]serSettings/

# Gradle template backup files
*.backup
*.backup.meta
*.backup2
*.backup2.meta

Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,58 @@ public void GetTags()
_log($"Get all user tags " + dictionaryString.TrimEnd(',', ' ') + "}");
}

public void TrackEvent()
{
// Detect platform
string platform =
Application.platform == RuntimePlatform.Android ? "android"
: Application.platform == RuntimePlatform.IPhonePlayer ? "ios"
: "unknown";

// Track event without properties
_log($"Tracking an event <b>Unity-{platform}-noprops</b> without properties");
OneSignal.User.TrackEvent($"Unity-{platform}-noprops");

// Track event with comprehensive properties
var properties = new Dictionary<string, object>
{
{ "someNum", 123 },
{ "someFloat", 3.14159f },
{ "someString", "abc" },
{ "someBool", true },
{
"someObject",
new Dictionary<string, object>
{
{ "abc", "123" },
{
"nested",
new Dictionary<string, object> { { "def", "456" } }
},
}
},
{
"someArray",
new List<object> { 1, 2 }
},
{
"someMixedArray",
new List<object>
{
1,
"2",
new Dictionary<string, object> { { "abc", "123" } },
}
},
{ "someNull", null },
};

_log(
$"Tracking an event <b>Unity-{platform}</b> with properties: {Json.Serialize(properties)}"
);
OneSignal.User.TrackEvent($"Unity-{platform}", properties);
}

/*
* Outcomes
*/
Expand Down
Loading
Loading