codeliter/expo-notification-pusher

从您的后端向 expo 应用发送推送通知

1.0.0 2020-06-12 08:17 UTC

This package is auto-updated.

Last update: 2024-09-12 17:54:30 UTC


README

这是一个实用库,它使您轻松地从服务器向您的 expo 应用发送推送通知。

功能

  • 向特定渠道发送通知(仅限 Android)。
  • 智能向不同的 expo 项目发送推送通知。
  • 如果接收者超过建议的 100 人,则自动批量推送通知。

要求

安装

使用 Composer

要使用 Composer 安装 expo-notification-pusher,请将以下内容添加到您的 composer.json 文件中

{
    "require": {
        "codeliter/expo-notification-pusher": "1.*"
    }
}

或运行以下命令

composer require codeliter/expo-notification-pusher
  • 从源代码安装 Clone 仓库,运行以下命令
git clone https://github.com/codeliter/expo-notification-pusher.git

在代码顶部添加

require_once '/path/to/expo-notification-pusher/src/Expo/PushNotification.php';

用法

发送基本的推送通知

$send = PushNotification::send(['ExponentPushToken[oj4iK4CRA7Ry8gDCrtawef]'], 'Test','Test body');
  • 第一个参数必须是一个有效的 expo 令牌数组。例如 ['ExponentPushToken[oj4iK4CRA7Ry8gDCrtawef]']

  • 第二个参数是推送通知的标题。这是必需的。

  • 第三个参数是推送通知的正文。这是必需的。

发送标准推送通知

// The channel we want this notification to be pushed to (Android Only). This allows for grouping of notifications.
// The channel must have been initialized inside the expo app already.
$channel = "notifications";

// This contains data we need inside the app to move the user to a specific screen or handle some other things.
$data  = [
    "intent"=>'notification',
    'type'=>'chat',
    'message'=>'Hello'
];

$send = PushNotification::send(['ExponentPushToken[oj4iK4CRA7Ry8gDCrtawef]'], 'Test','Test body', $channel, $data);

Codeliter 制作,满满的爱♥