expo使ってビルドしたアプリでpush通知用のトークンを生成が上手く出来ずにハマりまくったのでメモ。
local環境では問題なくトークンが生成できるのに、Testflightだとトークンが生成されず、statusが”undetermined”となってしまう。
加えて、apple先生から以下のメールが届いたりもしてた。
Dear Developer, We identified one or more issues with a recent delivery for your app, "pushtest imneko" 1.0.0 (1.0.0.1). Your delivery was successful, but you may wish to correct the following issues in your next delivery: ITMS-90078: Missing Push Notification Entitlement - Your app appears 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. Xcode does not automatically copy the aps-environment entitlement from provisioning profiles at build time. This behavior is intentional. To use this entitlement, either enable Push Notifications in the project editor's Capabilities pane, or manually add the entitlement to your entitlements file. For more information, see https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/HandlingRemoteNotifications.html#//apple_ref/doc/uid/TP40008194-CH6-SW1. After you’ve corrected the issues, you can use Xcode or Application Loader to upload a new binary to App Store Connect. Best regards, The App Store Team
とりあえず解決方法がわかったのでメモ
環境
・expo-cli 2.19.4
・macOS Catalina
証明書とかの諸々を他のと共有する為に自分でアップロードすると上手くいかなかったのでexpoに全部ハンドリングしてもらえるように管理数上限に達してる場合は諸々のprofile, certificate, keyを消す。
apple developerページ -> Certificates,Identifiers & Profiles に行く
・Certificates
iOS Distributionを1つ消す(1枠空きがあるようにする)
・Identifiers
push通知の項目に何かセットされていれば全て消す。
(これは消す必要ない)
・Profiles
問題になっているProfileを消す
・Keys
Certificatesと同様に1つ消す(1枠空きがあるようにする)
次にサイドバーにあるCertificatesタブをクリックし、Certificatesの横の+をクリックする。

そしてガイドに従いながら
Apple Push Notification service SSL (Sandbox & Production)
の生成をする。

この証明書を使うように設定しないとダメみたい?(未検証なので検証するか、した人がいれば教えてください!!)
ここまで完了すれば次はcliでの操作になります。
対象のプロジェクトまで移動し、 expo-cli build:ios —clear-credentials
を実行し、証明書諸々を全てexpoにハンドリングしてもらうようにする。
ビルドが完了したら
expo-cli upload:ios
でテストフライト用にアップロードする。
application loaderからアップロードするのは試してないですが、多分application loaderからでも大丈夫だと思います。
アップロードが完了し、testflightできるようになるとpush通知用トークンが生成されるようになる。
手元の環境では色々やってみて、ちゃんとpush通知用のトークン生成出来たのはこの方法だったので備忘録的にメモしました。