BAD_ACCESS

おもにiOS、ときどき変な電子工作、ガジェット話。

Push通知を実装したはずなのにリリースされたアプリでPushが来ない!?ってなったとき

Push通知を実装したはずなのにリリースされたアプリで通知がこない!! Adhoc版でテストしたときはうまくいったのに…という場合、一度確認しとくべきところ。

こんなエラーメッセージがくる

Missing Push Notification Entitlement - Your app appears to include API used to register with the Apple Push Notification service, but the app signature's entitlements do not include the "aps-environment" entitlement. If your app uses the Apple Push Notification service, make sure your App ID is enabled for Push Notification in the Provisioning Portal, and resubmit after signing your app with a Distribution provisioning profile that includes the "aps-environment" entitlement. See "Provisioning and Development" in the Local and Push Notification Programming Guide for more information. If your app does not use the Apple Push Notification service, no action is required. You may remove the API from future submissions to stop this warning. If you use a third-party framework, you may need to contact the developer for information on removing the API.

アプリにはプッシュ通知用のAPIが実装されているけど、Distributionにプッシュ通知の設定がされてませんよー

iTunes ConnectのBinary Details

uploadが完了した後に、バイナリの詳細を見ることができる。アップロードしたバイナリが正しければ下図のようにEntitlementsaps-environmentの値が入っている。 これが入ってない場合、アプリ申請用のDistributionを作ったときに何かミスをしている可能性がある。

Binary Details

Provisioning Profileの中をみてみる。

バイナリの詳細のEntitlementsaps-environmentの値が入ってなかった場合、Provisioning Profileの情報をみてみよう。

Provisioning Profileの設定が正しければ以下のようにEntitlementsaps-environmentというキーが含まれているはず。

        <key>Entitlements</key>
        <dict>
                <key>application-identifier</key>
                <string>A8PPLL6C5N.com.kayac.kakusenkun</string>
                <key>aps-environment</key>
                <string>production</string>
                <key>get-task-allow</key>
                <false/>

Distributionを作り直す。

こういった問題が起こるのは申請用のDistributionを作成するタイミングが原因であることが考えられる。特に、Distributionを作成するよりも先にPush通知の証明書関係の登録を終わらせていないという可能性などが考えられる。

こういう場合は、申請用のDistributionを再作成してみることをおすすめします。

また再申請時に、上記2つの確認も併せて行うことで、プッシュ通知まわりのトラブルのいくつかを回避できるのではないでしょうか。