OneSignal Plugin sending notifications to wrong user

Hey Guys,

I have the OneSignal plugin to send push notifications to the users mobiles. I am using the RegisterWithUser on login to register the device with the user and the Unregister action on logout to prevent the notifications from being delivered when someone logs out.

The problem is that when I login with a different user, the notification intended for the first user appears to the second user as well, even when using the SendPushNotificationToUserId action.

Any thoughts on this?


Hi Carlos,

Could it be the Unregister somehow goes wrong? If the device receives push notifications for both users, they must both still be registered.

Hi Kilian,

Wasn't the Unregister, but thanks for the reply. It seems that the only way to get the users apart is either to tag them or to get their player id. Unfortunately the player id doen't come in the API response.



Hi Carlos,

You can use SendPushNotificationToUser. I check against the Device Table to see if they have a device registered. I then send then correct message to the right user.

Hope this helps




Hi Mark,

Thanks for the reply. It seems that the problem was happening because we forgot to clean the user table from the onesignal. We regitered users before we had the unregister in the logout so we had duplicate entries.

Once we cleaned the users table from the onesignal and had the register and unregister working properly it all went ok.

Thanks anyway for the reply.