Cordova Phonegap notification.beep忽略静音模式
您好,我正在使用cordova 2.7.0,我需要使用notification.beep()方法。但我有个问题,即使手机处于静音模式,我的应用程序也会响 有什么建议吗Cordova Phonegap notification.beep忽略静音模式,cordova,notifications,silent,beep,Cordova,Notifications,Silent,Beep,您好,我正在使用cordova 2.7.0,我需要使用notification.beep()方法。但我有个问题,即使手机处于静音模式,我的应用程序也会响 有什么建议吗 我正在使用iphone 5。更新CDVSound.m文件中的代码 注意:(void)setVolume适用于phonegap 3.4,我不确定其他旧版本的功能是否相同。。但必须有类似的功能来设置音量 在函数setVolume中添加以下两行代码,这将设置和设备上的声音设置相同的音量 float mVolume=[self getVo
我正在使用iphone 5。更新CDVSound.m文件中的代码 注意:(void)setVolume适用于phonegap 3.4,我不确定其他旧版本的功能是否相同。。但必须有类似的功能来设置音量 在函数setVolume中添加以下两行代码,这将设置和设备上的声音设置相同的音量
float mVolume=[self getVolumeLevel];
volume = [NSNumber numberWithFloat: mVolume];
完整代码如下所示
- (void)setVolume:(CDVInvokedUrlCommand*)command
{
NSString* callbackId = command.callbackId;
NSString* mediaId = [command.arguments objectAtIndex:0];
NSNumber* volume = [command.arguments objectAtIndex:1 withDefault:[NSNumber numberWithFloat:1.0]];
//This will set volume of the sound same as sound set on device.
float mVolume=[self getVolumeLevel];
volume = [NSNumber numberWithFloat: mVolume];
if ([self soundCache] != nil) {
CDVAudioFile* audioFile = [[self soundCache] objectForKey:mediaId];
if (audioFile != nil) {
audioFile.volume = volume;
if (audioFile.player) {
audioFile.player.volume = [volume floatValue];
}
[[self soundCache] setObject:audioFile forKey:mediaId];
}
}
}