PHP code example of alymosul / exponent-server-sdk-php

1. Go to this page and download the library: Download alymosul/exponent-server-sdk-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

alymosul / exponent-server-sdk-php example snippets


     
    $channelName = 'news';
    $recipient= 'ExponentPushToken[unique]';
    
    // You can quickly bootup an expo instance
    $expo = \ExponentPhpSDK\Expo::normalSetup();
    
    // Subscribe the recipient to the server
    $expo->subscribe($channelName, $recipient);
    
    // Build the notification data
    $notification = ['body' => 'Hello World!'];
    
    // Notify an interest with a notification
    $expo->notify([$channelName], $notification);
 

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

$channelName = 'user_528491';
$recipient = 'ExponentPushToken[unique]';

// …

// Subscribe the recipient to the server
$expo->subscribe($channelName, $recipient);

// …

// Notify an interest with a notification, only one recipient will receive it
$expo->notify([$channelName], $notification);

$channelName = 'group_4815';

$recipient1 = 'ExponentPushToken[unique1]';
$recipient2 = 'ExponentPushToken[unique2]';

// …

// Subscribe the recipients to the server
$expo->subscribe($channelName, $recipient1);
$expo->subscribe($channelName, $recipient2);

// …

// Notify an interest with a notification, the 2 recipients will receive it
$expo->notify([$channelName], $notification);

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

    // ...
    
    // Bootup an expo instance
    $expo = \ExponentPhpSDK\Expo::normalSetup();
    
    // Fetch your access token from where you stored it
    $accessToken = 'your_expo_access_token';
    
    // The access token will be attached to every push request you make hereafter
    $expo->setAccessToken($accessToken);
    
    // Notify an interest with a notification
    $expo->notify([$channelName], $notification);