【发布时间】:2020-08-25 00:51:46
【问题描述】:
我正在开发一个带有 expo 和推送通知的应用程序工作正常,但没有声音并且它不会弹出..
注意:它只会振动,没有提示音。
我的客户端
if (Constants.isDevice) {
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') {
alert('Failed to get push token for push notification!');
return;
}
token = await Notifications.getExpoPushTokenAsync();
console.log(token);
this.setState({ expoPushToken: token });
} else {
alert('Must use physical device for Push Notifications');
}
if (Platform.OS === 'android') {
Notifications.createChannelAndroidAsync('notification-sound-channel', {
name: 'Notification Sound Channel',
sound: true,
priority: 'max',
vibrate: [0, 250, 250, 250],
});
}
我的服务器端是php laravel:https://github.com/Alymosul/exponent-server-sdk-php
$notification = [
'title' => 'test title',
'body' => 'test body'
'channelId' => 'notification-sound-channel',
];
我还使用 expo 推送通知工具对其进行了测试:https://expo.io/notifications,它的工作原理相同(振动没有声音或弹出)
环境
博览会:“^37.0.8”,
SDK 版本:27,
测试设备android版本:9
【问题讨论】:
标签: android react-native push-notification expo