Ionic 4 本地通知声音在 Oreo+ 中不起作用
Ionic 4 local notification sound not working in Oreo+
我正在构建一个 Ionic 4 应用程序,本地通知 sound
在 Nougat 中工作,但在 Oero 中不工作。
只是播放默认声音,忽略 sound
我已阅读此处:
https://distriqt.github.io/ANE-PushNotifications/m.FCM-GCM%20Payload
Sounds on individual notifications were deprecated in Android O (API 26). You now have to set them on a channel.
那个频道是必要的
this.localNot.schedule({
id: id,
// channel: id, // IS NOT Possible to set
title: title,
text: 'Some text',
sound: `file://assets/audio/mySOUNDFILE.mp3`,
icon: 'file://assets/img/logo/favicon.png', // TODO resident Img,
color: colour
});
但是就像我在 ionic 中没有字段 "channel" 可用一样,我在这里设置了一个问题,但很接近。
https://github.com/ionic-team/ionic/issues/19696
你有什么建议吗?
我正在用这个
"git+https://github.com/Steffaan/cordova-plugin-local-notifications.git",
home.ts
declare var cordova: Cordova;
@Component({
selector: 'app-home', ...
并发送通知
cordova.plugins.notification.local.schedule({
id: Myid,
title: tit,
text: txt,
priority: MyPriority,
channel: 'MyChannel',
sound: `file://assets/audio/${sound}.mp3`,
foreground: true,
lockscreen: true,
vibrate: vib,
wakeup: true,
});
哪里
priority: MyPriority,
channel: 'MyChannel',
必须不同,对于每个不同的声音
在文件/node_modules/@types/cordova/index.d.ts 我设置:
interface CordovaPlugins {
notification: any;
...
}
我正在构建一个 Ionic 4 应用程序,本地通知 sound
在 Nougat 中工作,但在 Oero 中不工作。
只是播放默认声音,忽略 sound
我已阅读此处: https://distriqt.github.io/ANE-PushNotifications/m.FCM-GCM%20Payload
Sounds on individual notifications were deprecated in Android O (API 26). You now have to set them on a channel.
那个频道是必要的
this.localNot.schedule({
id: id,
// channel: id, // IS NOT Possible to set
title: title,
text: 'Some text',
sound: `file://assets/audio/mySOUNDFILE.mp3`,
icon: 'file://assets/img/logo/favicon.png', // TODO resident Img,
color: colour
});
但是就像我在 ionic 中没有字段 "channel" 可用一样,我在这里设置了一个问题,但很接近。 https://github.com/ionic-team/ionic/issues/19696
你有什么建议吗?
我正在用这个 "git+https://github.com/Steffaan/cordova-plugin-local-notifications.git",
home.ts
declare var cordova: Cordova;
@Component({
selector: 'app-home', ...
并发送通知
cordova.plugins.notification.local.schedule({
id: Myid,
title: tit,
text: txt,
priority: MyPriority,
channel: 'MyChannel',
sound: `file://assets/audio/${sound}.mp3`,
foreground: true,
lockscreen: true,
vibrate: vib,
wakeup: true,
});
哪里
priority: MyPriority,
channel: 'MyChannel',
必须不同,对于每个不同的声音
在文件/node_modules/@types/cordova/index.d.ts 我设置:
interface CordovaPlugins {
notification: any;
...
}