Skip to content

Commit 96b8e5b

Browse files
committed
fix(demo): route push permission through OneSignal SDK
1 parent 384badd commit 96b8e5b

3 files changed

Lines changed: 14 additions & 30 deletions

File tree

examples/demo/Assets/App/Editor/iOS/SigningPostProcessor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class SigningPostProcessor : IPostprocessBuildWithReport
3434
private const string ApsEnvironment = "development";
3535

3636
private const string NseTargetName = "OneSignalNotificationServiceExtension";
37-
private const string WidgetTargetName = "OneSignalWidget";
37+
private const string WidgetTargetName = "OneSignalWidgetExtension";
3838

3939
// Short bundle-id suffixes (match the Flutter demo).
4040
private const string NseBundleSuffix = "NSE";

examples/demo/Assets/Scripts/AppBootstrapper.cs

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -92,32 +92,17 @@ private async void Start()
9292

9393
private void PromptPushForStartup()
9494
{
95-
#if UNITY_ANDROID && !UNITY_EDITOR
96-
if (DotEnv.IsE2EMode)
97-
{
98-
RequestAndroidPostNotificationsPermission();
99-
return;
100-
}
101-
#endif
95+
// Route both runtime and E2E flows through the SDK on every
96+
// platform. The earlier Android E2E path called raw
97+
// `activity.requestPermissions(POST_NOTIFICATIONS)`, which shows
98+
// the OS dialog but never tells the OneSignal SDK about the
99+
// grant. The SDK then enqueues two competing update-subscription
100+
// ops (one SUBSCRIBED, one NO_PERMISSION) and which one wins is a
101+
// race — pushes silently never deliver when NO_PERMISSION wins.
102102
_viewModel.PromptPush();
103103
}
104104

105105
#if UNITY_ANDROID && !UNITY_EDITOR
106-
private static void RequestAndroidPostNotificationsPermission()
107-
{
108-
using var version = new AndroidJavaClass("android.os.Build$VERSION");
109-
if (version.GetStatic<int>("SDK_INT") < 33)
110-
return;
111-
112-
using var unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
113-
using var activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
114-
activity.Call(
115-
"requestPermissions",
116-
new[] { "android.permission.POST_NOTIFICATIONS" },
117-
1001
118-
);
119-
}
120-
121106
private static void SetAndroidWebViewDebugging(bool enabled)
122107
{
123108
if (!DotEnv.IsE2EMode)

examples/demo/Assets/Scripts/Services/AccessibilityBridge.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#if UNITY_IOS || UNITY_ANDROID
21
using System;
32
using System.Collections;
43
using System.Collections.Generic;
@@ -663,6 +662,9 @@ private void InvokeAndroidNativeAction(string id)
663662
var boolField = _root.Q<BaseBoolField>(id);
664663
if (boolField != null)
665664
{
665+
if (boolField is RadioButton && boolField.value)
666+
return;
667+
666668
boolField.value = !boolField.value;
667669
return;
668670
}
@@ -727,17 +729,15 @@ private void InvokeAndroidNativeScroll(string direction)
727729

728730
private static string AndroidNativeRole(VisualElement el)
729731
{
730-
if (AndroidClickTargets.ContainsKey(el))
731-
return "button";
732-
733-
return el switch
732+
var role = el switch
734733
{
735734
TextField => "input",
736735
BaseBoolField => "toggle",
737736
OneSignalDemo.UI.SwitchToggle => "toggle",
738737
Button => "button",
739-
_ => "text",
738+
_ => AndroidClickTargets.ContainsKey(el) ? "button" : "text",
740739
};
740+
return role;
741741
}
742742
#else
743743
private void SyncAndroidNativeAccessibility() { }
@@ -1128,4 +1128,3 @@ public IosInfoTap(Func<bool> isEnabled, Action action)
11281128
#endif
11291129
}
11301130
}
1131-
#endif

0 commit comments

Comments
 (0)