Я просто пытался получить deviceToken из своего приложения для iPhone с помощью службы push-уведомлений Apple.
У меня нет никакой реализации на стороне сервера в настоящее время.
Я создал идентификатор приложения, получил сертификат SSL, профиль обеспечения с APN и вызов
- (void)applicationDidFinishLaunching:(UIApplication *)application {
//view init and add sub view to window
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound];
}
метод.
Когда я выполняю приложение, оно всплывает в окне действия, чтобы разрешить Push-уведомление (означает, что мой запрос на регистрацию 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];
}