Push Notification Delegates not getting called

北慕城南 提交于 2020-01-05 07:03:28

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!