PHP code example of kozhindev / expo-server-sdk-php

1. Go to this page and download the library: Download kozhindev/expo-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/ */

    

kozhindev / expo-server-sdk-php example snippets


     
    $token = 'ExponentPushToken[unique]';
    
    $expo = new \ExponentPhpSDK\Expo();
    
    // Build the notification data
    $notification = ['body' => 'Hello World!'];
    
    // Notify a token (or several tokens) with a notification
    $expo->notify([$token], $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);