Reputation: 315
I have a NodeJS backend application I'm trying to configure to be able to send Push notifications to an IOS frontend application. I want to be able to send notifications to specific users (intend to use PlayerIds to send notifications). I am not sure how to obtain the users playerIds that I want to send.
var message = {
app_id: "5eb5a37e-b458-11e3-ac11-000c2940e62c",
contents: {"en": "English Message"},
include_player_ids: ["6392d91a-b206-4b7b-a620-cd68e32c3a76","76ece62b-bcfe-468c-8a78-839aeaa8c5fa","8e0f21fa-9a5a-4ae7-a9a6-ca1f24294b86"]
};
sendNotification(message);
My question is how can I pull these player_ids dynamically and match them against users in my DB? Thanks!
Onesignal documentation https://documentation.onesignal.com/reference#create-notification
Upvotes: 1
Views: 6657
Reputation: 3948
You can set your user id from your DB by calling setExternalUserId
, example:
OneSignal.setExternalUserId("123");
You can then use "filters"
with include_external_user_ids
on the OneSignal create notification REST API POST call on your server with the tag field to target your users.
Upvotes: 3