Я использую его с ядром PHP, и он работает (со звуком, вибрацией и всплывающим окном).
Это код m PHP, который срабатывает при нажатии кнопки.
require_once 'vendor/autoload.php';
$channelName = 'userdId'; // from database
$recipient= 'ExponentPushToken[lHS_FNBss5OD-XT-rGgRLE]';
// 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 = ['title' => "Notification Title", 'body' => 'This is a testing notification.', 'channelId' => 'notification-sound-channel',];
// Notify an interest with a notification
$expo->notify([$channelName], $notification);
Это мой собственный код React
import React, { useEffect, useState } from "react";
import { StyleSheet, Text, View, Button, Platform } from "react-native";
import { Notifications } from "expo";
import * as Permissions from "expo-permissions";
export default function App() {
const [expoPushToken, setExpoPushToken] = useState("");
useEffect(() => {
this.getPushNotificationPermissions();
});
getPushNotificationPermissions = async () => {
const { status: existingStatus } = await Permissions.getAsync(
Permissions.NOTIFICATIONS
);
let finalStatus = existingStatus;
if (existingStatus !== "granted") {
const { status } = await Permissions.askAsync(Permissions.NOTIFICATIONS);
finalStatus = status;
}
if (finalStatus !== "granted") {
return;
}
const tok = await Notifications.getExpoPushTokenAsync();
setExpoPushToken(tok);
};
if (Platform.OS === "android") {
Notifications.createChannelAndroidAsync("notification-sound-channel", {
name: "Notification Sound Channel",
sound: true,
priority: "max",
vibrate: [0, 250, 250, 250],
});
}
return (
<View>
<Text>PHP Notification Testing</Text>
</View>
);
}