LoginSignup
44
38

More than 5 years have passed since last update.

iOSのプッシュ通知を何度もテストする方法

Last updated at Posted at 2015-06-30

何が問題か

iOSでプッシュ通知を実装すると、プッシュ通知を有効化する確認ポップアップが表示されます。
このポップアップは一度表示すると最低1日は再表示されないという仕様なので、確認ポップアップ後のコールバックのテストなどがとってもやりづらいです。

通知.png

対応

公式のドキュメントに対応が書いてありました。

Resetting the Push Notifications Permissions Alert on iOS

The first time a push-enabled app registers for push notifications, iOS asks the user if they wish to receive notifications for that app. Once the user has responded to this alert it is not presented again unless the device is restored or the app has been uninstalled for at least a day.

If you want to simulate a first-time run of your app, you can leave the app uninstalled for a day. You can achieve the latter without actually waiting a day by following these steps:

  1. Delete your app from the device.
  2. Turn the device off completely and turn it back on.
  3. Go to Settings > General > Date & Time and set the date ahead a day or more.
  4. Turn the device off completely again and turn it back on.

https://developer.apple.com/library/ios/technotes/tn2265/_index.html#//apple_ref/doc/uid/DTS40010376-CH1-TNTAG42

日付を戻すタイミングとか書いてないですが、以下の手順で問題なくできてます。

  1. アプリを削除
  2. デバイスを再起動
  3. 日付を1日以上進める(いつも2日ぐらい進めてます)
  4. デバイスを再起動
  5. 日付を戻す
  6. アプリをインストール

これで何度でもテストができますね!
デバイスを再起動する時点で、めんどくさすぎますが(;´Д`)

7/1 2:07 追記

ちなみにプッシュ通知のこの辺の情報は、

/private/var/mobile/Library/RemoteNotification/Clients.plist

内で管理されてるそうです。

The plist: /private/var/mobile/Library/RemoteNotification/Clients.plist

... contains the registered clients for push notifications. Removing your app's entry will cause the prompt to re-appear
http://stackoverflow.com/questions/2438400/reset-push-notification-settings-for-app

脱獄した端末なら簡単に再テストができそうです!(未確認)
あ、もちろん脱獄して何かあっても知りませんw

44
38
2

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
44
38