zo0r / react-native-push-notification

React Native Local and Remote Notifications
MIT License
6.73k stars 2.05k forks source link

Android 13 problem - POST_NOTIFICATIONS #2365

Open roeycohen opened 1 year ago

roeycohen commented 1 year ago

It seems like notifications won't work on Android 13 unless you add <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/> to your manifest file. https://developer.android.com/develop/ui/views/notifications/notification-permission#declare

this also requires requesting permissions explicitly... can someone please provide a sample code for that?

bananer commented 1 year ago

This seems to work:

import { PermissionsAndroid } from 'react-native';
PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS);
roeycohen commented 1 year ago

Thanks @bananer, I'm definitely going to give it a shot :)

shivapasunuri commented 10 months ago

Heyy @bananer I have tried this as well, for me some devices are getting the push notifications and some are not for the android built apk.

sivamani-edumpus commented 7 months ago

But, User deny the permission how again ask it?

heyalexchoi commented 6 months ago

for anyone else having issues receiving remote notifications, you may need

<service
            android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
            android:exported="false" >
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>

even though readme says you only need if you want to use localNotificationSchedule

yashnerkar commented 5 months ago

Heyy @bananer I have tried this as well, for me some devices are getting the push notifications and some are not for the android built apk.

same , if you got the solution for it can you let me know alos?

mrazekrad commented 4 months ago

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

Faizansiddiqui287 commented 3 months ago

How can I ask notification permission for Android 13 and above in react native version 0.61?