Skip to content
Open
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
36 changes: 31 additions & 5 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,19 @@ jobs:
onesignal-app-id: ${{ vars.APPIUM_ONESIGNAL_APP_ID }}
onesignal-api-key: ${{ secrets.APPIUM_ONESIGNAL_API_KEY }}

- name: Enable E2E accessibility
run: |
python3 - <<'PY'
import json
from pathlib import Path

path = Path("examples/demo/Packages/manifest.json")
manifest = json.loads(path.read_text())
manifest["dependencies"]["com.unity.modules.accessibility"] = "1.0.0"
path.write_text(json.dumps(manifest, indent=2) + "\n")
PY
printf '%s\n' '-define:ONESIGNAL_E2E_ACCESSIBILITY' > examples/demo/Assets/csc.rsp

- name: Resolve OneSignal Android SDK version
id: android-sdk-version
run: |
Expand All @@ -61,7 +74,7 @@ jobs:
uses: actions/cache@v5
with:
path: examples/demo/Library
key: unity-library-android-${{ hashFiles('examples/demo/Packages/manifest.json', 'examples/demo/ProjectSettings/ProjectVersion.txt') }}
key: unity-library-android-${{ hashFiles('examples/demo/Packages/manifest.json', 'examples/demo/Assets/csc.rsp', 'examples/demo/ProjectSettings/ProjectVersion.txt') }}
restore-keys: unity-library-android-

- name: Build APK
Expand All @@ -72,7 +85,7 @@ jobs:
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
with:
projectPath: examples/demo
unityVersion: auto
unityVersion: 6000.4.11f1
targetPlatform: Android
buildMethod: BuildScript.BuildAndroidEmulator
allowDirtyBuild: true
Expand Down Expand Up @@ -108,11 +121,24 @@ jobs:
onesignal-app-id: ${{ vars.APPIUM_ONESIGNAL_APP_ID }}
onesignal-api-key: ${{ secrets.APPIUM_ONESIGNAL_API_KEY }}

- name: Enable E2E accessibility
run: |
python3 - <<'PY'
import json
from pathlib import Path

path = Path("examples/demo/Packages/manifest.json")
manifest = json.loads(path.read_text())
manifest["dependencies"]["com.unity.modules.accessibility"] = "1.0.0"
path.write_text(json.dumps(manifest, indent=2) + "\n")
PY
printf '%s\n' '-define:ONESIGNAL_E2E_ACCESSIBILITY' > examples/demo/Assets/csc.rsp

- name: Cache Unity Library
uses: actions/cache@v5
with:
path: examples/demo/Library
key: unity-library-ios-${{ hashFiles('examples/demo/Packages/manifest.json', 'examples/demo/ProjectSettings/ProjectVersion.txt') }}
key: unity-library-ios-${{ hashFiles('examples/demo/Packages/manifest.json', 'examples/demo/Assets/csc.rsp', 'examples/demo/ProjectSettings/ProjectVersion.txt') }}
restore-keys: unity-library-ios-

- name: Cache Xcode DerivedData
Expand All @@ -123,7 +149,7 @@ jobs:
uses: actions/cache@v5
with:
path: examples/demo/Build/iOS-DerivedData
key: deriveddata-${{ runner.os }}-${{ hashFiles('examples/demo/Packages/manifest.json', 'examples/demo/ProjectSettings/ProjectVersion.txt', 'examples/demo/ProjectSettings/ProjectSettings.asset', 'com.onesignal.unity.ios/Editor/**', 'com.onesignal.unity.core/Editor/**', 'examples/demo/iOS/ExportOptions.plist') }}
key: deriveddata-${{ runner.os }}-${{ hashFiles('examples/demo/Packages/manifest.json', 'examples/demo/Assets/csc.rsp', 'examples/demo/ProjectSettings/ProjectVersion.txt', 'examples/demo/ProjectSettings/ProjectSettings.asset', 'com.onesignal.unity.ios/Editor/**', 'com.onesignal.unity.core/Editor/**', 'examples/demo/iOS/ExportOptions.plist') }}
restore-keys: deriveddata-${{ runner.os }}-

