Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IOS Volume is always 0 #112

Open
Karniej opened this issue May 8, 2020 · 5 comments
Open

IOS Volume is always 0 #112

Karniej opened this issue May 8, 2020 · 5 comments

Comments

@Karniej
Copy link

Karniej commented May 8, 2020

Hello there,
I'm working on an app and cannot get the package to work
RN version is 62.2

I added and linked the library correctly, but whenever I call the function

SystemSettings.getVolume('system').then(data => console.log(data) I get the same amount all the time, even when I changed the volume on the simulator.

Anyone had the same issue ?

@Karniej
Copy link
Author

Karniej commented May 8, 2020

Okay I found out that it doesn't work on Simulator - only on Physical device - please add it to the docummentation.
If you don't have time - i'll make a PR :)

@LeDanielH
Copy link

hello dev, first of all, thank you for your hard work. @Karniej Unfortunatelly I also have this issue:

All of these return 0 on IOS:

const volumeMusic = await this.getSystemSettingsVolume('music');
const volumeSystem = await this.getSystemSettingsVolume('system');
const volumeCall = await this.getSystemSettingsVolume('call');
const volumeAlarm = await this.getSystemSettingsVolume('alarm');
const volumeNotification = await this.getSystemSettingsVolume('notification');
const volumeRing = await this.getSystemSettingsVolume('ring');

but when using listener, IOS returns data.value that has expected value

type TSystemSettingsVolumeListenerData = {
    alarm: number,
    call: number,
    music: number,
    notification: number,
    ring: number,
    system: number,
    value: number,
};

SystemSetting.addVolumeListener((data: TSystemSettingsVolumeListenerData) => {
  // IOS does not return anything but data.value
  // Android lists TSystemSettingsVolumeListenerData
  const volume = isIos ? data.value : data.music; // workaround
  this._setAppVolumeLevel(volume);
});

@Karniej
Copy link
Author

Karniej commented May 28, 2020

@LeDanielH I recommend trying out on a physical device -then you can test it out correctly. :)

@jqn
Copy link

jqn commented Feb 17, 2021

@LeDanielH this library only works with physical devices. A simulator always returns 0 for volume and a device returns the correct volume level.

@DrakosPZ
Copy link

I have a similar problem and to me it seems like the entire library isn't working for me.

I tested it on a device and installed the library normally with npm i

My Code is as followed
` componentDidMount(): void {
this.interval = setInterval(this.checkVolume, 500);
}

checkVolume() {
	SystemSetting.getVolume('music').then((checkedVolume)=>{
		this.setState({musicVolume: checkedVolume});
	});
	SystemSetting.getVolume('system').then((checkedVolume)=>{
		this.setState({systemVolume: checkedVolume});
	});
	SystemSetting.getVolume('call').then((checkedVolume)=>{
		this.setState({callVolume: checkedVolume});
	});
	SystemSetting.getVolume('alarm').then((checkedVolume)=>{
		this.setState({alarmVolume: checkedVolume});
	});
	SystemSetting.getVolume('notification').then((checkedVolume)=>{
		this.setState({notificationVolume: checkedVolume});
	});
	SystemSetting.getVolume('ring').then((checkedVolume)=>{
		this.setState({ringVolume: checkedVolume});
	});
}

`

No matter how much I change the volume on my device, it always stays 0?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants