iOS Question Beginners question about Firebase Push Tokens

miker2069

Active Member
Licensed User
Longtime User
I was able to successfully get the Firebase Push Integration sample working as specified here. As I continue my education on this topic I have a basic question about Push tokens. From what I can see in the forum and googling around on this topic, my iOS based Push Notification enabled app can generate a user specific token. This token can presumably be used to send notifications to just that user. My questions are:

Once the token is generated is there a structure way (i.e. using Firebase SDK) to store the per user token in the Firebase cloud or Apple APN servers? Or is it my (the developer) responsibility to store the user token and then associate it with the user in my own database or other mechanism? I've seen examples of how to generate the user token but never what to do with it after it's generated (like send it somewhere, etc.). Is this the correct assumption.

If the user has more than one Apple device like an ipad and iphone, is the token per device? I think the answer is yes but want to verify. So if the user generates a token on his/her iphone and I use that to send the user a notification, it will only go to the iphone. If I want to send notifications to both devices, the app on both devices must generate a per user token and I need to associate it with that user and broadcast simultaneously. Is that correct?

Thank You!
 

Alexander Stolte

Expert
Licensed User
Longtime User
If the user has more than one Apple device like an ipad and iphone, is the token per device?
Yes, per device.
If I want to send notifications to both devices, the app on both devices must generate a per user token and I need to associate it with that user and broadcast simultaneously. Is that correct?
You then have 2 push tokens for this user, one for the iphone and one for the ipad, in your database both tokens must be assigned to this user. If you want a push notification for the user, you have to send the message to both tokens, because you can't know on which device the user is waiting for one of them. Instagram does the same thing for example, I have the app on my android phone and on my ipad, when someone writes to me I get the notification on both devices.

Or another approach would be to check which device was last active in the DB and then send to this device. But I would not recommend this.

I hope I didn't misunderstand your question.
 
Upvote 0

miker2069

Active Member
Licensed User
Longtime User
Yes, per device.

You then have 2 push tokens for this user, one for the iphone and one for the ipad, in your database both tokens must be assigned to this user. If you want a push notification for the user, you have to send the message to both tokens, because you can't know on which device the user is waiting for one of them. Instagram does the same thing for example, I have the app on my android phone and on my ipad, when someone writes to me I get the notification on both devices.

Or another approach would be to check which device was last active in the DB and then send to this device. But I would not recommend this.

I hope I didn't misunderstand your question.

I believe you've answered them, thank you. Seems like my assumptions were correct. It's my responsibility to maintain the tokens centrally and tokens are per device.
 
Upvote 0
Top