iOSでプッシュ通知を実装する方法の超詳細まとめ

| コメント(0)
Lancorkさんから。http://www.lancork.net

追記(2014/11/04)
registerForRemoteNotificationTypes: is not supported in iOS 8.0 and later.

iOS8よりregisterForRemoteNotificationTypesが使えなくなった。
ターゲットがiOS7でも動作しないため、iOSのバージョンを判定した上で対応する必要あり。

    /* iOS8より、registerForRemoteNotificationTypesは、使えない。

    [[UIApplication sharedApplication]registerForRemoteNotificationTypes:

     (UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)];

     return YES;

    */

    

    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)

    {

        [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];

        [[UIApplication sharedApplication] registerForRemoteNotifications];

    }

    else

    {

        [[UIApplication sharedApplication] registerForRemoteNotificationTypes:

         (UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];

    }

    return YES;




コメントする

この記事について

このページは、Shinjiが2014年9月 5日 13:09に書いた記事です。

ひとつ前の記事は「iPhoneのディスク空き容量(残量)を取得する」です。

次の記事は「Amazon SNS Mobile Pushを使ってiOSのPush Notificationを実装する」です。

最近のコンテンツはインデックスページで見られます。過去に書かれたものはアーカイブのページで見られます。