Onesignal + PHP (App Notification)

Asked

Viewed 224 times

0

I have a code configured for PHP in it is sending the messages all ok for all applications, I want to configure the code to send only to an application. ( What I did after installing the app on the mobile phone generates a player_id on the site of onesignal). I took this id and pasted it in a field of mine in my form {Player}.

CODE:

function sendMessage(){

    $content = array(
        "en" => "Você Tem Um Novo Aviso Individual !!!"
    );

    $fields = array(
        'app_id' => "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",

        "include_player_ids" => ('all'),

       'data' => array("foo" => "bar"),
        'contents' => $content

    );

I want to know how to set up here "include_player_ids" => ('all'), for the code understand that since send to all ('ALL') it send to the player_id that is in this field {Player}.

1 answer

0

According to the documentation

inserir a descrição da imagem aqui

You should use the id of the user present in the application in the menu Users > All Users.

For example, you want to send the notification to the player with the following id : 32c3b33a-3390-4985-9b90-fac83fecfc81, then it would be

$fields = array(
   'app_id' => "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
   "include_player_ids" => ["32c3b33a-3390-4985-9b90-fac83fecfc81"],
   'data' => array("foo" => "bar"),
   'contents' => $content

    );

Browser other questions tagged

You are not signed in. Login or sign up in order to post.