diff --git a/.cursor/rules/pr-conventions.mdc b/.cursor/rules/pr-conventions.mdc new file mode 100644 index 000000000..cd953b179 --- /dev/null +++ b/.cursor/rules/pr-conventions.mdc @@ -0,0 +1,32 @@ +--- +description: Conventions for pull request titles and body content +alwaysApply: true +--- + +# Pull Request Conventions + +## PR Title + +Use semantic/conventional commit prefixes in PR titles: + +- `fix:` for bug fixes +- `feat:` for new features +- `chore:` for maintenance tasks (deps, CI, tooling) +- `refactor:` for code restructuring without behavior changes +- `docs:` for documentation-only changes +- `test:` for test-only changes + +Example: `fix: resolve notification grouping on Android 14` + +## PR Body + +Follow the repo's PR template at `.github/pull_request_template.md`. Every PR body must include: + +1. **One Line Summary** (required) +2. **Motivation** (required) explaining why the change is being made +3. **Scope** (recommended) describing what is and isn't affected +4. **Testing** section with manual and/or unit testing details +5. **Affected code checklist** with relevant items checked +6. **Checklist** sections confirmed + +Remove the instructional header block (between `` and ``) before submitting. diff --git a/com.onesignal.unity.android/Runtime/OneSignalAndroid.cs b/com.onesignal.unity.android/Runtime/OneSignalAndroid.cs index 925569cca..25665873c 100644 --- a/com.onesignal.unity.android/Runtime/OneSignalAndroid.cs +++ b/com.onesignal.unity.android/Runtime/OneSignalAndroid.cs @@ -133,6 +133,8 @@ public override void Initialize(string appId) var unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); var activity = unityPlayer.GetStatic("currentActivity"); + _enableHardwareAcceleration(activity); + _sdkWrapperClass.CallStatic("setSdkType", "unity"); _sdkWrapperClass.CallStatic("setSdkVersion", VersionHeader); @@ -174,6 +176,27 @@ public override void Initialize(string appId) _completedInit(appId); } + /// + /// Unity sets android:hardwareAccelerated="false" on its Activity which + /// prevents WebView transparent backgrounds from rendering. The native SDK + /// displays in-app messages via a PopupWindow whose window inherits this + /// setting, causing the IAM to render with an opaque white background. + /// Enabling the flag at the window level restores transparency without + /// affecting Unity's own GL/Vulkan rendering surface. + /// + private static void _enableHardwareAcceleration(AndroidJavaObject activity) + { + activity.Call( + "runOnUiThread", + new AndroidJavaRunnable(() => + { + const int FLAG_HARDWARE_ACCELERATED = 0x01000000; + using var window = activity.Call("getWindow"); + window.Call("setFlags", FLAG_HARDWARE_ACCELERATED, FLAG_HARDWARE_ACCELERATED); + }) + ); + } + public override void Login(string externalId, string jwtBearerToken = null) { _sdkClass.CallStatic("login", externalId, jwtBearerToken); diff --git a/examples/demo/README.md b/examples/demo/README.md index 3296079a9..48501c69a 100644 --- a/examples/demo/README.md +++ b/examples/demo/README.md @@ -1,9 +1,25 @@ -# Testing on Example App +# Testing on the Demo App First try to use a more recent Unity version for testing on the emulators. ![Unity Version](docs/unity-version.png) +## Command Line + +You can build and install without opening the Unity editor by using the provided scripts. Have an emulator/simulator booted first, then run: + +```sh +# Android — builds APK and installs on a running emulator +./run-android.sh + +# iOS — generates Xcode project, builds, and installs on a booted simulator +./run-ios.sh +``` + +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 Editor + ### Android Check your build profiles and make sure Android platform is selected. @@ -20,6 +36,6 @@ Check your build profiles and make sure iOS platform is selected. Then configure your play settings and set `Target SDK` to `Simulator SDK` ![iOS Example 1](docs/ios-example-1.png) -Then click `Build and Run` and select a location for the apk bundle. Or click `Build` to use own simualtor. +Then click `Build and Run` and select a location for the apk bundle. Or click `Build` to use own simulator. ![iOS Example 1](docs/ios-example-2.png) diff --git a/examples/demo/build_android.sh b/examples/demo/run-android.sh similarity index 98% rename from examples/demo/build_android.sh rename to examples/demo/run-android.sh index 9e9e4cc67..5e90e6951 100755 --- a/examples/demo/build_android.sh +++ b/examples/demo/run-android.sh @@ -9,7 +9,7 @@ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" UNITY="${UNITY_PATH:-/Applications/Unity/Hub/Editor/6000.3.6f1/Unity.app/Contents/MacOS/Unity}" ADB="/Applications/Unity/Hub/Editor/6000.3.6f1/PlaybackEngines/AndroidPlayer/SDK/platform-tools/adb" OUTPUT="$SCRIPT_DIR/Build/Android/onesignal-demo.apk" -LOG="$SCRIPT_DIR/Build/build.log" +LOG="$SCRIPT_DIR/Build/build-android.log" INSTALL=true SKIP_BUILD=false diff --git a/examples/demo/build_ios.sh b/examples/demo/run-ios.sh similarity index 99% rename from examples/demo/build_ios.sh rename to examples/demo/run-ios.sh index 9f8ae267d..84864207c 100755 --- a/examples/demo/build_ios.sh +++ b/examples/demo/run-ios.sh @@ -8,7 +8,7 @@ set -eu SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" UNITY="${UNITY_PATH:-/Applications/Unity/Hub/Editor/6000.3.6f1/Unity.app/Contents/MacOS/Unity}" XCODE_DIR="$SCRIPT_DIR/Build/iOS" -LOG="$SCRIPT_DIR/Build/build.log" +LOG="$SCRIPT_DIR/Build/build-ios.log" SCHEME="Unity-iPhone" DERIVED="$SCRIPT_DIR/Build/iOS-DerivedData" APP_BUNDLE_ID="com.onesignal.example"