Hello I'm using cordova 2.7.0 and I need to use the notification.beep() method. But I've a problem, my app rings even if the phone is in silent mode.
any suggestions?
I'm using iphone 5.
Hello I'm using cordova 2.7.0 and I need to use the notification.beep() method. But I've a problem, my app rings even if the phone is in silent mode.
any suggestions?
I'm using iphone 5.
Update your code in CDVSound.m file
Note: (void)setVolume is for phonegap 3.4 , Im not sure if the function is same for other older versions as well.. But similar function must be there to set volume.
Add following 2 lines of code to function setVolume, This will set volume of the sound same as sound set on device.
float mVolume=[self getVolumeLevel];
volume = [NSNumber numberWithFloat: mVolume];
Complete code will be as follows
- (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];
}
}
}