Skip to content

Commit 47817a8

Browse files
committed
Add method to check state of canWrite permission
1 parent a05db17 commit 47817a8

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

android/src/main/java/com/devstepbcn/wifi/AndroidWifiModule.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
import org.json.JSONException;
3737
import org.json.JSONObject;
3838

39+
import com.facebook.react.bridge.Promise;
40+
3941
public class AndroidWifiModule extends ReactContextBaseJavaModule {
4042

4143
//WifiManager Instance
@@ -91,6 +93,17 @@ public void loadWifiList(Callback successCallback, Callback errorCallback) {
9193
}
9294
}
9395

96+
//Returns a promise that resolves a boolean of wether or not the canWrite
97+
//permission has been granted
98+
@ReactMethod
99+
public void checkCanWrite(Promise promise) {
100+
boolean canWrite = true;
101+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
102+
canWrite = Settings.System.canWrite(reactContext);
103+
}
104+
promise.resolve(canWrite);
105+
}
106+
94107
//Method to force wifi usage if the user needs to send requests via wifi
95108
//if it does not have internet connection. Useful for IoT applications, when
96109
//the app needs to communicate and send requests to a device that have no

0 commit comments

Comments
 (0)