fastlane pem で Push 通知に必要な p12 ファイルを生成する

iOS 用の Push 通知 証明書を生成したい。 真心を込めて手動で生成することもできるが、ここでは fastlane pem でコマンドで生成する。

fastlane pem

fastlane/pem at master · fastlane/fastlane

詳細は上の README みればやり方書いてる。

gem install fastlane

$ gem install pem

pem

  1. コマンドラインpem と打つ
  2. Apple ID 聞かれるので入力する
  3. Apple ID パスワード聞かれるので入れる
    • fastlane を信用する、不安なら OSS なのでコードを読むべし
  4. bundle id を聞かれるので該当のアプリの bundle id を入れる
  5. 証明書の期限が 30 日以内の場合、p12 ファイルが吐かれる
    • –force オプション使うと 30 以上でもファイルが吐かれるっぽい

下記のようなログと流れになる。

$ pem
+------------------+-------+
|  Summary for PEM 1.4.0   |
+------------------+-------+
| development      | false |
| generate_p12     | true  |
| force            | false |
| save_private_key | true  |
| output_path      | .     |
+------------------+-------+

[14:56:45]: To not be asked about this value, you can specify it using 'username'
Your Apple ID Username: Your Apple ID Username
[14:56:53]: Starting login with user 'Your Apple ID Username'
-------------------------------------------------------------------------------------
The login information you enter will be stored in your Mac OS Keychain
You can also pass the password using the `FASTLANE_PASSWORD` environment variable
More information about it on GitHub: https://github.com/fastlane/fastlane/tree/master/credentials_manager
-------------------------------------------------------------------------------------
Password (for Your Apple ID Username): *************
[14:57:01]: Successfully logged in
[14:57:02]: To not be asked about this value, you can specify it using 'app_identifier'
The bundle identifier of your app: jp.starhoshi.hoge
[14:57:18]: Existing push notification profile 'jp.starhoshi.hoge' is valid for 135 more days.
[14:57:18]: You already have a push certificate, which is active for more than 30 more days. No need to create a new one
[14:57:18]: If you still want to create a new one, use the --force option when running PEM.

あとは p12 ファイルを Amazon SNS とかにあげれば OK !