Languages

Menu
Sites
Language
Send Push notification to specific device

Hello,

I need to send push notification on specific devices.

For example: Suppose an application registered for push notification and get push notification from push server.

And we have 5 samsung gear s2 devices and we need to send notification on 3 devices then how can we achive the same.

our code :

document.addEventListener("DOMContentLoaded", function(event) {
 
    var service = new tizen.ApplicationControl("http://tizen.org/appcontrol/operation/push_test");

    function errorCallback(response) 
    {
        alert('The following error occurred: ' +  response.name);
    }

    function registerSuccessCallback(id) 
    {
       tizen.push.connectService(notificationCallback, errorCallback1);
        console.log("Registration succeeded with id: " + id);
    }
 
    tizen.push.registerService(service, registerSuccessCallback, errorCallback);
 
    $.ajax({
        type: 'POST',
        contentType: 'json',
        url: 'https://apnortheast.push.samsungosp.com:8088/spp/pns/api/push',
        headers: {"appID": 'XmHU0D7kJl', 
            "appSecret": 'vYd47IKgpAWJlNQQrtgkH/2Bgd0AAA=='
        },                   
        data: JSON.stringify({ "regID":'04a1e05c336dc9d362cb4fc7cb5477312b263f6357e96326f18c0e40edf79d93e9eb43605163ea91d6aec9cfa072379ddb8c', 
            "requestID":"000001",
            "message":"badgeOption=SET&badgeNumber=10&action=ALERT&alertMessage=Hi, You got push message",
            "appData":"Hello this is the message received form push server"
        }),
        dataType: 'json',
    }).done(function ( data ) { 
     
        console.log(JSON.stringify(data)); 
        }
    ).error(function(error){
        console.log(error);
    });
      
    function errorCallback1(response)
    {
        alert('The following error occurred in error callback1: ' +  response.name);
    }

    function notificationCallback(noti)
    {
        console.log(noti);
        alert("Notification received with alert message: " + noti.appData);
        var msg= noti.appData;
        $('#msg_id').text(msg);
    }

});

Responses

1 Replies
Iqbal Hossain