The case is this:
- A user logs in to the app on their iPhone A
- The user login in to the same app on their iPhone B
Now, in the database, there are 2 tokens for one user, that is correct.
+---------+-------------------+
| user_id | device_token |
+---------+-------------------+
| 1 | 1st_device_token1 |
| 1 | 2nd_device_token1 |
+---------+-------------------+
Say, that user deleted the app, installed it again (on both devices) and that means, tokens in APNs changed, therefore in our database, there are 4 unique tokens.
+---------+-----------------------+
| user_id | device_token |
+---------+-----------------------+
| 1 | 1st_device_token1 |
| 1 | 2nd_device_token1 |
| 1 | 1st_device_token1_new |
| 1 | 2nd_device_token1_new |
+---------+-----------------------+
Now, a push notification for that user is going to be sent to 4 devices (4 tokens). If they keep deleting and installing the app (may happen :) ), I would have in the database a large amount of tokens for one user and think, that they have such a vast number of devices, while in reality, there are a lot of invalid tokens.
How to prevent that?
Pushwoosh periodically clears its database from invalidated tokens (once per day or so), so having a "vast number" of entries should not be a problem. As for sending pushes to multiple devices of one user, there is a specific Push by UserID feature for this case.
The idea is to set a particular UserID on a login event and reset it to a default value on a logout with the following method:
Once UserID is set, you can send your /createMessage API requests with "users" parameter:
This feature is accessible for all payment plans, so it should be accessible for you.