From 44c3756ab535b0a7e81ef64c6dda572805a01eae Mon Sep 17 00:00:00 2001 From: Fadi George Date: Tue, 28 Apr 2026 09:38:59 -0700 Subject: [PATCH 01/54] chore(demo): prepare demo app for Appium E2E tests --- examples/demo/.env.example | 3 + .../demo/Assets/Scripts/AppBootstrapper.cs | 22 ++- .../Assets/Scripts/Models/NotificationType.cs | 1 + .../demo/Assets/Scripts/Repositories.meta | 8 -- .../Repositories/OneSignalRepository.cs | 131 ------------------ .../Repositories/OneSignalRepository.cs.meta | 2 - .../demo/Assets/Scripts/Services/DotEnv.cs | 78 +++++++++++ .../Assets/Scripts/Services/DotEnv.cs.meta | 2 + .../Scripts/Services/OneSignalApiService.cs | 100 ++++++------- .../Scripts/Services/PreferencesService.cs | 7 - .../UI/Dialogs/CustomNotificationDialog.cs | 6 +- .../Assets/Scripts/UI/Dialogs/LoginDialog.cs | 2 +- .../Scripts/UI/Dialogs/TrackEventDialog.cs | 6 +- .../Assets/Scripts/UI/HomeScreenController.cs | 10 +- ...er.cs => CustomEventsSectionController.cs} | 8 +- .../CustomEventsSectionController.cs.meta | 2 + .../UI/Sections/InAppSectionController.cs | 2 +- .../LiveActivitiesSectionController.cs | 2 +- .../UI/Sections/PushSectionController.cs | 4 +- .../UI/Sections/SendIamSectionController.cs | 8 +- .../UI/Sections/SendPushSectionController.cs | 16 ++- .../UI/Sections/TagsSectionController.cs | 4 +- .../TrackEventSectionController.cs.meta | 2 - .../UI/Sections/TriggersSectionController.cs | 8 +- .../UI/Sections/UserSectionController.cs | 8 +- .../Assets/Scripts/ViewModels/AppViewModel.cs | 122 ++++++++-------- 26 files changed, 247 insertions(+), 317 deletions(-) delete mode 100644 examples/demo/Assets/Scripts/Repositories.meta delete mode 100644 examples/demo/Assets/Scripts/Repositories/OneSignalRepository.cs delete mode 100644 examples/demo/Assets/Scripts/Repositories/OneSignalRepository.cs.meta create mode 100644 examples/demo/Assets/Scripts/Services/DotEnv.cs create mode 100644 examples/demo/Assets/Scripts/Services/DotEnv.cs.meta rename examples/demo/Assets/Scripts/UI/Sections/{TrackEventSectionController.cs => CustomEventsSectionController.cs} (82%) create mode 100644 examples/demo/Assets/Scripts/UI/Sections/CustomEventsSectionController.cs.meta delete mode 100644 examples/demo/Assets/Scripts/UI/Sections/TrackEventSectionController.cs.meta diff --git a/examples/demo/.env.example b/examples/demo/.env.example index 674a938f..b0c98cee 100644 --- a/examples/demo/.env.example +++ b/examples/demo/.env.example @@ -1 +1,4 @@ +# Default App ID (used when ONESIGNAL_APP_ID is empty or missing): 77e32082-ea27-42e3-a898-c72e141824ef +ONESIGNAL_APP_ID=your-onesignal-app-id ONESIGNAL_API_KEY=your_rest_api_key +E2E_MODE=false diff --git a/examples/demo/Assets/Scripts/AppBootstrapper.cs b/examples/demo/Assets/Scripts/AppBootstrapper.cs index 71f68141..8204f64b 100644 --- a/examples/demo/Assets/Scripts/AppBootstrapper.cs +++ b/examples/demo/Assets/Scripts/AppBootstrapper.cs @@ -1,4 +1,3 @@ -using OneSignalDemo.Repositories; using OneSignalDemo.Services; using OneSignalDemo.ViewModels; using OneSignalSDK; @@ -12,7 +11,8 @@ namespace OneSignalDemo { public class AppBootstrapper : MonoBehaviour { - private const string OneSignalAppId = "77e32082-ea27-42e3-a898-c72e141824ef"; + private const string DefaultAppId = "77e32082-ea27-42e3-a898-c72e141824ef"; + private const string PlaceholderAppId = "your-onesignal-app-id"; private const string Tag = "AppBootstrapper"; [SerializeField] @@ -20,7 +20,6 @@ public class AppBootstrapper : MonoBehaviour private PreferencesService _prefs; private OneSignalApiService _apiService; - private OneSignalRepository _repository; private void Awake() { @@ -29,19 +28,18 @@ private void Awake() private async void Start() { + DotEnv.Load(); + _prefs = new PreferencesService(); _apiService = new OneSignalApiService(); - _repository = new OneSignalRepository(_apiService); - var appId = _prefs.AppId; - if (string.IsNullOrEmpty(appId)) - { - appId = OneSignalAppId; - _prefs.AppId = appId; - } + var envAppId = DotEnv.Get("ONESIGNAL_APP_ID"); + var appId = + string.IsNullOrWhiteSpace(envAppId) || envAppId == PlaceholderAppId + ? DefaultAppId + : envAppId; _apiService.SetAppId(appId); - _apiService.LoadApiKey(); OneSignal.Debug.LogLevel = LogLevel.Verbose; OneSignal.ConsentRequired = _prefs.ConsentRequired; @@ -63,7 +61,7 @@ private async void Start() RegisterSdkListeners(); - _viewModel.Init(_repository, _prefs); + _viewModel.Init(_prefs, _apiService); _viewModel.LoadInitialState(); await _viewModel.LoadInitialDataAsync(); diff --git a/examples/demo/Assets/Scripts/Models/NotificationType.cs b/examples/demo/Assets/Scripts/Models/NotificationType.cs index c8810a39..b760ce0e 100644 --- a/examples/demo/Assets/Scripts/Models/NotificationType.cs +++ b/examples/demo/Assets/Scripts/Models/NotificationType.cs @@ -4,6 +4,7 @@ public enum NotificationType { Simple, WithImage, + WithSound, Custom, } } diff --git a/examples/demo/Assets/Scripts/Repositories.meta b/examples/demo/Assets/Scripts/Repositories.meta deleted file mode 100644 index 5b2a5fbf..00000000 --- a/examples/demo/Assets/Scripts/Repositories.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 0068a692b631446fc90e311f87a661b9 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/examples/demo/Assets/Scripts/Repositories/OneSignalRepository.cs b/examples/demo/Assets/Scripts/Repositories/OneSignalRepository.cs deleted file mode 100644 index 82b74433..00000000 --- a/examples/demo/Assets/Scripts/Repositories/OneSignalRepository.cs +++ /dev/null @@ -1,131 +0,0 @@ -using System.Collections.Generic; -using System.Threading.Tasks; -using Newtonsoft.Json.Linq; -using OneSignalDemo.Models; -using OneSignalDemo.Services; -using OneSignalSDK; - -namespace OneSignalDemo.Repositories -{ - public class OneSignalRepository - { - private readonly OneSignalApiService _apiService; - - public OneSignalRepository(OneSignalApiService apiService) - { - _apiService = apiService; - } - - public void LoginUser(string externalUserId) => OneSignal.Login(externalUserId); - - public void LogoutUser() => OneSignal.Logout(); - - public void AddAlias(string label, string id) => OneSignal.User.AddAlias(label, id); - - public void AddAliases(Dictionary aliases) => - OneSignal.User.AddAliases(aliases); - - public void AddEmail(string email) => OneSignal.User.AddEmail(email); - - public void RemoveEmail(string email) => OneSignal.User.RemoveEmail(email); - - public void AddSms(string smsNumber) => OneSignal.User.AddSms(smsNumber); - - public void RemoveSms(string smsNumber) => OneSignal.User.RemoveSms(smsNumber); - - public void AddTag(string key, string value) => OneSignal.User.AddTag(key, value); - - public void AddTags(Dictionary tags) => OneSignal.User.AddTags(tags); - - public void RemoveTag(string key) => OneSignal.User.RemoveTag(key); - - public void RemoveTags(List keys) => OneSignal.User.RemoveTags(keys.ToArray()); - - public Dictionary GetTags() => OneSignal.User.GetTags(); - - public void AddTrigger(string key, string value) => - OneSignal.InAppMessages.AddTrigger(key, value); - - public void AddTriggers(Dictionary triggers) => - OneSignal.InAppMessages.AddTriggers(triggers); - - public void RemoveTrigger(string key) => OneSignal.InAppMessages.RemoveTrigger(key); - - public void RemoveTriggers(List keys) => - OneSignal.InAppMessages.RemoveTriggers(keys.ToArray()); - - public void ClearTriggers() => OneSignal.InAppMessages.ClearTriggers(); - - public void SendOutcome(string name) => OneSignal.Session.AddOutcome(name); - - public void SendUniqueOutcome(string name) => OneSignal.Session.AddUniqueOutcome(name); - - public void SendOutcomeWithValue(string name, float value) => - OneSignal.Session.AddOutcomeWithValue(name, value); - - public string GetPushSubscriptionId() => OneSignal.User.PushSubscription.Id; - - public bool IsPushOptedIn() => OneSignal.User.PushSubscription.OptedIn; - - public void OptInPush() => OneSignal.User.PushSubscription.OptIn(); - - public void OptOutPush() => OneSignal.User.PushSubscription.OptOut(); - - public void ClearAllNotifications() => OneSignal.Notifications.ClearAllNotifications(); - - public bool HasPermission() => OneSignal.Notifications.Permission; - - public Task RequestPermissionAsync(bool fallbackToSettings) => - OneSignal.Notifications.RequestPermissionAsync(fallbackToSettings); - - public void SetInAppMessagesPaused(bool paused) => OneSignal.InAppMessages.Paused = paused; - - public bool IsInAppMessagesPaused() => OneSignal.InAppMessages.Paused; - - public void SetLocationShared(bool shared) => OneSignal.Location.IsShared = shared; - - public bool IsLocationShared() => OneSignal.Location.IsShared; - - public void RequestLocationPermission() => OneSignal.Location.RequestPermission(); - - public void SetConsentRequired(bool required) => OneSignal.ConsentRequired = required; - - public void SetConsentGiven(bool granted) => OneSignal.ConsentGiven = granted; - - public string GetExternalId() => OneSignal.User.ExternalId; - - public string GetOnesignalId() => OneSignal.User.OneSignalId; - - public void TrackEvent(string name, Dictionary properties = null) => - OneSignal.User.TrackEvent(name, properties); - - public async Task SendNotification(NotificationType type) - { - var subId = GetPushSubscriptionId(); - return await _apiService.SendNotification(type, subId); - } - - public async Task SendCustomNotification(string title, string body) - { - var subId = GetPushSubscriptionId(); - return await _apiService.SendCustomNotification(title, body, subId); - } - - public async Task FetchUser(string onesignalId) => - await _apiService.FetchUser(onesignalId); - - public bool HasApiKey() => _apiService.HasApiKey(); - - public void StartDefaultLiveActivity( - string activityId, - IDictionary attributes, - IDictionary content - ) => OneSignal.LiveActivities.StartDefault(activityId, attributes, content); - - public async Task UpdateLiveActivity( - string activityId, - string eventType, - JObject eventUpdates = null - ) => await _apiService.UpdateLiveActivity(activityId, eventType, eventUpdates); - } -} diff --git a/examples/demo/Assets/Scripts/Repositories/OneSignalRepository.cs.meta b/examples/demo/Assets/Scripts/Repositories/OneSignalRepository.cs.meta deleted file mode 100644 index 2583b6ec..00000000 --- a/examples/demo/Assets/Scripts/Repositories/OneSignalRepository.cs.meta +++ /dev/null @@ -1,2 +0,0 @@ -fileFormatVersion: 2 -guid: af7149b19604643618be0ff85429fdf7 \ No newline at end of file diff --git a/examples/demo/Assets/Scripts/Services/DotEnv.cs b/examples/demo/Assets/Scripts/Services/DotEnv.cs new file mode 100644 index 00000000..06c68c40 --- /dev/null +++ b/examples/demo/Assets/Scripts/Services/DotEnv.cs @@ -0,0 +1,78 @@ +using System; +using System.Collections.Generic; +using System.IO; +using UnityEngine; + +namespace OneSignalDemo.Services +{ + /// Loads key/value pairs from the demo's .env file (StreamingAssets in players, project root in editor). + public static class DotEnv + { + private static readonly Dictionary _values = new(); + private static bool _loaded; + + public static void Load() + { + if (_loaded) + return; + _loaded = true; + + try + { + var content = ReadEnvContent(); + if (string.IsNullOrEmpty(content)) + return; + + foreach (var line in content.Split('\n')) + { + var trimmed = line.Trim(); + if (trimmed.Length == 0 || trimmed.StartsWith("#") || !trimmed.Contains("=")) + continue; + + var eqIndex = trimmed.IndexOf('='); + var key = trimmed.Substring(0, eqIndex).Trim(); + var value = trimmed.Substring(eqIndex + 1).Trim(); + + int commentIdx = value.IndexOf('#'); + if (commentIdx >= 0) + value = value.Substring(0, commentIdx).Trim(); + + if ( + value.Length >= 2 + && ( + (value[0] == '"' && value[value.Length - 1] == '"') + || (value[0] == '\'' && value[value.Length - 1] == '\'') + ) + ) + value = value.Substring(1, value.Length - 2); + + _values[key] = value; + } + } + catch (Exception) + { + // .env not bundled or unreadable -- keys remain empty + } + } + + public static string Get(string key) => + _values.TryGetValue(key, out var value) ? value : ""; + + public static bool IsE2EMode => + string.Equals(Get("E2E_MODE"), "true", StringComparison.OrdinalIgnoreCase); + + private static string ReadEnvContent() + { +#if UNITY_EDITOR + var editorPath = Path.Combine(Application.dataPath, "..", ".env"); + if (File.Exists(editorPath)) + return File.ReadAllText(editorPath); +#endif + var streamingPath = Path.Combine(Application.streamingAssetsPath, ".env"); + if (File.Exists(streamingPath)) + return File.ReadAllText(streamingPath); + + return null; + } + } +} diff --git a/examples/demo/Assets/Scripts/Services/DotEnv.cs.meta b/examples/demo/Assets/Scripts/Services/DotEnv.cs.meta new file mode 100644 index 00000000..478c2577 --- /dev/null +++ b/examples/demo/Assets/Scripts/Services/DotEnv.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 0fbac43cdfb045fd9aaafd0d5088a6de diff --git a/examples/demo/Assets/Scripts/Services/OneSignalApiService.cs b/examples/demo/Assets/Scripts/Services/OneSignalApiService.cs index 5ad84aad..8112c1e1 100644 --- a/examples/demo/Assets/Scripts/Services/OneSignalApiService.cs +++ b/examples/demo/Assets/Scripts/Services/OneSignalApiService.cs @@ -1,10 +1,8 @@ using System; -using System.IO; using System.Text; using System.Threading.Tasks; using Newtonsoft.Json.Linq; using OneSignalDemo.Models; -using UnityEngine; using UnityEngine.Networking; namespace OneSignalDemo.Services @@ -12,7 +10,6 @@ namespace OneSignalDemo.Services public class OneSignalApiService { private string _appId; - private string _apiKey; private const string NotificationImageUrl = "https://media.onesignal.com/automated_push_templates/ratings_template.png"; @@ -23,38 +20,13 @@ public class OneSignalApiService public string GetAppId() => _appId; - public void LoadApiKey() + public bool HasApiKey() { - var envPath = Path.Combine(Application.dataPath, "..", ".env"); -#if !UNITY_EDITOR - var streamingPath = Path.Combine(Application.streamingAssetsPath, ".env"); - if (File.Exists(streamingPath)) - envPath = streamingPath; -#endif - if (!File.Exists(envPath)) - return; - - foreach (var line in File.ReadAllLines(envPath)) - { - var trimmed = line.Trim(); - if (trimmed.StartsWith("#") || !trimmed.Contains("=")) - continue; - - var eqIndex = trimmed.IndexOf('='); - var key = trimmed.Substring(0, eqIndex).Trim(); - var value = trimmed.Substring(eqIndex + 1).Trim(); - int commentIdx = value.IndexOf('#'); - if (commentIdx >= 0) - value = value.Substring(0, commentIdx).Trim(); - value = value.Trim('"', '\''); - - if (key == "ONESIGNAL_API_KEY") - _apiKey = value; - } + var key = DotEnv.Get("ONESIGNAL_API_KEY"); + return !string.IsNullOrWhiteSpace(key) && key != PlaceholderApiKey; } - public bool HasApiKey() => - !string.IsNullOrEmpty(_apiKey) && _apiKey != PlaceholderApiKey; + private static string GetApiKey() => DotEnv.Get("ONESIGNAL_API_KEY"); public async Task SendNotification(NotificationType type, string subscriptionId) { @@ -63,6 +35,8 @@ public async Task SendNotification(NotificationType type, string subscript string title, body; + JObject extra = null; + switch (type) { case NotificationType.Simple: @@ -72,23 +46,31 @@ public async Task SendNotification(NotificationType type, string subscript case NotificationType.WithImage: title = "Image Notification"; body = "This notification includes an image"; + extra = new JObject + { + ["big_picture"] = NotificationImageUrl, + ["ios_attachments"] = new JObject { ["image"] = NotificationImageUrl }, + ["mutable_content"] = true, + }; + break; + case NotificationType.WithSound: + title = "Sound Notification"; + body = "This notification plays a custom sound"; + extra = new JObject + { + ["ios_sound"] = "vine_boom.wav", + ["android_channel_id"] = "b3b015d9-c050-4042-8548-dcc34aa44aa4", + }; break; default: return false; } - var payload = new JObject + var payload = BuildBasePayload(title, body, subscriptionId); + if (extra != null) { - ["app_id"] = _appId, - ["include_subscription_ids"] = new JArray(subscriptionId), - ["headings"] = new JObject { ["en"] = title }, - ["contents"] = new JObject { ["en"] = body }, - }; - - if (type == NotificationType.WithImage) - { - payload["big_picture"] = NotificationImageUrl; - payload["ios_attachments"] = new JObject { ["image"] = NotificationImageUrl }; + foreach (var prop in extra.Properties()) + payload[prop.Name] = prop.Value; } return await PostNotification(payload.ToString()); @@ -103,14 +85,7 @@ string subscriptionId if (string.IsNullOrEmpty(subscriptionId) || string.IsNullOrEmpty(_appId)) return false; - var payload = new JObject - { - ["app_id"] = _appId, - ["include_subscription_ids"] = new JArray(subscriptionId), - ["headings"] = new JObject { ["en"] = title }, - ["contents"] = new JObject { ["en"] = body }, - }; - + var payload = BuildBasePayload(title, body, subscriptionId); return await PostNotification(payload.ToString()); } @@ -170,18 +145,13 @@ public async Task UpdateLiveActivity( payload["event_updates"] = eventUpdates; if (eventType == "end") - { - var unixTimestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds(); - payload["dismissal_date"] = unixTimestamp; - } + payload["dismissal_date"] = DateTimeOffset.UtcNow.ToUnixTimeSeconds(); - var jsonPayload = payload.ToString(); var request = new UnityWebRequest(url, "POST"); - var bodyRaw = Encoding.UTF8.GetBytes(jsonPayload); - request.uploadHandler = new UploadHandlerRaw(bodyRaw); + request.uploadHandler = new UploadHandlerRaw(Encoding.UTF8.GetBytes(payload.ToString())); request.downloadHandler = new DownloadHandlerBuffer(); request.SetRequestHeader("Content-Type", "application/json"); - request.SetRequestHeader("Authorization", $"Key {_apiKey}"); + request.SetRequestHeader("Authorization", $"Key {GetApiKey()}"); var tcs = new TaskCompletionSource(); var operation = request.SendWebRequest(); @@ -193,11 +163,19 @@ public async Task UpdateLiveActivity( return success; } + private JObject BuildBasePayload(string title, string body, string subscriptionId) => + new() + { + ["app_id"] = _appId, + ["include_subscription_ids"] = new JArray(subscriptionId), + ["headings"] = new JObject { ["en"] = title }, + ["contents"] = new JObject { ["en"] = body }, + }; + private async Task PostNotification(string jsonPayload) { var request = new UnityWebRequest("https://onesignal.com/api/v1/notifications", "POST"); - var bodyRaw = Encoding.UTF8.GetBytes(jsonPayload); - request.uploadHandler = new UploadHandlerRaw(bodyRaw); + request.uploadHandler = new UploadHandlerRaw(Encoding.UTF8.GetBytes(jsonPayload)); request.downloadHandler = new DownloadHandlerBuffer(); request.SetRequestHeader("Content-Type", "application/json"); request.SetRequestHeader("Accept", "application/vnd.onesignal.v1+json"); diff --git a/examples/demo/Assets/Scripts/Services/PreferencesService.cs b/examples/demo/Assets/Scripts/Services/PreferencesService.cs index 405c21bc..bf77bfc4 100644 --- a/examples/demo/Assets/Scripts/Services/PreferencesService.cs +++ b/examples/demo/Assets/Scripts/Services/PreferencesService.cs @@ -4,19 +4,12 @@ namespace OneSignalDemo.Services { public class PreferencesService { - private const string KeyAppId = "onesignal_app_id"; private const string KeyConsentRequired = "consent_required"; private const string KeyPrivacyConsent = "privacy_consent"; private const string KeyExternalUserId = "external_user_id"; private const string KeyLocationShared = "location_shared"; private const string KeyIamPaused = "iam_paused"; - public string AppId - { - get => GetString(KeyAppId, ""); - set => SetString(KeyAppId, value); - } - public bool ConsentRequired { get => GetBool(KeyConsentRequired, false); diff --git a/examples/demo/Assets/Scripts/UI/Dialogs/CustomNotificationDialog.cs b/examples/demo/Assets/Scripts/UI/Dialogs/CustomNotificationDialog.cs index edbc59d2..3111e61b 100644 --- a/examples/demo/Assets/Scripts/UI/Dialogs/CustomNotificationDialog.cs +++ b/examples/demo/Assets/Scripts/UI/Dialogs/CustomNotificationDialog.cs @@ -28,7 +28,7 @@ protected override void BuildContent(VisualElement container) container.Add(titleLabel); _titleField = new TextField(); - _titleField.name = "custom_notif_title"; + _titleField.name = "custom_notification_title_input"; _titleField.AddToClassList("input-field"); _titleField.RegisterValueChangedCallback(_ => ValidateInput()); container.Add(_titleField); @@ -39,7 +39,7 @@ protected override void BuildContent(VisualElement container) container.Add(bodyLabel); _bodyField = new TextField(); - _bodyField.name = "custom_notif_body"; + _bodyField.name = "custom_notification_body_input"; _bodyField.AddToClassList("input-field"); _bodyField.RegisterValueChangedCallback(_ => ValidateInput()); container.Add(_bodyField); @@ -50,7 +50,7 @@ protected override void BuildContent(VisualElement container) actions.Add(CreateCancelButton()); _confirmButton = CreateConfirmButton("Send", OnConfirm); - _confirmButton.name = "custom_notif_confirm"; + _confirmButton.name = "custom_notification_send_button"; _confirmButton.SetEnabled(false); actions.Add(_confirmButton); diff --git a/examples/demo/Assets/Scripts/UI/Dialogs/LoginDialog.cs b/examples/demo/Assets/Scripts/UI/Dialogs/LoginDialog.cs index a8770237..65513272 100644 --- a/examples/demo/Assets/Scripts/UI/Dialogs/LoginDialog.cs +++ b/examples/demo/Assets/Scripts/UI/Dialogs/LoginDialog.cs @@ -29,7 +29,7 @@ protected override void BuildContent(VisualElement container) container.Add(label); _externalIdField = new TextField(); - _externalIdField.name = "login_external_id"; + _externalIdField.name = "login_user_id_input"; _externalIdField.AddToClassList("input-field"); _externalIdField.RegisterValueChangedCallback(_ => ValidateInput()); container.Add(_externalIdField); diff --git a/examples/demo/Assets/Scripts/UI/Dialogs/TrackEventDialog.cs b/examples/demo/Assets/Scripts/UI/Dialogs/TrackEventDialog.cs index 101707a9..b8547424 100644 --- a/examples/demo/Assets/Scripts/UI/Dialogs/TrackEventDialog.cs +++ b/examples/demo/Assets/Scripts/UI/Dialogs/TrackEventDialog.cs @@ -32,7 +32,7 @@ protected override void BuildContent(VisualElement container) container.Add(nameLabel); _nameField = new TextField(); - _nameField.name = "event_name"; + _nameField.name = "event_name_input"; _nameField.AddToClassList("input-field"); _nameField.RegisterValueChangedCallback(_ => ValidateInput()); container.Add(_nameField); @@ -43,7 +43,7 @@ protected override void BuildContent(VisualElement container) container.Add(propsLabel); _propertiesField = new TextField(); - _propertiesField.name = "event_properties"; + _propertiesField.name = "event_properties_input"; _propertiesField.AddToClassList("input-field"); _propertiesField.textEdition.placeholder = "{\"key\": \"value\"}"; _propertiesField.RegisterValueChangedCallback(_ => ValidateInput()); @@ -60,7 +60,7 @@ protected override void BuildContent(VisualElement container) actions.Add(CreateCancelButton()); _confirmButton = CreateConfirmButton("Track", OnConfirm); - _confirmButton.name = "event_confirm_button"; + _confirmButton.name = "event_track_button"; _confirmButton.SetEnabled(false); actions.Add(_confirmButton); diff --git a/examples/demo/Assets/Scripts/UI/HomeScreenController.cs b/examples/demo/Assets/Scripts/UI/HomeScreenController.cs index 80b23bca..5f10f601 100644 --- a/examples/demo/Assets/Scripts/UI/HomeScreenController.cs +++ b/examples/demo/Assets/Scripts/UI/HomeScreenController.cs @@ -39,7 +39,7 @@ public class HomeScreenController : MonoBehaviour private TagsSectionController _tagsSection; private OutcomesSectionController _outcomesSection; private TriggersSectionController _triggersSection; - private TrackEventSectionController _trackEventSection; + private CustomEventsSectionController _customEventsSection; private LocationSectionController _locationSection; private LiveActivitiesSectionController _liveActivitiesSection; @@ -246,10 +246,10 @@ private void BuildSections() _triggersSection.OnRemoveSelectedTap = ShowRemoveSelectedTriggersDialog; _contentRoot.Add(_triggersSection.Root); - _trackEventSection = new TrackEventSectionController(_viewModel); - _trackEventSection.OnInfoTap = () => ShowTooltip("trackEvent"); - _trackEventSection.OnTrackEventTap = ShowTrackEventDialog; - _contentRoot.Add(_trackEventSection.Root); + _customEventsSection = new CustomEventsSectionController(_viewModel); + _customEventsSection.OnInfoTap = () => ShowTooltip("customEvents"); + _customEventsSection.OnTrackEventTap = ShowTrackEventDialog; + _contentRoot.Add(_customEventsSection.Root); _locationSection = new LocationSectionController(_viewModel); _locationSection.OnInfoTap = () => ShowTooltip("location"); diff --git a/examples/demo/Assets/Scripts/UI/Sections/TrackEventSectionController.cs b/examples/demo/Assets/Scripts/UI/Sections/CustomEventsSectionController.cs similarity index 82% rename from examples/demo/Assets/Scripts/UI/Sections/TrackEventSectionController.cs rename to examples/demo/Assets/Scripts/UI/Sections/CustomEventsSectionController.cs index 0aad14fd..6a82241d 100644 --- a/examples/demo/Assets/Scripts/UI/Sections/TrackEventSectionController.cs +++ b/examples/demo/Assets/Scripts/UI/Sections/CustomEventsSectionController.cs @@ -4,7 +4,7 @@ namespace OneSignalDemo.UI.Sections { - public class TrackEventSectionController + public class CustomEventsSectionController { private readonly AppViewModel _viewModel; private readonly VisualElement _root; @@ -12,7 +12,7 @@ public class TrackEventSectionController public Action OnInfoTap; public Action OnTrackEventTap; - public TrackEventSectionController(AppViewModel viewModel) + public CustomEventsSectionController(AppViewModel viewModel) { _viewModel = viewModel; _root = BuildSection(); @@ -23,8 +23,8 @@ public TrackEventSectionController(AppViewModel viewModel) private VisualElement BuildSection() { var section = SectionBuilder.CreateSection( - "Track Event", - "track_event_section", + "Custom Events", + "custom_events_section", () => OnInfoTap?.Invoke() ); diff --git a/examples/demo/Assets/Scripts/UI/Sections/CustomEventsSectionController.cs.meta b/examples/demo/Assets/Scripts/UI/Sections/CustomEventsSectionController.cs.meta new file mode 100644 index 00000000..18e004d4 --- /dev/null +++ b/examples/demo/Assets/Scripts/UI/Sections/CustomEventsSectionController.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 1e85e0f98a331481a88a6a6ff46a9f7a diff --git a/examples/demo/Assets/Scripts/UI/Sections/InAppSectionController.cs b/examples/demo/Assets/Scripts/UI/Sections/InAppSectionController.cs index ee8d1487..b9dfc443 100644 --- a/examples/demo/Assets/Scripts/UI/Sections/InAppSectionController.cs +++ b/examples/demo/Assets/Scripts/UI/Sections/InAppSectionController.cs @@ -33,7 +33,7 @@ private VisualElement BuildSection() var toggleRow = SectionBuilder.CreateToggleRow( "Pause In-App Messages", "Toggle in-app message display", - "iam_paused_toggle", + "pause_iam_toggle", _viewModel.InAppMessagesPaused, OnPauseChanged ); diff --git a/examples/demo/Assets/Scripts/UI/Sections/LiveActivitiesSectionController.cs b/examples/demo/Assets/Scripts/UI/Sections/LiveActivitiesSectionController.cs index 00413d6d..201970cb 100644 --- a/examples/demo/Assets/Scripts/UI/Sections/LiveActivitiesSectionController.cs +++ b/examples/demo/Assets/Scripts/UI/Sections/LiveActivitiesSectionController.cs @@ -48,7 +48,7 @@ private VisualElement BuildSection() var orderNumberRow = CreateInlineInputRow( "Order #", "ORD-1234", - "live_activity_order_input" + "live_activity_order_number_input" ); _orderNumberField = orderNumberRow.Q(); inputCard.Add(orderNumberRow); diff --git a/examples/demo/Assets/Scripts/UI/Sections/PushSectionController.cs b/examples/demo/Assets/Scripts/UI/Sections/PushSectionController.cs index d21628aa..4c9234bc 100644 --- a/examples/demo/Assets/Scripts/UI/Sections/PushSectionController.cs +++ b/examples/demo/Assets/Scripts/UI/Sections/PushSectionController.cs @@ -36,9 +36,9 @@ private VisualElement BuildSection() var pushIdRow = SectionBuilder.CreateInlineKeyValue( "Push ID", _viewModel.PushSubscriptionId ?? "\u2013", - "push_subscription_id" + "push_id" ); - _pushIdLabel = pushIdRow.Q