From 5139ef3f46aec6633e6e567581f6d78b0d358f26 Mon Sep 17 00:00:00 2001 From: Fadi George Date: Wed, 11 Mar 2026 13:49:13 -0700 Subject: [PATCH] fix: skip ShortcutBadger on API 26+ to prevent SIGSEGV on Xiaomi devices On Android 8+ (API 26), notification channels handle app icon badges natively, making ShortcutBadger unnecessary. ShortcutBadger's DefaultBadger fallback causes native SIGSEGV crashes on certain Xiaomi devices (Redmi 10C, Redmi 9A) where MIUI's broadcast receiver has buggy native code that cannot be caught at the Java level. Fixes OneSignal/react-native-onesignal#1766 Made-with: Cursor --- .../notifications/internal/badges/impl/BadgeCountUpdater.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/OneSignalSDK/onesignal/notifications/src/main/java/com/onesignal/notifications/internal/badges/impl/BadgeCountUpdater.kt b/OneSignalSDK/onesignal/notifications/src/main/java/com/onesignal/notifications/internal/badges/impl/BadgeCountUpdater.kt index 6f2f8f0f05..bf752ea6ae 100644 --- a/OneSignalSDK/onesignal/notifications/src/main/java/com/onesignal/notifications/internal/badges/impl/BadgeCountUpdater.kt +++ b/OneSignalSDK/onesignal/notifications/src/main/java/com/onesignal/notifications/internal/badges/impl/BadgeCountUpdater.kt @@ -50,6 +50,10 @@ internal class BadgeCountUpdater( override fun update() { if (!areBadgesEnabled()) return + // On API 26+ the system handles badges via NotificationChannel, and + // ShortcutBadger can cause native SIGSEGV crashes on some OEM devices + // (e.g. Xiaomi Redmi) where the broadcast receiver has buggy native code. + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { updateStandard() } else { @@ -83,6 +87,7 @@ internal class BadgeCountUpdater( override fun updateCount(count: Int) { if (!areBadgeSettingsEnabled()) return + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) return try { ShortcutBadger.applyCountOrThrow(_applicationService.appContext, count) } catch (e: ShortcutBadgeException) {