How to Change iOS Push Notifications Permission Dialog with Expo

Vladimir Vovk - Sep 13 - - Dev Community

To receive push notifications we need to ask the user permission first. The requestPermissionsAsync function will show the user standard dialog asking to allow displaying alerts, setting badge count, and playing sounds.

Standard iOS permission dialog

Unfortunately, the docs have no information on how to change the dialog's text and make it more personal for our app. I found this Apple Developer Forums thread which recommends setting the NSUserNotificationsUsageDescription key in the Info.plist file.

For React Native app we can easily do that with XCode. And for the Expo app, we can set it with app.json or app.config.js configuration files.

All we need to do is to go to the ios -> infoPlist section of the configuration file and add NSUserNotificationsUsageDescription key like so:

{
  "name": "My awesome app",
  "ios": {
    "infoPlist": {
      "NSUserNotificationsUsageDescription": "Allow notifications to stay up to date. These can be configured from the System Settings."
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

That's it! πŸŽ‰
Rebuild your app binary and enjoy your new permission text.


If this post was helpful to you please, give it a star 🌟, and happy hacking! πŸ’»

Credits

Photo by Adem AY on Unsplash

. . . . . . . . . . . . .
Terabox Video Player