How to switch ON/OFF the GPS in iOS devices using appium


Am doing the automation testscript for iOS devices.I need to verify the application in GPS ON/OFF.
So i setted the following arguments ,but it’s not working for me

    capabilities.setCapability("locationServicesEnabled", true);
    capabilities.setCapability("locationServicesAuthorized", false);

Note I Used mobile data only.

can you please help me to overcome the issue