- name: Export Xcode project from Unity
Expand All @@ -134,7 +160,7 @@ jobs:
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
with:
projectPath: examples/demo
unityVersion: auto
unityVersion: 6000.4.11f1
targetPlatform: iOS
buildMethod: BuildScript.BuildiOSDevice
allowDirtyBuild: true
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ And via many additional platforms. [Check them all out](https://documentation.on
## Requirements
- A [OneSignal Account](https://app.onesignal.com/signup) if you do not already have one
- Your OneSignal App ID which you can find under **Settings > Keys & IDs**
- Unity 2021.3 or newer
- Unity 2022.3 or newer
- Android Builds: Target API Level 33 or higher
- iOS Builds: CocoaPods 1.11.3 or newer
- In order to test push notifications you will need
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ internal static class OneSignalAndroidDependencies
{
static OneSignalAndroidDependencies()
{
if (AssetDatabase.IsAssetImportWorkerProcess())
return;

OneSignalSDKSettings.Changed += WriteDependencies;
WriteDependencies();
}
Expand Down
3 changes: 3 additions & 0 deletions com.onesignal.unity.ios/Editor/OneSignaliOSDependencies.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ internal static class OneSignaliOSDependencies
{
static OneSignaliOSDependencies()
{
if (AssetDatabase.IsAssetImportWorkerProcess())
return;

OneSignalSDK.OneSignalSDKSettings.Changed += WriteDependencies;
WriteDependencies();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ internal sealed class OneSignalFileInventory : ScriptableObject
public static string[] GetCurrentPaths() =>
ConvertPathsToUnix(
Directory.GetFiles(PackageAssetsPath, "*", SearchOption.AllDirectories)
);
)
.Except(GeneratedDependencyPaths)
.ToArray();

/// <summary>
/// Makes sure <see cref="paths"/> are using forward slash to be Unix compatible.
Expand Down Expand Up @@ -75,5 +77,22 @@ public static string[] ConvertPathsToUnix(string[] paths)
"Resources"
);
public static readonly string AssetPath = Path.Combine(EditorResourcesPath, AssetName);
private static readonly string[] GeneratedDependencyPaths = ConvertPathsToUnix(
new[]
{
Path.Combine(
PackageAssetsPath,
"Editor",
"OneSignalAndroidDependencies.xml"
),
Path.Combine(
PackageAssetsPath,
"Editor",
"OneSignalAndroidDependencies.xml.meta"
),
Path.Combine(PackageAssetsPath, "Editor", "OneSignaliOSDependencies.xml"),
Path.Combine(PackageAssetsPath, "Editor", "OneSignaliOSDependencies.xml.meta"),
}
);
}
}
2 changes: 1 addition & 1 deletion examples/demo/Assets/OneSignal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ And via many additional platforms. [Check them all out](https://documentation.on
## Requirements
- A [OneSignal Account](https://app.onesignal.com/signup) if you do not already have one
- Your OneSignal App ID which you can find under **Settings > Keys & IDs**
- Unity 2021.3 or newer
- Unity 2022.3 or newer
- Android Builds: Target API Level 33 or higher
- iOS Builds: CocoaPods 1.11.3 or newer
- In order to test push notifications you will need
Expand Down
16 changes: 16 additions & 0 deletions examples/demo/Assets/Scripts/Services/AccessibilityBridge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
using System.Globalization;
using System.Reflection;
using UnityEngine;
#if UNITY_2023_2_OR_NEWER && ONESIGNAL_E2E_ACCESSIBILITY
using UnityEngine.Accessibility;
#endif
using UnityEngine.UIElements;

namespace OneSignalDemo.Services
Expand All @@ -15,6 +17,7 @@ namespace OneSignalDemo.Services
/// </summary>
public class AccessibilityBridge : MonoBehaviour
{
#if UNITY_2023_2_OR_NEWER && ONESIGNAL_E2E_ACCESSIBILITY
// GeometryChangedEvent is the hot path; this tick catches drift from sources that
// don't raise it (animation curves, opacity tweens, value mutations).
private const float FrameRefreshIntervalSeconds = 0.05f;
Expand Down Expand Up @@ -912,6 +915,19 @@ public IosInfoTap(Func<bool> isEnabled, Action action)
Action = action;
}
}
#endif
#else
public static void EnableForE2E(VisualElement root) { }

public static void RegisterE2ETapTarget(
VisualElement target,
Func<bool> isEnabled,
Action action
) { }

public static void RequestResync() { }

public static void RequestImmediateResync() { }
#endif
}
}
9 changes: 8 additions & 1 deletion examples/demo/Assets/Scripts/UI/Dialogs/DialogBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,17 @@ protected TextField CreateTextField(string label, string name, string placeholde
field.name = name;
field.AddToClassList("input-field");
if (!string.IsNullOrEmpty(placeholder))
field.textEdition.placeholder = placeholder;
SetPlaceholder(field, placeholder);
return field;
}

