在IOS应用程序中用户离线时不发送通知[PHP]

For sending the IOS notification, we have to send a device token with request. Then we save the device token in database users table.

When the user logs in, we store the device token in a column as per the device token notification goes to user.

However, when user logs out, device token is removed from the users table and those notifications go a-miss from that user.

How can we handle this scenario that whenever someone logs in, the device can then send all those notifications?

Save the notifications in the database for the user according to both user-id and token. When user is logged out remove the token, for newly generated notifications only save the user-id. When user login update the records for the user with new token.