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