私はトークン内部のデバイスを取得 - (BOOL)アプリケーションを:didFinishLaunchingWithOptions:
- (BOOL)application:didFinishLaunchingWithOptions:
内のデバイストークン(APN)を取得する方法がわからない、私はAppDelegateにデバイストークンを取得することができる唯一の場所は
であります- (void)application:didRegisterForRemoteNotificationsWithDeviceToken:
ここで、application:didRegisterForRemoteNotificationsWithDeviceTokenは、非同期またはdidFinishLaunchingWithOptionsの後に実行されます。ですから、didFinishLaunchingWithOptionsにデバイストークンを取得する方法はありますか?私はdidFinishLaunchingWithOptionsからプッシュした私のViewControllerに渡したいからです。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
for (id key in launchOptions) {
NSLog(@"Key: %@, Value %@", key, [launchOptions objectForKey: key]);
}
AddViewController *avc = [[AddViewController alloc] init];
avc.managedObjectContext = self.managedObjectContext;
avc.pushToken = self.pushToken;
UINavigationController *uinav = [[UINavigationController alloc] init ];
[uinav pushViewController:avc animated:YES];
[_window addSubview:uinav.view];
[avc release];
[self.window makeKeyAndVisible];
// Let the device know we want to receive push notifications
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
return YES;
}
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
{
NSLog(@"My token is: %@", deviceToken);
self.pushToken = [NSString stringWithFormat:@"%@", deviceToken];
}
おかげで任意の助けのためにたくさん:
は、ここに私のサンプルコードです。
良いアイデアwarrenm。 tx – dejoong