问题
I am implementing push notification for a client. I have followed all the steps of push notifications setup on device (including certificate generation and everything).
I have used following links as reference:
- Apple Push Notification Services Tutorial
- Programming Apple Push Notification Services
I call this function in app delegates didFinishLaunchingWithOptions
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
After setup, i run the app i get the Blue Push notification warning dialogue but after I press Ok the delegates are not called.
- (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
None of these delegates are called ever. I am stuck here as i cannot proceed further as none of the delegates is called.
If any of you has faced a similar issue i would be very very thankful if you can help me out here.
回答1:
I have seen this before, you need to just add [application registerForRemoteNotifications]; to your code, where application is the instance of UIApplication inside the didFinishLaunchingWithOptions method of the app delegate. Make sure you add this once you have set up your UINotificationType, and UIUserNotificationSettings
来源:https://stackoverflow.com/questions/8169201/push-notification-delegates-not-getting-called