kozhindev/expo-server-sdk-php
Composer 安装命令:
composer require kozhindev/expo-server-sdk-php
包简介
Server-side library for working with Expo push notifications using PHP
README 文档
README
Server-side library for working with Expo push notifications using PHP
Usage
- Require the package in your project
composer require kozhindev/exponent-server-sdk-php
- In a php file
require_once __DIR__.'/vendor/autoload.php'; $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);
Data can be added to notifications by providing it as a JSON object. For example:
// Build the notification data $notification = ['body' => 'Hello World!', 'data'=> json_encode(array('someData' => 'goes here'))];
Additional security
If you set up enhanced security in your Expo Dashboard (as described here), you will need to attach an authorization token to each push request:
// ... // 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);
统计信息
- 总下载量: 348
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-08-23