我用的是iphone和ios 9.3
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
UIUserNotificationType types = (UIUserNotificationType) (UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert);
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:types categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
return YES;
}通知注册之后,调用此方法:
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
//register to receive notifications
[application registerForRemoteNotifications];
}在应用程序registerForRemoteNotifications之后,系统弹出,我接受通知,但是方法:
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *) deviceToken 从来没有打过电话,我错过了什么?
这在ios 8上非常有用。
发布于 2016-04-28 07:18:08
好吧,这听起来很愚蠢,但它开始工作了,没有改变一行代码.这是在重新启动wifi路由器和计算机之后发生的,可能是路由器阻塞了连接。
谢谢您的回答,如果有人有类似的问题,请查看下面的帖子:didRegisterForRemoteNotificationsWithDeviceToken not called in ios8, but didRegister...Settings is
https://stackoverflow.com/questions/36897686
复制相似问题