@abrarmehraj/permission-kit 0.1.1 → 0.1.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/README.md +24 -2
- package/android/build/.transforms/11f559a2ebefa85800586e59edd71959/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/expo/modules/permissionkit/{ExpoPermissionKitModule$definition$lambda$2$$inlined$AsyncFunctionWithoutArgs$1.dex → ExpoPermissionKitModule$definition$lambda$4$$inlined$AsyncFunctionWithoutArgs$1.dex} +0 -0
- package/android/build/.transforms/11f559a2ebefa85800586e59edd71959/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/expo/modules/permissionkit/ExpoPermissionKitModule$definition$lambda$4$$inlined$AsyncFunctionWithoutArgs$2.dex +0 -0
- package/android/build/.transforms/11f559a2ebefa85800586e59edd71959/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/expo/modules/permissionkit/ExpoPermissionKitModule$definition$lambda$4$$inlined$AsyncFunctionWithoutArgs$3.dex +0 -0
- package/android/build/.transforms/11f559a2ebefa85800586e59edd71959/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/expo/modules/permissionkit/ExpoPermissionKitModule$definition$lambda$4$$inlined$AsyncFunctionWithoutArgs$4.dex +0 -0
- package/android/build/.transforms/11f559a2ebefa85800586e59edd71959/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/expo/modules/permissionkit/ExpoPermissionKitModule.dex +0 -0
- package/android/build/.transforms/4df5c4d065593aa9636568712527225c/transformed/classes/classes_dex/classes.dex +0 -0
- package/android/build/intermediates/compile_library_classes_jar/debug/bundleLibCompileToJarDebug/classes.jar +0 -0
- package/android/build/{tmp/kotlin-classes/debug/expo/modules/permissionkit/ExpoPermissionKitModule$definition$lambda$2$$inlined$AsyncFunctionWithoutArgs$1.class → intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/expo/modules/permissionkit/ExpoPermissionKitModule$definition$lambda$4$$inlined$AsyncFunctionWithoutArgs$1.class} +0 -0
- package/android/build/{tmp/kotlin-classes/debug/expo/modules/permissionkit/ExpoPermissionKitModule$definition$lambda$2$$inlined$AsyncFunctionWithoutArgs$2.class → intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/expo/modules/permissionkit/ExpoPermissionKitModule$definition$lambda$4$$inlined$AsyncFunctionWithoutArgs$2.class} +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/expo/modules/permissionkit/ExpoPermissionKitModule$definition$lambda$4$$inlined$AsyncFunctionWithoutArgs$3.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/expo/modules/permissionkit/ExpoPermissionKitModule$definition$lambda$4$$inlined$AsyncFunctionWithoutArgs$4.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/expo/modules/permissionkit/ExpoPermissionKitModule.class +0 -0
- package/android/build/intermediates/runtime_library_classes_jar/debug/bundleLibRuntimeToJarDebug/classes.jar +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/counters.tab +1 -1
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/last-build.bin +0 -0
- package/android/build/kotlin/compileDebugKotlin/classpath-snapshot/shrunk-classpath-snapshot.bin +0 -0
- package/android/build/kotlin/compileDebugKotlin/local-state/build-history.bin +0 -0
- package/android/build/{intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/expo/modules/permissionkit/ExpoPermissionKitModule$definition$lambda$2$$inlined$AsyncFunctionWithoutArgs$1.class → tmp/kotlin-classes/debug/expo/modules/permissionkit/ExpoPermissionKitModule$definition$lambda$4$$inlined$AsyncFunctionWithoutArgs$1.class} +0 -0
- package/android/build/{intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/expo/modules/permissionkit/ExpoPermissionKitModule$definition$lambda$2$$inlined$AsyncFunctionWithoutArgs$2.class → tmp/kotlin-classes/debug/expo/modules/permissionkit/ExpoPermissionKitModule$definition$lambda$4$$inlined$AsyncFunctionWithoutArgs$2.class} +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/permissionkit/ExpoPermissionKitModule$definition$lambda$4$$inlined$AsyncFunctionWithoutArgs$3.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/permissionkit/ExpoPermissionKitModule$definition$lambda$4$$inlined$AsyncFunctionWithoutArgs$4.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/expo/modules/permissionkit/ExpoPermissionKitModule.class +0 -0
- package/android/src/main/java/expo/modules/permissionkit/ExpoPermissionKitModule.kt +42 -4
- package/build/ExpoPermissionKitModule.d.ts +2 -0
- package/build/ExpoPermissionKitModule.d.ts.map +1 -1
- package/build/ExpoPermissionKitModule.js.map +1 -1
- package/build/PermissionKit.d.ts +12 -0
- package/build/PermissionKit.d.ts.map +1 -1
- package/build/PermissionKit.js +35 -0
- package/build/PermissionKit.js.map +1 -1
- package/package.json +1 -1
- package/plugin/build/index.js +10 -5
- package/src/ExpoPermissionKitModule.ts +2 -0
- package/src/PermissionKit.ts +40 -0
- package/android/build/.transforms/11f559a2ebefa85800586e59edd71959/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/expo/modules/permissionkit/ExpoPermissionKitModule$definition$lambda$2$$inlined$AsyncFunctionWithoutArgs$2.dex +0 -0
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ In your `app.json`, add the plugin and specify the permissions you want:
|
|
|
36
36
|
[
|
|
37
37
|
"@abrarmehraj/permission-kit",
|
|
38
38
|
{
|
|
39
|
-
"permissions": ["batteryOptimization"]
|
|
39
|
+
"permissions": ["batteryOptimization", "overlay"]
|
|
40
40
|
}
|
|
41
41
|
]
|
|
42
42
|
]
|
|
@@ -57,6 +57,7 @@ Add the required permission to your `android/app/src/main/AndroidManifest.xml` O
|
|
|
57
57
|
|
|
58
58
|
```xml
|
|
59
59
|
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
|
|
60
|
+
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
|
60
61
|
```
|
|
61
62
|
|
|
62
63
|
> **Note**: PermissionKit requires Expo Modules architecture. If you are on React Native 0.69+, you likely already have it. Make sure you run `npx pod-install` for iOS.
|
|
@@ -90,6 +91,26 @@ const result = await PermissionKit.checkBatteryOptimization();
|
|
|
90
91
|
// Use on app start to know the current state
|
|
91
92
|
```
|
|
92
93
|
|
|
94
|
+
### `PermissionKit.overlay()`
|
|
95
|
+
|
|
96
|
+
Checks if the app is allowed to draw over other apps (System Alert Window). If not, automatically opens the Android Settings "Display over other apps" dialog, waits for the user to return, and re-checks on resume.
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
const result = await PermissionKit.overlay();
|
|
100
|
+
|
|
101
|
+
if (result.status === 'granted') {
|
|
102
|
+
// App is allowed to draw over others
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### `PermissionKit.checkOverlay()`
|
|
107
|
+
|
|
108
|
+
Check the current overlay status without opening settings.
|
|
109
|
+
|
|
110
|
+
```ts
|
|
111
|
+
const result = await PermissionKit.checkOverlay();
|
|
112
|
+
```
|
|
113
|
+
|
|
93
114
|
---
|
|
94
115
|
|
|
95
116
|
## Platform Support
|
|
@@ -97,6 +118,7 @@ const result = await PermissionKit.checkBatteryOptimization();
|
|
|
97
118
|
| Feature | Android | iOS |
|
|
98
119
|
|-----------------------|---------|------------------|
|
|
99
120
|
| Battery Optimization | ✅ | `unavailable` ⚠️ |
|
|
121
|
+
| Overlay Permission | ✅ | `unavailable` ⚠️ |
|
|
100
122
|
|
|
101
123
|
> **iOS Note**: iOS does not have Android-style battery optimization. Calling `batteryOptimization()` on iOS immediately returns `{ status: 'unavailable' }` without showing any UI.
|
|
102
124
|
|
|
@@ -105,10 +127,10 @@ const result = await PermissionKit.checkBatteryOptimization();
|
|
|
105
127
|
## Roadmap
|
|
106
128
|
|
|
107
129
|
- [x] Battery Optimization (Android)
|
|
130
|
+
- [x] Overlay Permission (Android)
|
|
108
131
|
- [ ] Notifications (Android + iOS)
|
|
109
132
|
- [ ] Exact Alarm (Android)
|
|
110
133
|
- [ ] DND Access (Android)
|
|
111
|
-
- [ ] Overlay Permission (Android)
|
|
112
134
|
- [x] Expo Config Plugin
|
|
113
135
|
- [ ] Standalone Package
|
|
114
136
|
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab
CHANGED
|
Binary file
|
|
Binary file
|
package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.values.at
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab
CHANGED
|
Binary file
|
|
Binary file
|
package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab
CHANGED
|
Binary file
|
|
Binary file
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
4
|
|
2
2
|
0
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.len
CHANGED
|
Binary file
|
|
Binary file
|
package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i
CHANGED
|
Binary file
|
|
Binary file
|
package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream
CHANGED
|
Binary file
|
|
Binary file
|
package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.len
CHANGED
|
Binary file
|
package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.values.at
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/android/build/kotlin/compileDebugKotlin/classpath-snapshot/shrunk-classpath-snapshot.bin
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -10,6 +10,16 @@ import expo.modules.kotlin.modules.Module
|
|
|
10
10
|
import expo.modules.kotlin.modules.ModuleDefinition
|
|
11
11
|
|
|
12
12
|
class ExpoPermissionKitModule : Module() {
|
|
13
|
+
private fun hasManifestPermission(permission: String): Boolean {
|
|
14
|
+
val context = appContext.reactContext ?: return false
|
|
15
|
+
return try {
|
|
16
|
+
val packageInfo = context.packageManager.getPackageInfo(context.packageName, android.content.pm.PackageManager.GET_PERMISSIONS)
|
|
17
|
+
packageInfo.requestedPermissions?.contains(permission) == true
|
|
18
|
+
} catch (e: Exception) {
|
|
19
|
+
false
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
13
23
|
override fun definition() = ModuleDefinition {
|
|
14
24
|
Name("ExpoPermissionKit")
|
|
15
25
|
|
|
@@ -36,10 +46,7 @@ class ExpoPermissionKitModule : Module() {
|
|
|
36
46
|
val packageName = context.packageName
|
|
37
47
|
|
|
38
48
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
39
|
-
if (
|
|
40
|
-
context,
|
|
41
|
-
android.Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
|
|
42
|
-
) != android.content.pm.PackageManager.PERMISSION_GRANTED) {
|
|
49
|
+
if (!hasManifestPermission(android.Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS)) {
|
|
43
50
|
throw Exception("MISSING_PERMISSION: Add batteryOptimization to your app.json plugin")
|
|
44
51
|
}
|
|
45
52
|
|
|
@@ -52,5 +59,36 @@ class ExpoPermissionKitModule : Module() {
|
|
|
52
59
|
context.startActivity(intent)
|
|
53
60
|
}
|
|
54
61
|
}
|
|
62
|
+
|
|
63
|
+
AsyncFunction("isOverlayPermissionEnabled") {
|
|
64
|
+
val context = appContext.reactContext
|
|
65
|
+
?: throw Exception("Context unavailable")
|
|
66
|
+
|
|
67
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
68
|
+
return@AsyncFunction Settings.canDrawOverlays(context)
|
|
69
|
+
}
|
|
70
|
+
return@AsyncFunction true
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
AsyncFunction("openOverlayPermissionSettings") {
|
|
74
|
+
val context = appContext.reactContext
|
|
75
|
+
?: throw Exception("Context unavailable")
|
|
76
|
+
|
|
77
|
+
val packageName = context.packageName
|
|
78
|
+
|
|
79
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
80
|
+
if (!hasManifestPermission(android.Manifest.permission.SYSTEM_ALERT_WINDOW)) {
|
|
81
|
+
throw Exception("MISSING_PERMISSION: Add 'overlay' to your app.json plugin")
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
val intent = Intent(
|
|
85
|
+
Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
|
|
86
|
+
Uri.parse("package:$packageName")
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
|
90
|
+
context.startActivity(intent)
|
|
91
|
+
}
|
|
92
|
+
}
|
|
55
93
|
}
|
|
56
94
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export interface PermissionKitNativeModule {
|
|
2
2
|
isBatteryOptimizationEnabled(): Promise<boolean>;
|
|
3
3
|
openBatteryOptimizationSettings(): Promise<void>;
|
|
4
|
+
isOverlayPermissionEnabled(): Promise<boolean>;
|
|
5
|
+
openOverlayPermissionSettings(): Promise<void>;
|
|
4
6
|
}
|
|
5
7
|
declare let _nativeModule: PermissionKitNativeModule | null;
|
|
6
8
|
export default _nativeModule;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoPermissionKitModule.d.ts","sourceRoot":"","sources":["../src/ExpoPermissionKitModule.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,yBAAyB;IACxC,4BAA4B,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IACjD,+BAA+B,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"ExpoPermissionKitModule.d.ts","sourceRoot":"","sources":["../src/ExpoPermissionKitModule.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,yBAAyB;IACxC,4BAA4B,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IACjD,+BAA+B,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,0BAA0B,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAC/C,6BAA6B,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAChD;AAED,QAAA,IAAI,aAAa,EAAE,yBAAyB,GAAG,IAAW,CAAC;AAO3D,eAAe,aAAa,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoPermissionKitModule.js","sourceRoot":"","sources":["../src/ExpoPermissionKitModule.ts"],"names":[],"mappings":";;AAAA,+BAA2C;
|
|
1
|
+
{"version":3,"file":"ExpoPermissionKitModule.js","sourceRoot":"","sources":["../src/ExpoPermissionKitModule.ts"],"names":[],"mappings":";;AAAA,+BAA2C;AAS3C,IAAI,aAAa,GAAqC,IAAI,CAAC;AAC3D,IAAI,CAAC;IACH,aAAa,GAAG,IAAA,0BAAmB,EAA4B,mBAAmB,CAAC,CAAC;AACtF,CAAC;AAAC,WAAM,CAAC;IACP,0EAA0E;AAC5E,CAAC;AAED,kBAAe,aAAa,CAAC"}
|
package/build/PermissionKit.d.ts
CHANGED
|
@@ -8,8 +8,20 @@ export declare function batteryOptimization(): Promise<{
|
|
|
8
8
|
} | {
|
|
9
9
|
status: "granted" | "denied";
|
|
10
10
|
}>;
|
|
11
|
+
export declare function checkOverlay(): Promise<{
|
|
12
|
+
status: "unavailable";
|
|
13
|
+
} | {
|
|
14
|
+
status: "granted" | "denied";
|
|
15
|
+
}>;
|
|
16
|
+
export declare function overlay(): Promise<{
|
|
17
|
+
status: "unavailable";
|
|
18
|
+
} | {
|
|
19
|
+
status: "granted" | "denied";
|
|
20
|
+
}>;
|
|
11
21
|
export declare const PermissionKit: {
|
|
12
22
|
batteryOptimization: typeof batteryOptimization;
|
|
13
23
|
checkBatteryOptimization: typeof checkBatteryOptimization;
|
|
24
|
+
overlay: typeof overlay;
|
|
25
|
+
checkOverlay: typeof checkOverlay;
|
|
14
26
|
};
|
|
15
27
|
//# sourceMappingURL=PermissionKit.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PermissionKit.d.ts","sourceRoot":"","sources":["../src/PermissionKit.ts"],"names":[],"mappings":"AAGA,wBAAsB,wBAAwB;;;YAME,SAAS,GAAG,QAAQ;GAEnE;AAED,wBAAsB,mBAAmB;;;YAJO,SAAS,GAAG,QAAQ;GA8BnE;AAiBD,eAAO,MAAM,aAAa
|
|
1
|
+
{"version":3,"file":"PermissionKit.d.ts","sourceRoot":"","sources":["../src/PermissionKit.ts"],"names":[],"mappings":"AAGA,wBAAsB,wBAAwB;;;YAME,SAAS,GAAG,QAAQ;GAEnE;AAED,wBAAsB,mBAAmB;;;YAJO,SAAS,GAAG,QAAQ;GA8BnE;AAiBD,wBAAsB,YAAY;;;YAMc,SAAS,GAAG,QAAQ;GAEnE;AAED,wBAAsB,OAAO;;;YAJmB,SAAS,GAAG,QAAQ;GA8BnE;AAED,eAAO,MAAM,aAAa;;;;;CAKzB,CAAC"}
|
package/build/PermissionKit.js
CHANGED
|
@@ -6,6 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.PermissionKit = void 0;
|
|
7
7
|
exports.checkBatteryOptimization = checkBatteryOptimization;
|
|
8
8
|
exports.batteryOptimization = batteryOptimization;
|
|
9
|
+
exports.checkOverlay = checkOverlay;
|
|
10
|
+
exports.overlay = overlay;
|
|
9
11
|
const react_native_1 = require("react-native");
|
|
10
12
|
const ExpoPermissionKitModule_1 = __importDefault(require("./ExpoPermissionKitModule"));
|
|
11
13
|
async function checkBatteryOptimization() {
|
|
@@ -50,8 +52,41 @@ function waitForResume() {
|
|
|
50
52
|
});
|
|
51
53
|
});
|
|
52
54
|
}
|
|
55
|
+
async function checkOverlay() {
|
|
56
|
+
if (react_native_1.Platform.OS === 'ios' || !ExpoPermissionKitModule_1.default) {
|
|
57
|
+
return { status: 'unavailable' };
|
|
58
|
+
}
|
|
59
|
+
const enabled = await ExpoPermissionKitModule_1.default.isOverlayPermissionEnabled();
|
|
60
|
+
return {
|
|
61
|
+
status: (enabled ? 'granted' : 'denied'),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
async function overlay() {
|
|
65
|
+
var _a;
|
|
66
|
+
if (react_native_1.Platform.OS === 'ios' || !ExpoPermissionKitModule_1.default) {
|
|
67
|
+
return { status: 'unavailable' };
|
|
68
|
+
}
|
|
69
|
+
const check = await checkOverlay();
|
|
70
|
+
if (check.status === 'granted') {
|
|
71
|
+
return check;
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
await ExpoPermissionKitModule_1.default.openOverlayPermissionSettings();
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
if ((_a = error === null || error === void 0 ? void 0 : error.message) === null || _a === void 0 ? void 0 : _a.includes('MISSING_PERMISSION')) {
|
|
78
|
+
console.warn("[@abrarmehraj/permission-kit] Missing Permission: You forgot to add 'overlay' to your app.json plugin.");
|
|
79
|
+
return { status: 'denied' };
|
|
80
|
+
}
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
83
|
+
await waitForResume();
|
|
84
|
+
return await checkOverlay();
|
|
85
|
+
}
|
|
53
86
|
exports.PermissionKit = {
|
|
54
87
|
batteryOptimization,
|
|
55
88
|
checkBatteryOptimization,
|
|
89
|
+
overlay,
|
|
90
|
+
checkOverlay,
|
|
56
91
|
};
|
|
57
92
|
//# sourceMappingURL=PermissionKit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PermissionKit.js","sourceRoot":"","sources":["../src/PermissionKit.ts"],"names":[],"mappings":";;;;;;AAGA,4DAQC;AAED,kDA0BC;
|
|
1
|
+
{"version":3,"file":"PermissionKit.js","sourceRoot":"","sources":["../src/PermissionKit.ts"],"names":[],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abrarmehraj/permission-kit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "A developer-friendly permissions library for Expo and React Native. One call handles the full workflow — check, request, wait for app resume, return final status.",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"module": "build/index.js",
|
package/plugin/build/index.js
CHANGED
|
@@ -3,18 +3,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const config_plugins_1 = require("expo/config-plugins");
|
|
4
4
|
const withPermissionKit = (config, props) => {
|
|
5
5
|
const permissions = (props === null || props === void 0 ? void 0 : props.permissions) || [];
|
|
6
|
-
if (permissions.includes('batteryOptimization')) {
|
|
6
|
+
if (permissions.includes('batteryOptimization') || permissions.includes('overlay')) {
|
|
7
7
|
config = (0, config_plugins_1.withAndroidManifest)(config, (config) => {
|
|
8
8
|
const androidManifest = config.modResults;
|
|
9
9
|
if (!androidManifest.manifest['uses-permission']) {
|
|
10
10
|
androidManifest.manifest['uses-permission'] = [];
|
|
11
11
|
}
|
|
12
12
|
const existingPermissions = androidManifest.manifest['uses-permission'].map((p) => p.$['android:name']);
|
|
13
|
-
if (
|
|
13
|
+
if (permissions.includes('batteryOptimization') &&
|
|
14
|
+
!existingPermissions.includes('android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS')) {
|
|
14
15
|
androidManifest.manifest['uses-permission'].push({
|
|
15
|
-
$: {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
$: { 'android:name': 'android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS' },
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
if (permissions.includes('overlay') &&
|
|
20
|
+
!existingPermissions.includes('android.permission.SYSTEM_ALERT_WINDOW')) {
|
|
21
|
+
androidManifest.manifest['uses-permission'].push({
|
|
22
|
+
$: { 'android:name': 'android.permission.SYSTEM_ALERT_WINDOW' },
|
|
18
23
|
});
|
|
19
24
|
}
|
|
20
25
|
return config;
|
|
@@ -3,6 +3,8 @@ import { requireNativeModule } from 'expo';
|
|
|
3
3
|
export interface PermissionKitNativeModule {
|
|
4
4
|
isBatteryOptimizationEnabled(): Promise<boolean>;
|
|
5
5
|
openBatteryOptimizationSettings(): Promise<void>;
|
|
6
|
+
isOverlayPermissionEnabled(): Promise<boolean>;
|
|
7
|
+
openOverlayPermissionSettings(): Promise<void>;
|
|
6
8
|
}
|
|
7
9
|
|
|
8
10
|
let _nativeModule: PermissionKitNativeModule | null = null;
|
package/src/PermissionKit.ts
CHANGED
|
@@ -54,7 +54,47 @@ function waitForResume(): Promise<void> {
|
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
export async function checkOverlay() {
|
|
58
|
+
if (Platform.OS === 'ios' || !NativeModule) {
|
|
59
|
+
return { status: 'unavailable' as const };
|
|
60
|
+
}
|
|
61
|
+
const enabled = await NativeModule.isOverlayPermissionEnabled();
|
|
62
|
+
return {
|
|
63
|
+
status: (enabled ? 'granted' : 'denied') as 'granted' | 'denied',
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export async function overlay() {
|
|
68
|
+
if (Platform.OS === 'ios' || !NativeModule) {
|
|
69
|
+
return { status: 'unavailable' as const };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const check = await checkOverlay();
|
|
73
|
+
|
|
74
|
+
if (check.status === 'granted') {
|
|
75
|
+
return check;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
try {
|
|
79
|
+
await NativeModule.openOverlayPermissionSettings();
|
|
80
|
+
} catch (error: any) {
|
|
81
|
+
if (error?.message?.includes('MISSING_PERMISSION')) {
|
|
82
|
+
console.warn(
|
|
83
|
+
"[@abrarmehraj/permission-kit] Missing Permission: You forgot to add 'overlay' to your app.json plugin."
|
|
84
|
+
);
|
|
85
|
+
return { status: 'denied' as const };
|
|
86
|
+
}
|
|
87
|
+
throw error;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
await waitForResume();
|
|
91
|
+
|
|
92
|
+
return await checkOverlay();
|
|
93
|
+
}
|
|
94
|
+
|
|
57
95
|
export const PermissionKit = {
|
|
58
96
|
batteryOptimization,
|
|
59
97
|
checkBatteryOptimization,
|
|
98
|
+
overlay,
|
|
99
|
+
checkOverlay,
|
|
60
100
|
};
|