Search code examples
iosobjective-capple-push-notificationsios-permissions

iOS app not asking for permissions on iOS7 device


I have an iOS app with push notifications enabled using following code

 if ([application respondsToSelector:@selector(isRegisteredForRemoteNotifications)])
{
    // iOS 8 Notifications
    [application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];

    [application registerForRemoteNotifications];
}
else
{
    // iOS < 8 Notifications
    [application registerForRemoteNotificationTypes:
     (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)];
}

When this app is run on iOS9 device it asks for permissions in the beginning just fine, but when used on iOS7 , iPhone 4 it doesn't ask for permissions but it receives the notifications just fine, not able to understand the issue.


Solution

  • Seeing as your user is receiving the push notifications despite not being presented a permission dialogue, following must be the scenario:

    1. He had a previous build on his iPhone 4s which he had authorized for push notifications.
    2. He quickly uninstalled the previous build and installed the latest build you gave him, without giving a period of one day to device before reinstalling.
    3. Result was that he wasn't presented any dialogue asking for push notifications permissions as the permissions were already granted previously.

    According to Apple Technical Note 2265:

    The first time a push-enabled app registers for push notifications, iOS asks the user if they wish to receive notifications for that app. Once the user has responded to this alert it is not presented again unless the device is restored or the app has been uninstalled for at least a day.

    If you want to simulate a first-time run of your app, you can leave the app uninstalled for a day. You can achieve the latter without actually waiting a day by following these steps:

    Delete your app from the device. Turn the device off completely and turn it back on. Go to Settings > General > Date & Time and set the date ahead a day or more. Turn the device off completely again and turn it back on

    If you ask your user to check for app specific permissions in settings menu, He will certainly see the Push permissions. Otherwise he would not have been receiving push notifications at all.