Skip to content

It doesn't work to send multiple notifications to different devices. #74

@adriano461997

Description

@adriano461997

I was trying to use only the token to send multiple notifications, first sending the token on the server and the server is responsible for subscribing to the token in a topic, then I use the topic to send notifications it happens that when only one token significations work, but When I try to sign up another token the notifications do not work.

I jumped this part and tried to use only topics instead of token, I do even process sending the token on the server and server Subscribes the token in the topic, but instead of being based on tokens if it was based on topics, in this case in each topic has only one User and so maybe I think it should work, but only when I try to send notifications on more than a topic core in the array, it gives a bad error of the Expo server.

My code

`

$tokens = utils::getTokens(1, "",false,10000);

    if($tokens["total"] == 0) {
        $data["estado"] = "erro";
        $data["texto"] = "Infelizmente nenhum pessoa disponivel para o envio de notificações foi encontrada!";
    } else {

        // Notify an interest with a notification, only one recipient will receive it

        $t = [];

        foreach ($tokens["data"] as $token) {
                $t[] = $token["token"];
        }


        try {

            $expo = \ExponentPhpSDK\Expo::normalSetup();

            $title = $_POST["titulo"];
            $body = $_POST["conteudo"];
            $notification = ['title' => $title, "body"=>$body, 'data'=> json_encode(array('someData' => 'goes here'))];

            $expo->notify($t, $notification);

        
        } catch (Exception $e){

        }

        $data["estado"] = "ok";
        $data["texto"] = null;
        $data["total_ok"] = 0;
        $data["total_error"] = 0;

`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions