Expo keep adding push notifications and send everything

Hi,

I follow this tutorial https://docs.expo.io/versions/latest/guides/push-notifications

I was able to send notification, but every time I send, it also send the previous.

So first time ok.
Then second time, I receive two notifications, …

any help on how to avoid send the same notification?

Hey @expo2019,

Can you share the code that you implemented that handles the notification delivery? Also, can you try using the testing tool here and see if it sends multiple? Push Notification Tool — Expo

Cheers,

Adam

I tested and it adds the messages when I use the same string.

If I replace otherInterest with something else, then it sends just one notification.

<?php

require_once __DIR__.'/vendor/autoload.php';

error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
  
$interestDetails = ['otherInterest', 'ExponentPushToken[...]'];

// You can quickly bootup an expo instance
$expo = \ExponentPhpSDK\Expo::normalSetup();

// echo 'subscribing';
// Subscribe the recipient to the server
$expo->subscribe($interestDetails[0], $interestDetails[1]);


// $notification = ['body' => 'Hello World!'];
$notification = ['body' => 'Hello Expo!', 'data'=> json_encode(array('someData' => 'goes here'))];

// Notify an interest with a notification
$expo->notify($interestDetails[0], $notification);

// echo 'Notification sent.';

?>

Ah. The PHP server is not maintained by the Expo team, but rather by fellow exponauts in the community. I would raise an issue here if you can create a reproducible example. Did you try the testing tool to see if the same thing occurs?

1 Like

Thank you Adam. It is probably me that is misusing the library. I will try the testing tool.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.