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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
dotnet-version: "8.0.x"

- name: Install CSharpier
run: dotnet tool install -g csharpier
run: dotnet tool restore

- name: Check formatting
run: csharpier check .
run: dotnet csharpier check .

- name: Validate Unity distribution layout
run: python3 .github/scripts/validate-unity-distribution.py
10 changes: 7 additions & 3 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ jobs:
# `pod install` an Unity-iPhone.xcworkspace exists and must be used;
# without CocoaPods we fall back to the .xcodeproj. The
# SigningPostProcessor already pinned DEVELOPMENT_TEAM and the NSE /
# Live Activity bundle IDs to match ExportOptions.plist.
# Live Activity bundle IDs to match ExportOptions.plist. CI only has the
# in-house distribution cert, so the identity and team are also pinned
# here for targets the post-processor skips (UnityFramework, Pods).
run: |
if [ -d Unity-iPhone.xcworkspace ]; then
CONTAINER_ARGS=(-workspace Unity-iPhone.xcworkspace)
Expand All @@ -206,6 +208,8 @@ jobs:
-quiet \
-hideShellScriptEnvironment \
CODE_SIGN_STYLE=Manual \
CODE_SIGN_IDENTITY="iPhone Distribution" \
DEVELOPMENT_TEAM=DL8TF3X4K3 \
COMPILER_INDEX_STORE_ENABLE=NO
xcodebuild -exportArchive \
-archivePath build/App.xcarchive \
Expand All @@ -231,8 +235,8 @@ jobs:
unzip -oq demo.ipa -d /tmp/ipa
APP=$(ls -d /tmp/ipa/Payload/*.app | head -n1)
codesign -d --entitlements - "$APP" 2>&1 | tee /tmp/entitlements.txt
if ! grep -q 'aps-environment' /tmp/entitlements.txt; then
echo "::error::Built IPA is missing aps-environment entitlement; push subscription will not work"
if ! grep -A2 'aps-environment' /tmp/entitlements.txt | grep -q 'production'; then
echo "::error::Built IPA needs aps-environment=production for the In House profile"
exit 1
fi

Expand Down
13 changes: 13 additions & 0 deletions dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version": 1,
"isRoot": true,
"tools": {
"csharpier": {
"version": "1.3.0",
"commands": [
"csharpier"
],
"rollForward": false
}
}
}
2 changes: 1 addition & 1 deletion examples/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ In `AppViewModel.LoadInitialState()` (`AppViewModel.cs` lines ~110-122), UI stat
- `AppBootstrapper.Start()` calls `DotEnv.Load()` BEFORE `OneSignal.Initialize`. There is no default App ID: `CopyEnvPreBuild` fails the build when `ONESIGNAL_APP_ID` is missing from `.env`, and `AppBootstrapper` throws if it is empty at runtime.

### Android package and Firebase
- Android package is `com.onesignal.sdkdemo`; iOS bundle ID stays `com.onesignal.example`.
- Android package and iOS bundle ID are `com.onesignal.sdkdemo`.
- `mainTemplate.gradle` depends on `com.google.firebase:firebase-messaging:25.1.3`.
- `google-services.json` lives in the project root and is gitignored. `FirebaseInstallationIdBuild` copies it into the generated `launcher/` module, where `launcherTemplate.gradle` applies the Google Services plugin only when the file exists (`baseProjectTemplate.gradle` declares the plugin version).
- The `firebase_messaging_installation_id_enabled` meta-data in `Assets/Plugins/Android/AndroidManifest.xml` defaults to `false`. The `FIREBASE_INSTALLATION_ID_ENABLED` scripting define (set in `Assets/csc.rsp` by E2E) flips it to `true` and fails the build if `google-services.json` is missing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ PlayerSettings:
androidMinAspectRatio: 1
applicationIdentifier:
Android: com.onesignal.sdkdemo
iPhone: com.onesignal.example
iPhone: com.onesignal.sdkdemo
buildNumber:
Standalone: 0
VisionOS: 0
Expand Down
2 changes: 1 addition & 1 deletion examples/demo-no-location/run-ios.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ XCODE_DIR="$SCRIPT_DIR/Build/iOS"
LOG="$SCRIPT_DIR/Build/build-ios.log"
SCHEME="Unity-iPhone"
DERIVED="$SCRIPT_DIR/Build/iOS-DerivedData"
APP_BUNDLE_ID="com.onesignal.example"
APP_BUNDLE_ID="com.onesignal.sdkdemo"
INSTALL=true
SKIP_BUILD=false
OPEN_XCODE=false
Expand Down
24 changes: 14 additions & 10 deletions examples/demo/Assets/App/Editor/iOS/SigningPostProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ namespace App.Editor.iOS
/// <summary>
/// Final iOS post-processor for the demo app. Runs AFTER the OneSignal
/// SDK and demo widget post-processors so it can correct things they set:
/// flips aps-environment to "development", normalizes extension bundle
/// sets aps-environment (production for CI's In House profiles, development
/// otherwise), normalizes extension bundle
/// IDs, pins DEVELOPMENT_TEAM on every target, and (in CI only) switches
/// signing to Manual with the OneSignal-owned Appium provisioning
/// profiles so xcodebuild archive can sign the IPA unattended.
/// </summary>
public class SigningPostProcessor : IPostprocessBuildWithReport
{
private const string AppleTeamId = "99SW8E36CT";
private const string ApsEnvironment = "development";
private const string AppleTeamId = "DL8TF3X4K3";

private const string NseTargetName = "OneSignalNotificationServiceExtension";
private const string WidgetTargetName = "OneSignalWidgetExtension";
Expand All @@ -30,16 +30,18 @@ public class SigningPostProcessor : IPostprocessBuildWithReport
private const string NseBundleSuffix = "NSE";
private const string WidgetBundleSuffix = "LA";

// CI-only manual signing config. Profile names must match the
// OneSignal-owned provisioning profiles fetched by
// CI-only manual signing config: the in-house distribution cert and
// In House profiles, so BrowserStack can install the IPA without
// re-signing it. Profile names must match the OneSignal-owned
// provisioning profiles fetched by
// .github/workflows/e2e.yml (`Download provisioning profiles`) and
// referenced by examples/demo/iOS/ExportOptions.plist. Local devs
// keep Xcode auto-signing because IsCiBuild only returns true when
// GitHub Actions / similar set CI=true.
private const string MainProfileName = "Appium Demo - Main";
private const string NseProfileName = "Appium Demo - NSE";
private const string WidgetProfileName = "Appium Demo - Live Activity";
private const string DevSignIdentity = "Apple Development";
private const string DistributionSignIdentity = "iPhone Distribution";

// Run after both demo widget post-processor (45) and SDK
// post-processor (45). 100 puts us after pod install (50) too.
Expand Down Expand Up @@ -87,11 +89,13 @@ private static void FixupApsEnvironment(string outputPath)

var plist = new PlistDocument();
plist.ReadFromFile(fullPath);
plist.root.SetString("aps-environment", ApsEnvironment);
// In House profiles only grant production APNs.
var apsEnvironment = IsCiBuild() ? "production" : "development";
plist.root.SetString("aps-environment", apsEnvironment);
plist.WriteToFile(fullPath);

Debug.Log(
$"[SigningPostProcessor] Set aps-environment=\"{ApsEnvironment}\" in {relPath}"
$"[SigningPostProcessor] Set aps-environment=\"{apsEnvironment}\" in {relPath}"
);
}

Expand Down Expand Up @@ -150,11 +154,11 @@ string label
// specifier but Unity still emits it on every target; clear it so
// the specifier above wins instead of an empty UUID lookup.
project.SetBuildProperty(targetGuid, "PROVISIONING_PROFILE", "");
project.SetBuildProperty(targetGuid, "CODE_SIGN_IDENTITY", DevSignIdentity);
project.SetBuildProperty(targetGuid, "CODE_SIGN_IDENTITY", DistributionSignIdentity);
project.SetBuildProperty(
targetGuid,
"CODE_SIGN_IDENTITY[sdk=iphoneos*]",
DevSignIdentity
DistributionSignIdentity
);

Debug.Log(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.onesignal.example.icon">
package="com.onesignal.sdkdemo.icon">
</manifest>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apply plugin: 'com.android.library'

android {
namespace 'com.onesignal.example.icon'
namespace 'com.onesignal.sdkdemo.icon'

def unityLib = project(':unityLibrary').extensions.getByName('android')

Expand Down
27 changes: 15 additions & 12 deletions examples/demo/Assets/Resources/Theme.uss
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,8 @@
font-size: 14px;
-unity-font-style: bold;
-unity-text-align: middle-center;
margin-left: 0;
margin-right: 0;
margin-bottom: var(--card-gap);
}

Expand All @@ -390,25 +392,25 @@
color: #757575;
}

.button-grid-row {
/* Two per row via flex-wrap; an odd last button grows to span the row.
The negative margins cancel the outer half of each button's gutter. */
.button-grid {
flex-direction: row;
flex-wrap: wrap;
margin-left: -4px;
margin-right: -4px;
}

.button-grid-item {
.button-grid > .primary-button,
.button-grid > .destructive-button {
flex-grow: 1;
flex-basis: 0;
flex-basis: 40%;
margin-left: 4px;
margin-right: 4px;
padding: 0 8px;
white-space: nowrap;
}

.button-grid-item--leading {
margin-right: var(--card-gap);
}

.button-grid-item--trailing {
margin-left: 0;
}

.destructive-button {
background-color: transparent;
color: var(--os-primary);
Expand All @@ -420,6 +422,8 @@
font-size: 14px;
-unity-font-style: bold;
-unity-text-align: middle-center;
margin-left: 0;
margin-right: 0;
margin-bottom: var(--card-gap);
}

Expand Down Expand Up @@ -607,7 +611,6 @@
background-color: var(--os-backdrop);
justify-content: flex-start;
align-items: center;
padding-top: 80px;
}

.dialog-container {
Expand Down
4 changes: 2 additions & 2 deletions examples/demo/Assets/Scripts/Editor/BuildScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ public static void BuildiOSSimulator()
/// Builds an Xcode project targeting physical iOS devices, used by CI to
/// produce a signed IPA for BrowserStack. The OneSignal SDK and demo
/// post-processors add push capabilities, the NSE / Live Activity widget
/// targets, and pin DEVELOPMENT_TEAM + aps-environment=development so the
/// archive step can sign with the Appium provisioning profiles in
/// targets, and pin DEVELOPMENT_TEAM + aps-environment=production so the
/// archive step can sign with the In House Appium provisioning profiles in
/// ExportOptions.plist.
/// </summary>
public static void BuildiOSDevice()
Expand Down
15 changes: 15 additions & 0 deletions examples/demo/Assets/Scripts/UI/Dialogs/DialogBase.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Runtime.InteropServices;
using OneSignalDemo.Services;
using UnityEngine;
using UnityEngine.UIElements;

namespace OneSignalDemo.UI.Dialogs
Expand Down Expand Up @@ -33,6 +34,7 @@ public void Show(VisualElement parent)

Overlay = new VisualElement();
Overlay.AddToClassList("dialog-overlay");
Overlay.style.paddingTop = SafeAreaTop(parent);
Overlay.RegisterCallback<ClickEvent>(e =>
{
if (e.target == Overlay)
Expand Down Expand Up @@ -84,6 +86,19 @@ public void Dismiss()
Overlay = null;
}

/// <summary>
/// Top safe-area inset in panel units. Dialogs anchor below it (the
/// container adds the 24px inset) and stay put while open: a dialog
/// that moves desyncs XCUITest frame reporting from the layout.
/// </summary>
private static float SafeAreaTop(VisualElement parent)
{
float height = parent.resolvedStyle.height;
if (float.IsNaN(height) || height <= 0 || Screen.height <= 0)
return 0;
return (Screen.height - Screen.safeArea.yMax) * height / Screen.height;
}

protected abstract void BuildContent(VisualElement container);

protected TextField CreateTextField(string label, string name, string placeholder = "")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Action<string> onSelected
protected override void BuildContent(VisualElement container)
{
Overlay.AddToClassList("dropdown-overlay");
Overlay.style.paddingTop = 0;
container.AddToClassList("dropdown-menu");

var list = new ScrollView(ScrollViewMode.Vertical);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,18 @@ private VisualElement BuildSection()
card.Add(_listContainer);
section.Add(card);

section.Add(
var buttonGrid = SectionBuilder.CreateButtonGrid();
section.Add(buttonGrid);
buttonGrid.Add(
SectionBuilder.CreatePrimaryButton(
"ADD ALIAS",
"add_alias_button",
ShowAddAliasDialog
)
);
section.Add(
buttonGrid.Add(
SectionBuilder.CreatePrimaryButton(
"ADD MULTIPLE ALIASES",
"ADD ALIASES",
"add_multiple_aliases_button",
ShowAddMultipleAliasesDialog
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,26 +56,29 @@ private VisualElement BuildSection()

section.Add(inputCard);

var buttonGrid = SectionBuilder.CreateButtonGrid();
section.Add(buttonGrid);

_startButton = SectionBuilder.CreatePrimaryButton(
"START LIVE ACTIVITY",
"START ACTIVITY",
"start_live_activity_button",
OnStartTap
);
section.Add(_startButton);
buttonGrid.Add(_startButton);

_updateButton = SectionBuilder.CreatePrimaryButton(
$"UPDATE \u2192 {_viewModel.NextStatusLabel}",
"update_live_activity_button",
OnUpdateTap
);
section.Add(_updateButton);
buttonGrid.Add(_updateButton);

_endButton = SectionBuilder.CreateDestructiveButton(
"END LIVE ACTIVITY",
"END ACTIVITY",
"end_live_activity_button",
OnEndTap
);
section.Add(_endButton);
buttonGrid.Add(_endButton);

_apiKeyHint = new Label("Set ONESIGNAL_API_KEY in .env to enable update & end");
_apiKeyHint.name = "live_activity_api_key_hint";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,19 @@ private VisualElement BuildSection()
card.Add(toggleRow);
section.Add(card);

section.Add(
var buttonGrid = SectionBuilder.CreateButtonGrid();
section.Add(buttonGrid);
buttonGrid.Add(
SectionBuilder.CreatePrimaryButton(
"PROMPT LOCATION",
"prompt_location_button",
() => _viewModel.PromptLocation()
)
);

section.Add(
buttonGrid.Add(
SectionBuilder.CreatePrimaryButton(
"CHECK LOCATION SHARED",
"CHECK LOCATION",
"check_location_button",
() =>
{
Expand Down
12 changes: 12 additions & 0 deletions examples/demo/Assets/Scripts/UI/Sections/SectionBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,18 @@ Action<bool> onChanged
return row;
}

/// <summary>
/// Container that lays buttons out two per row. An odd last button
/// spans the row, and buttons hidden with display: none drop out so
/// the rest reflow.
/// </summary>
public static VisualElement CreateButtonGrid()
{
var grid = new VisualElement();
grid.AddToClassList("button-grid");
return grid;
}

public static Button CreatePrimaryButton(string text, string name, Action onClick)
{
var btn = new Button(onClick);
Expand Down
Loading
Loading