rnww-plugin-wifi 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -17,6 +17,7 @@ import android.net.wifi.WifiManager
|
|
|
17
17
|
import android.net.wifi.WifiNetworkSpecifier
|
|
18
18
|
import android.os.Build
|
|
19
19
|
import android.util.Log
|
|
20
|
+
import androidx.core.app.ActivityCompat
|
|
20
21
|
import androidx.core.content.ContextCompat
|
|
21
22
|
import expo.modules.kotlin.Promise
|
|
22
23
|
import expo.modules.kotlin.modules.Module
|
|
@@ -253,8 +254,8 @@ class WifiModule : Module() {
|
|
|
253
254
|
// 권한 요청
|
|
254
255
|
AsyncFunction("requestPermission") { promise: Promise ->
|
|
255
256
|
try {
|
|
256
|
-
val
|
|
257
|
-
if (
|
|
257
|
+
val activity = appContext.currentActivity
|
|
258
|
+
if (activity == null) {
|
|
258
259
|
promise.resolve(mapOf(
|
|
259
260
|
"locationGranted" to false,
|
|
260
261
|
"canAccessWifiInfo" to false,
|
|
@@ -263,18 +264,17 @@ class WifiModule : Module() {
|
|
|
263
264
|
return@AsyncFunction
|
|
264
265
|
}
|
|
265
266
|
|
|
266
|
-
permissions.
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
)
|
|
267
|
+
val permissions = arrayOf(Manifest.permission.ACCESS_FINE_LOCATION)
|
|
268
|
+
ActivityCompat.requestPermissions(activity, permissions, 1002)
|
|
269
|
+
|
|
270
|
+
// Return current status (actual result would come through onRequestPermissionsResult)
|
|
271
|
+
val granted = hasLocationPermission()
|
|
272
|
+
promise.resolve(mapOf(
|
|
273
|
+
"locationGranted" to granted,
|
|
274
|
+
"canAccessWifiInfo" to granted,
|
|
275
|
+
"requiredPermissions" to if (granted) emptyList<String>()
|
|
276
|
+
else listOf(Manifest.permission.ACCESS_FINE_LOCATION)
|
|
277
|
+
))
|
|
278
278
|
} catch (e: Exception) {
|
|
279
279
|
Log.e(TAG, "Error requesting permission", e)
|
|
280
280
|
promise.resolve(mapOf(
|