2011-10-28 7 views
0

Objective-CとiOSの開発は初めてですが、View Controllerからアップルプッシュ通知デバイストークンをリクエストして、後でクエリ文字列に使用するためにトークンを格納する方法があるのだろうかと思っていました私のウェブアプリケーションに。View ControllerからAPNSデバイストークンを要求できますか?

私は検索してきましたが、これに対する解決策を見つけることができませんでした。どんな助けもありがとう!

答えて

4

コード内のどこでもregisterForRemoteNotificationTypes:に電話できる必要があります。

しかし、あなたのアプリケーションデリゲートにapplication:didRegisterForRemoteNotificationsWithDeviceToken:を実装する必要があります。

最大3種類の通知を登録できます。必要に応じて削除して追加してください。

[[UIApplication sharedApplication] 
    registerForRemoteNotificationTypes: 
    (UIRemoteNotificationTypeAlert |  //Alerts are pop up boxes or on ios5, banners 
    UIRemoteNotificationTypeBadge |  //Badges are the little red number on the icon 
    UIRemoteNotificationTypeSound)]; //Sounds are... well, sounds. These can be played when presenting a remote notification 
+0

smalltalk環境でのコールバックとよく似ています。ジェームズの提案は健全です。 – mozillanerd

+0

それは私にはちょっと聞こえます。私は現在持っています: - (void)アプリケーション:(UIApplication *)アプリケーションdidRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { NSLog(@ "didRegisterForRemoteNotificationsWithDeviceToken:%@"、deviceToken); } のAppDelegate。 View ControllerからregisterForRemoteNotificationTypesを呼び出す構文は何でしょうか? – Kevin

+0

登録する通知の種類によって異なります。私は私の答えに追加しました。 –

関連する問題