I have two apps that received Push Notifications. I upgraded both to Xcode 6, and one works fine, the second one does not ever ask the user for permission to receive Push Notifications, nor does it receive the notifications.
I did update the code in the appDelegate to the new iOS 8 calls:
// register for push notification
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes: (UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge)
categories:nil]];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
else
{
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge|
UIRemoteNotificationTypeAlert|
UIRemoteNotificationTypeSound];
}
And I believe it is working correctly because didRegisterForRemoteNotificationsWithDeviceToken is being called and I am getting a DeviceToken.
I have:
Recreated (several times) my IDs and Provisioning profiles.
I am testing this on the device, not the simulator
I have tried to load it onto a iOS 8 AND iOS 7 device, neither works.
Checked to make sure that the PN is being sent by PARSE (which I am using to create the PN's). They are. And they are received on the second App.
Pushed up the date on my phone, restarted it, and reinstalled the app (had deleted it first).
Also, the App is listed in the notifications section to receive notifications.
Any thoughts?
Related
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.
Seeing as your user is receiving the push notifications despite not being presented a permission dialogue, following must be the scenario:
He had a previous build on his iPhone 4s which he had authorized for push notifications.
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.
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.
I am developing an iOS app that uses remote notifications. All works fine but I have noticed that the icon badge doesn't show any number when a notification is received.
I ask for permissions in this way in my AppDelegate:
[application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
[application registerForRemoteNotifications];
Is there anything more that I have to do?
Thanks!
The push notification payload should contain value with "badge" key, that will automatically update the app icon's badge.
I can't seem to get a prompt to show for registerUserNotificationSettings in iOS 8.1 or 8.2.
Here is what I'm doing in didFinishLaunchingWithOptions:
if ([application respondsToSelector:#selector(registerUserNotificationSettings:)]) {
#ifdef __IPHONE_8_0
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeAlert
|UIUserNotificationTypeSound | UIUserNotificationTypeBadge) categories:nil];
NSLog(#"Reg settings %#", settings);
[application registerUserNotificationSettings:settings];
#endif
}
Also getting the correct call back here:
- (void)application:(UIApplication *)application
didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings{
NSLog(#"Did register - %#", notificationSettings);
}
Yet no prompt is ever displayed. What's even more annoying is that an alert will display when the device is locked, but won't give the notification alert sound. Any ideas on a work around?
Update for iOS 11+:
Since iOS 11 Resetting the Push Notifications Permissions Alert on iOS procedure seems not to be necessary anymore. Just un-/reinstall the app.
Using your code, I get the prompt on the first app launch, and only on the first launch. But afaik, that's the expected behavior in iOS.
At least it's the same for photo library, microphone access etc:
Permissions Prompt Behavior
Popup on first usage (or at least the request to use it)
Apple adds an entry in settings (e.g. Privacy, or just under Settings for notifications)
First usage
In the Settings App you can configure Notifications for each app
Scroll down, select your app
Select Notifications
Enable/Disable them, or adjust their behavior
Resetting the Push Notifications Permissions Alert on iOS
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.
Source: https://developer.apple.com/library/ios/technotes/tn2265/_index.html
Change build target latest version you will see the popup message.
Same issue with me in iOS 8 its not showing, but in iOS 10 its showing the alert pop message, This alert message will be displayed only once for the application cycle. Unless you delete and reinstall new one.
- (void)registerLocalNotification{
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes: UIUserNotificationTypeAlert | UIUserNotificationTypeSound categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
If anybody is still stuck, toggling the options worked for me. It was this
UNAuthorizationOptions options = UNAuthorizationOptionAlert & UNAuthorizationOptionSound;
and I changed it to this
UNAuthorizationOptions options = UNAuthorizationOptionAlert;
and back to
UNAuthorizationOptions options = UNAuthorizationOptionAlert & UNAuthorizationOptionSound;
I have used push notification in one of my app which is live on app store. It was working fine before some days. But now push notification is not receiving.I uploaded new version of app on app store after this problem occurs.
Both the versions (live and in review) have different push certificates. i have revoked the previous certificate of the app which is live. will this create any problem with the live app?
may be that is due to update of iOS! you have to check for iOS version
for ios 8
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
[[UIApplication sharedApplication] registerForRemoteNotifications];
for else
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];
How to check if PushNotification for application is enabled ?
I knew we can change the push notification settings for application via settings->notification.
Here how to check this in appcode in IOS 7?
Once you’ve registered Push Notifications (asked the user if he allows…)
[[UIApplication sharedApplication] registerForRemoteNotificationTypes: (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
you can check what types of push notifications are enabled:
UIRemoteNotificationType enabledTypes = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
I hope this is what you want…