5
votes

I am very new to this development, so please help me

I am starting push notification using this code

[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
     (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];

But, on my device I am not getting push notification user permission alert saying "App Name" Would like to send Notifications

I found that if device is jail broken, then we don't receive permission alert message, but my device is not jail broken.

edited

I am also getting push notifications on my device, just not getting permission alert on first start.

Any help on this will be really thankful.

4
Do you create a development certificate with push notification enabled? - MaTTP
I am receiving push notifications, but not permission alert message - P.J
This alert will only come at first time app launch after installation. - Dhaval Panchal
@Prateek: try to cancel and install again your app - MaTTP

4 Answers

13
votes

from: https://developer.apple.com/library/ios/technotes/tn2265/_index.html#//apple_ref/doc/uid/DTS40010376-CH1-TNTAG42

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

  5. Re-install the app

I just tested on iOS 7.1 and it worked. note this requires turning off the device TWICE.

10
votes

I found that push notifications permission alert comes only first time application is started, even if we delete application, permission alert will not come. Even if application is uninstalled for more than 7 days, still permission alert will not come.

When I tested my application on different devices, I found this issue, that permission alert comes only once, first time application run.

Hope this information helps others who also faced same issue..

5
votes

if you use IOS S.1 /5.1 + , please read push notification Guidelines App Store Review Guidelines

By Apple Document

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 setting the system clock forward a day or more, turning the device off completely, then turning the device back on.

0
votes

you need to do something like this- you need to register you device also.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {   

    [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
}

Notification delegate method callback as per your status-

- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)devToken 
{

}


- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err 
{
    DebugLog(@"Error in registration. Error: %@", err);
}