How to ask notifications permissions if denied?

This is actually not possible. You only get one shot to prompt them for permissions. This is why most apps will present a custom view to explain why a certain permission is needed. And if the user clicks "yes", then they launch the actual permission alert. If they have already declined the permission, you'll need to check if app has certain permission and prompt them to go into settings to activate what is needed.

Here's an example of how you can check if they have given permission.


You cannot ask for a permission after the user has chosen to allow it or not. What you can do is check if the permission was not allowed and redirect the user to the app's settings.

How you check for the permission's authorization status depends on the type of service you want to authorize. You can the redirect the user to the settings with the following code:

Swift

UIApplication.shared.open(URL(string: UIApplicationOpenSettingsURLString)!, options: [:], completionHandler: nil)

Objective C

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString] options:@{} completionHandler:nil];

You´re not allowed to do that. The notification popup will prompt the first time the user opens the application. What you can do is check if the user hasn´t allowed this. Then you could open the settings page (which basically is what you can do in this case):

let isRegisteredForRemoteNotifications = UIApplication.shared.isRegisteredForRemoteNotifications
if !isRegisteredForRemoteNotifications {
    UIApplication.shared.open(URL(string: UIApplicationOpenSettingsURLString)!, options: [:], completionHandler: nil)
}

Swift 5.x

let isRegisteredForRemoteNotifications = UIApplication.shared.isRegisteredForRemoteNotifications
if !isRegisteredForRemoteNotifications {
    UIApplication.shared.open(URL(string: UIApplication.openSettingsURLString)!, options: [:], completionHandler: nil)
}