-
Notifications
You must be signed in to change notification settings - Fork 79
Description
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;
`