何が問題か
iOSでプッシュ通知を実装すると、プッシュ通知を有効化する確認ポップアップが表示されます。
このポップアップは一度表示すると最低1日は再表示されないという仕様なので、確認ポップアップ後のコールバックのテストなどがとってもやりづらいです。
対応
公式のドキュメントに対応が書いてありました。
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:
- Delete your app from the device.
- Turn the device off completely and turn it back on.
- Go to Settings > General > Date & Time and set the date ahead a day or more.
- Turn the device off completely again and turn it back on.
日付を戻すタイミングとか書いてないですが、以下の手順で問題なくできてます。
- アプリを削除
- デバイスを再起動
- 日付を1日以上進める(いつも2日ぐらい進めてます)
- デバイスを再起動
- 日付を戻す
- アプリをインストール
これで何度でもテストができますね!
デバイスを再起動する時点で、めんどくさすぎますが(;´Д`)
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