Help us understand the problem. What is going on with this article?

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

More than 3 years have passed since last update.

何が問題か

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

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした