Open mcastillo86 opened 5 months ago
Check if you've asked for permissions for notifications.
Thanks @akshayhalasangi but I have double checked that part, still nothing. Due to my version of react-native I followed this these steps. The app receives notifications when in background or foreground but not when it is closed.
do you do PushNotification.configure in App.js or index.js?
The same problem. PushNotification.configure is in index.js. Working on Android less then 13. Push notifications work when the app is in the foreground. Once it's off or in the background and a notification comes in, it kills the app.
Set environment according to https://dev.to/gautham495/asking-notification-permission-in-android-13-for-a-react-native-application-35n2
this solved my problem:
app/src/main/AndroidManifest.xml add =>
android/app/build.gradle add=> implementation platform('com.google.firebase:firebase-bom:29.0.1')
android/build.gradle
buildToolsVersion = "30.0.2" minSdkVersion = 23 compileSdkVersion = 33 targetSdkVersion = 33
And check permissions: export const checkAndroidPermissionPostNotifications = async () => { if (Platform.OS === "android" && Platform.Version >= 33) { try { // @ts-ignore - to be fixed after upgrade to RN 0.7+ const result = await PermissionsAndroid.check("android.permission.POST_NOTIFICATIONS"); //Permission is undefined, asking for it. if (result === undefined) { // @ts-ignore - to be fixed after upgrade to RN 0.7+ await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS); } } catch (error) {} } };
good luck to everyone! Radek
Question
Hello,
I've been using this package for quite a while but we've just noticed the our app is receiving foreground and background notifications but none is received when the app is closed. Below you can find my RN and this library versions, as well as some part of my android manifest file. Am I missing something?
package.json
"react-native": "~0.63.5", "react-native-push-notification": "8.1.1",
Android manifest
<meta-data android:name="com.dieam.reactnativepushnotification.default_notification_channel_id" android:value="channel-default" /> <meta-data android:name="com.dieam.reactnativepushnotification.notification_channel_name" android:value="Notificaciones" /> <meta-data android:name="com.dieam.reactnativepushnotification.notification_foreground" android:value="true" /> <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@mipmap/ic_stat_tlc" /> <meta-data android:name="com.google.firebase.messaging.default_notification_channel_id" android:value="channel-default" /> <meta-data android:name="com.dieam.reactnativepushnotification.notification_color" android:resource="@color/white" />