LoginSignup
6
7

More than 5 years have passed since last update.

iOS の Remote Push Notification 通知実装手順メモ

Last updated at Posted at 2016-05-24

参考になるかと思って開いた方、完全に自分用メモなので荒削りですいません。

軽い気持ちで Push 通知したくなって調べてみたら結構途方もない感じだったのでメモしました。
間違いもあるかもしれません。

Certification 準備

  1. https://developer.apple.com に移動、ログイン
  2. Certificates から Development (Production) を選択して + ボタンを押す
  3. 「Apple Push Notification services SSL (Sandbox)」を選択して Continue kobito.1463612250.591767.png
  4. 紐付ける Bundle ID を選択して Continue
  5. 「CSR をアップロードしろ」とでる(作り方の説明付き)ので、その通り作ってアップロードする
  6. .cer ダウンロード
  7. .cer をキーチェーンに取り込み
  8. p12 書き出し
  9. pem にする $openssl pkcs12 -out dev2.pem -in dev2.p12 -nodes -clcerts
  10. Server 側の pem ファイルが完成

Code for iOS

参考: What's New in iOS Notifications

  1. UIUserNotificationActionContext.Default or Minimal
  2. UIMutableUserNotificationCategory
    • 複数の Action をまとめる
  3. UIMutableUserNotificationCategory:setActions:forContext
    • Action とその Action が有効になる Context (通知ダイアログの状態?)を紐付ける
  4. registerUserNotificationSettings:
    • ユーザーに通知の許可を得る
  5. aplication:didRegisterUserNotificationSettings:notificationSettings:
  6. registerForRemoteNotifications:
  7. application:didRegisterForRemoteNotificationsWithDeviceToken:
    • Device token 取得 ( Push宛先 )

Code for server (Provider)

require 'apns'
# sandbox
APNS.pem = "/your/pem/file"
token = "your device token"
APNS.send_notification(token,"message")
6
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
7