Looking for best practices to manage Player ID for push notifications with Despia + OneSignal

Hi everyone,

I’m using Xano as my backend and @despia to convert my WeWeb app into a truly native iOS app. It’s a beautiful solution - the native plugin makes the process super easy, it works flawlessly, and their customer support has been outstanding. Public thanks to the Despia team for all the help getting everything set up.

For push notifications, I’m using a combination of Despia + OneSignal.

My question:
Despia automatically assigns a player_id to every device that installs the app. I’d now like to associate that player_id with the logged-in user, so that:

  • App is downloaded on iPhone A → Despia assigns a player_id to that device.

  • User X logs in on iPhone A → I link the player_id to User X in Xano.

  • User X logs out, User Y logs in on the same iPhone → I unlink the player_id from User X and link it to User Y.

This way, if I send a notification to User X, it only reaches the correct devices — not whichever user is currently logged into that iPhone.

I considered “clearing” the player IDs list on sign-out, but I don’t love that approach, since if a session expires they wouldn’t get notifications anymore — and I still want them to.

Any best practices you’d recommend for handling this mapping?

Thanks a lot in advance!
Jorge

1 Like

Thanks for the kind words - we really appreciate that :folded_hands:

The simplest approach would be to send the player ID to your login API using an add or edit operation on a linking table that associates player_id with user_id. This way, a single user can have multiple player IDs.

One important note: I’d recommend also including the device ID as the primary identifier in this relation. That ensures each device maps to exactly one player ID, so you only send a single push notification per user device.

Hope this helps! :slightly_smiling_face: