Tested almost every function I could get my hands on at the moment and found out this:
<uses-permission android:name="android.permission.WRITE_SETTINGS"
tools:ignore="ProtectedPermissions" />
does not really make the app have write setting permissions at load.
Instead, what worked for me, was to navigate to the permissions page using the below code that is given in the example folder here: example/src/HotspotScreen.tsx
async () => {
try {
await HotspotManager.openWriteSettings();
} catch (error: any) {
if (error instanceof TetheringError) {
ToastAndroid.show(error.message, ToastAndroid.LONG)
}
console.log(error);
}
}
that way we prompt the user to enable the permissions himself and everything works smoothly after that.
As for other permissions like FINE / COURSE_LOCATION, again I faced the same problem with the log showing "Error UID [exampleUID] does not have FINE / COURSE_LOCATION permissions. To bypass this I used this code block :
import { PermissionsAndroid } from 'react-native';
async function requestMultiplePermissions() {
try {
const granted = await PermissionsAndroid.requestMultiple([
PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
PermissionsAndroid.PERMISSIONS.ACCESS_COARSE_LOCATION,
]);
if (
granted['android.permission.ACCESS_FINE_LOCATION'] ===
PermissionsAndroid.RESULTS.GRANTED &&
granted['android.permission.ACCESS_COARSE_LOCATION'] ===
PermissionsAndroid.RESULTS.GRANTED
) {
console.log('Location permissions granted');
// Call the desired function here
} else {
console.log('Location permissions denied');
}
} catch (err) {
console.warn(err);
}
}
@aboozaid Overall, if you bypass the permissions "errors" (which ain't exactly errors per se), everything seems to work as intended.
I would like to thank you for publishing this, after such short notice.
I only have one question, which is really important to me and I think many others that will use this module.
Can you add a function in the example where the SSID and Password of the enabled Hotspot are predefined by the programmer, so the user doesn't have to navigate to it's page and put them manually after opening it through your module?
Adding an example of it would be great!
Thank you for your time and I hope this proves to be helpful.