Support Topics Documentation Slack YouTube Blog

Sending push to specific mobile id

I have the following code.

function sendPushMessage()
{
console.log(“sending push”);
var channel = “reports”,
message = “התלונה טופלה”,
publishOptions = new Backendless.PublishOptions({
headers: {
“ios-alert-title” : “התלונה טופלה”,
“ios-alert-subtitle”: “מוקד קררית ים”,
“ios-alert-body”: “תלונתך טופלה ונסגרה מהסיבה:”+repoData[localMarkerId-1].closeDesc,
“ios-sound”: “https://city.repoai.com/ok.wav”,
“android-ticker-text”: “תלונתך טופלה”,
“android-content-title”: “התלונה טופלה”,
“android-content-text”: “תלונתך טופלה ונסגרה מהסיבה:”+repoData[localMarkerId-1].closeDesc
}
}),
deliveryOptions = new Backendless.DeliveryOptions({
pushSinglecast: mobileList // devices IDs
});

Backendless.Messaging.publish( channel, message, publishOptions, deliveryOptions )
.then( function( messageStatus ) {
})
.catch( function( error ) {
});

}

I want to push to specific mobile that is in mobile id list, and not to channel.

Hello,

Any message should be sent to some channel or channels. When you specify pushSinglecast, you’re only filtering the recipients, but they still have to be subscribed to that channel.
So for example if you have devices A, B and C, and you want to send a message to A and C only, you still have to subscribe them to some channel (say, default), and then use pushSinglecast from deliveryOptions to only send a message to A and C, but not B, while they all are subscribed to default channel.

dear friend, this is what i did, but the entire channel got it.

i will try to check it with two diffrent mobile mobile.

We verified that push singlecast works correctly in our samples, and only the specified devices receive the message, not the whole channel. Your code seems correct as well, but apparently there’s something that leads to incorrect behavior in your case. If you could provide us a minimal sample that would reproduce the problem you describe, we should be able to investigate this further.