protected static void SetPlaceholder(TextField field, string placeholder)
{
#if UNITY_2023_1_OR_NEWER
field.textEdition.placeholder = placeholder;
#endif
}

protected Button CreateConfirmButton(string text, Action onClick)
{
var btn = new Button(onClick);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@ private void AddRow()
keyField.name = $"multipair_key_{rowIndex}";
keyField.AddToClassList("input-field");
keyField.AddToClassList("dialog-field-group-left");
keyField.textEdition.placeholder = _keyLabel;
SetPlaceholder(keyField, _keyLabel);
keyField.RegisterValueChangedCallback(_ => ValidateAll());

var valueField = new TextField();
valueField.name = $"multipair_value_{rowIndex}";
valueField.AddToClassList("input-field");
valueField.AddToClassList("dialog-field-group");
valueField.textEdition.placeholder = _valueLabel;
SetPlaceholder(valueField, _valueLabel);
valueField.RegisterValueChangedCallback(_ => ValidateAll());

row.Add(keyField);
Expand Down
4 changes: 2 additions & 2 deletions examples/demo/Assets/Scripts/UI/Dialogs/OutcomeDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ protected override void BuildContent(VisualElement container)
_nameField = new TextField();
_nameField.name = "outcome_name_input";
_nameField.AddToClassList("input-field");
_nameField.textEdition.placeholder = "Outcome Name";
SetPlaceholder(_nameField, "Outcome Name");
_nameField.RegisterValueChangedCallback(_ => ValidateInput());
container.Add(_nameField);

Expand All @@ -74,7 +74,7 @@ protected override void BuildContent(VisualElement container)
_valueField = new TextField();
_valueField.name = "outcome_value_input";
_valueField.AddToClassList("input-field");
_valueField.textEdition.placeholder = "Value";
SetPlaceholder(_valueField, "Value");
_valueField.RegisterValueChangedCallback(_ => ValidateInput());
_valueContainer.Add(_valueField);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected override void BuildContent(VisualElement container)
_propertiesField = new TextField();
_propertiesField.name = "event_properties_input";
_propertiesField.AddToClassList("input-field");
_propertiesField.textEdition.placeholder = "{\"key\": \"value\"}";
SetPlaceholder(_propertiesField, "{\"key\": \"value\"}");
_propertiesField.RegisterValueChangedCallback(_ => ValidateInput());
container.Add(_propertiesField);

Expand Down
1 change: 0 additions & 1 deletion examples/demo/Packages/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"com.onesignal.unity.core": "file:../../../com.onesignal.unity.core",
"com.onesignal.unity.ios": "file:../../../com.onesignal.unity.ios",
"com.unity.nuget.newtonsoft-json": "3.2.2",
"com.unity.modules.accessibility": "1.0.0",
"com.unity.modules.androidjni": "1.0.0",
"com.unity.modules.uielements": "1.0.0",
"com.unity.modules.unitywebrequest": "1.0.0"
Expand Down
6 changes: 0 additions & 6 deletions examples/demo/Packages/packages-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.modules.accessibility": {
"version": "1.0.0",
"depth": 0,
"source": "builtin",
"dependencies": {}
},
"com.unity.modules.androidjni": {
"version": "1.0.0",
"depth": 0,
Expand Down
4 changes: 4 additions & 0 deletions examples/demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ You can build and install without opening the Unity editor by using the provided

Both scripts accept `--no-install` to build only, `--install-only` to skip rebuilding, and `run-ios.sh` also supports `--open` to open the generated Xcode workspace. Set `UNITY_PATH` if Unity is not at the default location.

### Unity versions

The demo can be opened directly in Unity 2022.3 or Unity 6. The E2E workflow enables Unity 6's Accessibility module only for automated builds because that module is not available in Unity 2022.3.

## Clean Generated State

Use `clean.sh` when you want to retest setup from the Unity Editor or clear build artifacts before switching between dependency configurations:
Expand Down