Skip to content

Commit 905aefb

Browse files
committed
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
1 parent 58a786a commit 905aefb

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

  • OneSignalSDK/onesignal/notifications/src/main/java/com/onesignal/notifications/internal/badges/impl

OneSignalSDK/onesignal/notifications/src/main/java/com/onesignal/notifications/internal/badges/impl/BadgeCountUpdater.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ internal class BadgeCountUpdater(
8383

8484
override fun updateCount(count: Int) {
8585
if (!areBadgeSettingsEnabled()) return
86+
// On API 26+ the system handles badges via NotificationChannel, and
87+
// ShortcutBadger can cause native SIGSEGV crashes on some OEM devices
88+
// (e.g. Xiaomi Redmi) where the broadcast receiver has buggy native code.
89+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) return
8690
try {
8791
ShortcutBadger.applyCountOrThrow(_applicationService.appContext, count)
8892
} catch (e: ShortcutBadgeException) {

0 commit comments

Comments
 (0)