我一直在尝试使用 Apple 推送通知服务从我的 iPhone 应用程序中获取 deviceToken。我暂时在服务器端没有任何实现。我已经创建了 APP Id,获得了 SSL 证书,使用 APN 提供配置文件并调用
- (void)applicationDidFinishLaunching:(UIApplication *)application {
//view init and add sub view to window
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound];
}
方法。当我执行应用程序时,它会弹出操作框以允许推送通知(意味着我的 APN 注册请求正在运行)但我的回调未执行。didRegisterForRemoteNotificationsWithDeviceToken和didFailToRegisterForRemoteNotificationsWithError都没有被调用?有人可以帮我解决这个问题吗?以下是我的callbacs供参考。
- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err {
UIAlertView *myAlert = [[UIAlertView alloc] initWithTitle:@"APNClient" message:@"Entered into Error Method" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[myAlert show];
[myAlert release];
NSLog(@"Error in registration. Error: %@", err);
}
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)devToken {
UIAlertView *myAlert = [[UIAlertView alloc] initWithTitle:@"APNClient" message:@"Got the deviceToken..!" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[myAlert show];
[myAlert release];
}