gpt4 book ai didi

ionic-framework - Android 上的推送通知没有声音( ionic 电容器)

转载 作者:行者123 更新时间:2023-12-05 07:07:58 25 4
gpt4 key购买 nike

当我在电容器中实现插件 PushNotification 时遇到问题,问题是当手机收到推送通知时不会发出任何声音。这是我的代码。

PushNotifications.addListener('pushNotificationReceived',
(notification: PushNotification) => {
console.log('Push received: ',JSON.stringify(notification));

}

这是capacitor.config.json中的设置

"PushNotifications": {
"presentationOptions": ["badge", "sound", "alert"]
}

感谢您的帮助。

最佳答案

显示创建的通知 channel 详细信息。
那就不要在红米或者小米手机上测试了。

addListenersForNotifications = async () => {
await PushNotifications.addListener('registration', 'registration Name');
await PushNotifications.addListener('registrationError', 'error');
await PushNotifications.createChannel({
id: 'fcm_default_channel',
name: 'app name',
description: 'Show the notification if the app is open on your device',
importance: 5,
visibility: 1,
lights: true,
vibration: true,
});
await PushNotifications.addListener('pushNotificationReceived', this.pushNotificationReceived);
await PushNotifications.addListener('pushNotificationActionPerformed', this.pushNotificationActionPerformed);

};

关于ionic-framework - Android 上的推送通知没有声音( ionic 电容器),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61990880/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com