iOS アプリケーションにプッシュ通知を配信するように Urban Airship をセットアップしようとしましたが、うまくいきませんでした。
ここに私が持っているものがあります:
- プッシュ通知が有効になっている開発者プロビジョニング プロファイル
- デバイスに通知証明書をプッシュし、Urban Airship にアップロード
- どこにもエラーはありません - UA のエラー コンソールは空で、デバイス トークンがアクティブであることを確認しました
ここに私の AppDelegate.m ファイルからのいくつかのスニペットがあります
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//Push notifications
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert)];
//Init Airship launch options
NSMutableDictionary *takeOffOptions = [[NSMutableDictionary alloc] init];
[takeOffOptions setValue:launchOptions forKey:UAirshipTakeOffOptionsLaunchOptionsKey];
// Create Airship singleton that's used to talk to Urban Airship servers.
// Please populate AirshipConfig.plist with your info from http://go.urbanairship.com
[UAirship takeOff:takeOffOptions];
// Register for notifications
[[UAPush shared] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeSound |
UIRemoteNotificationTypeAlert)];
[UAirship setLogging:YES];
}
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)devToken {
// Updates the device token and registers the token with UA
NSLog(@"APN device token: %@", devToken);
[[UAPush shared] registerDeviceToken:devToken];
}
UA の [テスト プッシュ通知] タブから通知を送信するとき、またはターミナルから CURL コマンドを送信するときに、次のメソッドのいずれも呼び出されません。
- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err {
NSLog(@"Error in registration. Error: %@", err.description);
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
NSLog(@"Received push notification with userInfo:%@", userInfo);
}
- (void)handleNotification:(NSDictionary *)notification applicationState:(UIApplicationState)state
{
NSLog(@"Received push notification with notification:%@", notification);
}
アプリを閉じた状態でテストプッシュ通知を送信しようとしましたが、iOS も何もしません。iPhone の [設定] にチェックインして自分のアプリに移動すると、バッジとバナーのプッシュが有効になっていることがわかります。iPhone 5 で iOS 6.1 を実行しています。