1

I am developing an app with push notifications.

But a couple of weird things are happening.

First didRegisterForRemoteNotificationsWithDeviceToken executes always, even after disabling the notifications. And I receive them also.

I never get the alert asking me if I want to allow push notifications, even if I uninstall the app, move forward the calendar 2 days and restart the phone, it doesn't ask to allow them, it assumes I did allow them.

Can anyone tell me why is this weird stuff happening?

Thanks

Devang
  • 11,258
  • 13
  • 62
  • 100
subharb
  • 3,374
  • 8
  • 41
  • 72
  • You actually get push alert views shown if you've disabled them in settings for an app? That sounds totally wrong and if that's true, file a radar for it. – mattjgalloway Mar 27 '12 at 10:10
  • didRegisterForRemoteNotificationsWithDeviceToken gets called back presumably because he's calling registerForRemoteNotificationTypes. It's merely responding by handing back the device token. He's also saying that even after uninstalling & reinstalling the app, he doesn't see the first-time "'FooApp' Would Like To Send You Push Notifications" user permissions dialog. See http://stackoverflow.com/questions/8033216/how-to-show-would-like-to-send-you-push-notifications-alert-view-again for details. – rondoagogo Sep 06 '12 at 02:02

1 Answers1

0

How exactly are you disabling notifications? The Settings UI in iOS isn't exactly clear.

I use this code to display the app's Remote Push Notification Settings in the console.

UIRemoteNotificationType notificationSelection = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];

if (notificationSelection == UIRemoteNotificationTypeNone)
{
    NSLog(@"Push Notifications : DISABLED (%0X)", notificationSelection);
}
else
{
    NSLog(@"Push Notifications : ENABLED (%0X)", notificationSelection);

    if (notificationSelection & UIRemoteNotificationTypeBadge)
    {
        NSLog (@"Push Notifications : Badge");
    }

    if (notificationSelection & UIRemoteNotificationTypeSound)
    {
        NSLog (@"Push Notifications : Sound");
    }

    if (notificationSelection & UIRemoteNotificationTypeAlert)
    {
        NSLog (@"Push Notifications : Alert");
    }

    if (notificationSelection & UIRemoteNotificationTypeNewsstandContentAvailability)
    {
        NSLog (@"Push Notifications : Newstand Content Availability");
    }

    sendMessage = YES;
}
Snips
  • 6,575
  • 7
  • 40
  • 64
  • I go to General -> Notifications and then I disable the app Im developing. Also I change the date of the phone to 2 days after and I reboot the phone. – subharb Mar 27 '12 at 16:58
  • I'm only being detailed here to try and help you out... note that you'll need to disable all the individual options only. Just setting 'Notification Centre' to OFF, isn't sufficient. You'll also need to set alert style to 'None', and set badge icon to OFF, Sounds to OFF, and View in Lock Screen to OFF. *any* of these options individually will require Push Notifications to be enabled - that wasn't immediately obvious to me. I'll edit my answer above to add the code I use to display the app's remote notification settings in the console. – Snips Mar 27 '12 at 17:14
  • Also, what effect do you expect changing the clock to have? The notifications are sent by the remote server based on boolean flags, and whatever other criteria the server app uses - the time on the iPhone won't make difference. – Snips Mar 27 '12 at 17:20
  • I read in another question in stackoverflow that if you dont change the time the phone will not ask you if you want to "Allow notifications" I wanted to simulate that very first question. Also, the fact that "didRegisterForRemoteNotificationsWithDeviceToken" executes every time isnt already a strange behaviour? Is it suposed to be executed only once? that very first time? – subharb Mar 27 '12 at 17:31
  • 1
    According to the documentation, devices should register for notifications each time they run as the device token may change. – Snips Mar 27 '12 at 19:09
  • But the token is not changing. Any idea how to revert this? Installing and uninstalling is not helping to make the app work as expected. – subharb Mar 28 '12 at 06:42
  • In practice, I don't see the device token change either, but the documentation requires that you register each time. – Snips Mar 28 '12 at 08:36
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/9409/discussion-between-david-shaikh-and-snips) – subharb Mar 28 '12 at 14:10