React Native Push Notifications not appearing in settings

Viewed 5533

I am new to react native and I am trying to set up push notifications via iOS.

I have installed pushNotificationios and followed the instructions given. I have also signed up as an Apple Developer.

When I run my app the push notifications don't seem to work. When I go into my iPhone settings and click on the app it does not display notifications.

settings

Here is my code

import PushNotificationIOS from '@react-native-community/push-notification-ios';
import PushNotification from "react-native-push-notification";

const configure = () => {
 PushNotification.configure({

   onRegister: (token) => {
    console.log('TOKEN:', token);
     //process token
   },

   onNotification: (notification) => {
     // process the notification
     console.log("NOTIFICATION:", notification);
     // required on iOS only
     notification.finish(PushNotificationIOS.FetchResult.NoData);
   },

   permissions: {
     alert: true,
     badge: true,
     sound: true
   },
  
   popInitialNotification: true,
   requestPermissions: true,

 });
};


 export {
    configure,
   };

3 Answers

I have your package has some problem with permission

you can use react-native-permissions package to get notification permission

import {requestNotifications} from 'react-native-permissions';

requestNotifications(['alert', 'sound']).then(({status, settings}) => {
  // …
});
  1. Check your XCode Notification settings enter image description here

  2. Try to ask permission in your FirstPage as below. not index.

const MainPage = {} => {
  useEffect(() => {
    PushNotificationIOS.requestPermissions(['alert', 'badge', 'sound']);
  }, [])
}

iOS: User cannot see the alarm option in preferences if user does not see the request Permission popup.

Android: Do not need asking permission.

I don't know if your package name have some special character, but I had the same problem then you, and to resolve I needed to go to the xCode, Build Settings (of the project) and change the Product Name, because my Product Name had an accent (like "ó"), and that away wasn't a English name. Ridiculous but resolved

Related