如何做到和支付宝一样,关了app也能正常收到语音播报“支付宝收款到账88元”。
//监听商家收款推送消息,语音播报
document.addEventListener("plusready", function() {
plus.push.addEventListener("receive", function(msg) {
if(mui.os.android) {
var main = plus.android.runtimeMainActivity();
var SpeechUtility = plus.android.importClass('com.iflytek.cloud.SpeechUtility');
SpeechUtility.createUtility(main, "appid=123");
var SynthesizerPlayer = plus.android.importClass('com.iflytek.cloud.SpeechSynthesizer');
var play = SynthesizerPlayer.createSynthesizer(main, null);
play.startSpeaking(("支付宝收款到账88元", null);
} else {
var AVSpeechSynthesizer = plus.ios.importClass("AVSpeechSynthesizer");
var AVSpeechUtterance = plus.ios.importClass("AVSpeechUtterance");
var AVSpeechSynthesisVoice = plus.ios.import("AVSpeechSynthesisVoice");
var sppech = new AVSpeechSynthesizer();
var voice = AVSpeechSynthesisVoice.voiceWithLanguage("zh-CN");
var utterance = AVSpeechUtterance.speechUtteranceWithString("支付宝收款到账88元");
utterance.setVoice(voice);
sppech.speakUtterance(utterance);
}
}, false);
}, false);
7 个回复
猫猫猫猫 - 用户已离线
安卓的话,需要厂商白名单
距离您98米 (作者) - 哈哈
安卓锁屏了还可以语音播报,ios锁屏了就语音播报不了,不知道如何让手机锁屏了也能执行到receive
下一页丶翻
我离线打包为啥这个plus.push.addEventListener("receive"监听不触发,在线打包的可以就能触发
魏琦
大佬解决了吗?
nininiccc
请问这个问题解决了吗?
FullStack - 【插件开发】【专治疑难杂症】【ios上架、马甲包、白包、过审、已成功上架过几百个】【多款插件已上架:https://ext.dcloud.net.cn/publisher?id=22130】【非诚勿扰】QQ:543610866
后台离线推送语言播报、xx到账xx元(ios):https://ext.dcloud.net.cn/plugin?id=8452
FullStack - 【插件开发】【专治疑难杂症】【ios上架、马甲包、白包、过审、已成功上架过几百个】【多款插件已上架:https://ext.dcloud.net.cn/publisher?id=22130】【非诚勿扰】QQ:543610866
离线文本转语音、支持生成音频、下载或播放状态监听(ios) :https://ext.dcloud.net.cn/plugin?id=9286