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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rnww-plugin-wifi",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "React Native WebView WiFi Plugin with Expo support - Get WiFi information and manage connections",
5
5
  "main": "lib/bridge/index.js",
6
6
  "types": "lib/bridge/index.d.ts",
@@ -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 permissions = appContext.permissions
257
- if (permissions == null) {
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.askForPermissions(
267
- { result ->
268
- val granted = result[Manifest.permission.ACCESS_FINE_LOCATION]?.granted ?: false
269
- promise.resolve(mapOf(
270
- "locationGranted" to granted,
271
- "canAccessWifiInfo" to granted,
272
- "requiredPermissions" to if (granted) emptyList<String>()
273
- else listOf(Manifest.permission.ACCESS_FINE_LOCATION)
274
- ))
275
- },
276
- Manifest.permission.ACCESS_FINE_LOCATION
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(