Cordova Phonegap本机通知声音
有没有办法在Phonegap中使用本机/默认通知声音进行通知(特别是Phonegap的PushPlugin)?目前它确实使用我的默认通知声音,但是,我想添加一个选项来自定义通知声音,以使用手机上已有的任何默认声音 这可能吗?如果是这样,我如何在iOS和Android上实现它 仅供参考,我正在为我的应用程序使用Ionic 谢谢Cordova Phonegap本机通知声音,cordova,audio,push-notification,ionic,Cordova,Audio,Push Notification,Ionic,有没有办法在Phonegap中使用本机/默认通知声音进行通知(特别是Phonegap的PushPlugin)?目前它确实使用我的默认通知声音,但是,我想添加一个选项来自定义通知声音,以使用手机上已有的任何默认声音 这可能吗?如果是这样,我如何在iOS和Android上实现它 仅供参考,我正在为我的应用程序使用Ionic 谢谢 import android.content.res.AssetFileDescriptor; import android.media.MediaPlayer; impo
import android.content.res.AssetFileDescriptor;
import android.media.MediaPlayer;
import java.io.IOException;
String soundName = extras.getString("sound");
if (soundName != null) {
MediaPlayer player = new MediaPlayer();
AssetFileDescriptor file;
try {
file = getAssets().openFd("www/sounds/"+soundName+".mp3");
player.setDataSource(file.getFileDescriptor(), file.getStartOffset(), file.getLength());
defaults = Notification.DEFAULT_LIGHTS | Notification.DEFAULT_VIBRATE;
mBuilder.setDefaults(defaults);
player.prepare();
player.start();
} catch (IOException e) {
}
}
mNotificationManager.notify((String) appName, notId, mBuilder.build());
源于您可以尝试my,但这仅适用于android。您可以在这个插件中控制振动、声音、灯光和铃声。设备准备好后,只需使用
PushNotification.showPushSettings()
,它将弹出一个窗口。看看这一点:这也是:StackOverflow上不建议使用仅链接的答案。请尽量在答案中添加更多内容。