-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
App Crashed on Android 12 #2256
Comments
did you find any solution to this ? @touchalex |
@sa0sh0iip @touchalex it was due to this issue #2286 try adding this permission on AndroidManifest
|
@damithg-dev It did not fix the issue in my case...Any update regarding this issue? |
@risav-sarkar for me it was fixed. and had to handle the permission. could you be able to share the error log |
@damithg-dev I am still getting this error |
Hi, i have the same issue. Could you show how you handled the permission? Did you need to also display a promt after adding "SCHEDULE_EXACT_ALARM" and "USE_EXACT_ALARM"? In that case, how would this be done? |
Adding the following line, grade clean, delete app from testing device and rebuild helped.
According to https://developer.android.com/training/scheduling/alarms we need to prompt the user. No idea how to do that yet. After a quick test it seems to work fine with calling |
This will work in ANDROID 12,13(default permission comes on ALLOW). |
Do you need the exact alarms? As in, is your application actually an alarm app, or an app where the main functionality depends on sending notifications at exact time? In my case, my app does not qualify for exact alarm usage nor do I care if a notification is delivered at an exact time, therefore adding such permission makes no sense. What I did to work around this issue was remove both SCHEDULE_EXACT_ALARM and USE_EXACT_ALARM permissions from AndroidManifest and patch the RNPushNotificationHelper.java file: --- a/node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationHelper.java
+++ b/node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationHelper.java
@@ -173,15 +173,9 @@ public class RNPushNotificationHelper {
Log.d(LOG_TAG, String.format("Setting a notification with id %s at time %s",
bundle.getString("id"), Long.toString(fireDate)));
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
- if (allowWhileIdle && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
- getAlarmManager().setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, fireDate, pendingIntent);
- } else {
- getAlarmManager().setExact(AlarmManager.RTC_WAKEUP, fireDate, pendingIntent);
- }
- } else {
- getAlarmManager().set(AlarmManager.RTC_WAKEUP, fireDate, pendingIntent);
- }
+
+ // manual patch to use inexact alarm timing for scheduled notifications (avoids needing SCHEDULE_EXACT_ALARM permission)
+ getAlarmManager().setWindow(AlarmManager.RTC_WAKEUP, fireDate, 10 * 60 * 1000, pendingIntent);
}
By using |
Unfortunately, this suggestion still causes a bug in AOS 14 that causes the app to crash. |
By AOS 14 do you mean Android 14? |
@damithg-dev correct one is
(taken from https://stackoverflow.com/a/74397306/7867180). |
It's worked! |
My android app crashed on Android 12 (Works fine on Android 11)
Here is my development environment:
React Native Environment:
Homebrew 3.4.5
Node 17.8.0
NPM 8.5.5
Watchman 2022.03.21.00
React Native CLI 2.0.1
React Native 0.68
Pod 1.11.3
React Native Push Notificiation 8.1.1
and here is my build.gradle setting
ext {
buildToolsVersion = "31.0.0"
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 31
ndkVersion = "21.4.7075529"
googlePlayServicesVersion = "+" // default: "+"
firebaseMessagingVersion = "21.1.0" // default: "21.1.0"
supportLibVersion = "23.1.1" // default: 23.1.1
}
The app crash and close immediately when I open the app on Android 12 without showing any error.
The text was updated successfully, but these errors were encountered: