This is the NativeScript implementation of the Expo SDK's Permissions APIs.
- For iOS, it installs the native iOS
expo-permissions
source as-is. - For Android, I've been unable to get the native Android
expo-permissions
source to compile (a complication of it being Kotlin-based), so it installs the native Android source from our fork,@nativescript-community/expo-permissions
. However, even with that approach, I've been unable to get things working, so summarily Android support is not working for now.
It exposes the very same cross-platform TypeScript APIs as expo-permissions
does – this was achieved largely by copy-pasting the TypeScript source files from expo-permissions
.
npm install --save @unimodules/core expo-permissions unimodules-permissions-interface
ns plugin add @nativescript-community/expo-nativescript-adapter
ns plugin add @nativescript-community/expo-permissions-nativescript-plugin
expo-permissions-nativescript-plugin
has the following peer dependencies:
UMCore
|
org.unimodules.core
|
Mandatory | Implements the platform-agnostic API for consuming Expo Unimodules. | |
UMNativeModulesProxy
|
org.unimodules.adapters.nativescript
|
Mandatory | Adapts Expo Unimodules to NativeScript (and auto-installs the native modules for the above node module). | |
UMPermissionsInterface
|
org.unimodules.interfaces.permissions
|
Mandatory |
It's the interface that expo-permissions implements.
|
|
EXPermissions
|
expo.modules.permissions
|
Mandatory | Provides the Expo Permissions APIs. | |
Same as above (this auto-installs the native modules for the above node module). |
See Permissions in the Expo SDK API docs for full documentation.
🚫 | 🚫 | Has some kind of dependency on React Native. Won't boter implementing. | |
✅ | ✅ |
Should just work! Note that Android support is pending implementation of expo-nativescript-adapter .
|
Again, see Permissions in the Expo SDK API docs for full documentation.
Note that you can only use expo-permissions-nativescript-plugin
to check or request permissions for other Expo Unimodules that you have installed. So, for example, you wouldn't be able to use it to request Contacts permissions unless you also had expo-contacts-nativescript-plugin
installed. That's just the way it works.
Also, before asking for any permission, just as with native app development, you will still need to have the corresponding property listed in the appropriate place in your app, for example:
- (for iOS):
App_Resources/iOS/Info.plist
file, e.g.<key>NSContactsUsageDescription</key>
- (for Android):
App_Resources/Android/src/main/AndroidManifest.xml
file, e.g.<uses-permission android:name="android.permission.READ_CONTACTS" /> <uses-permission android:name="android.permission.WRITE_CONTACTS" />
.
... otherwise, your app may immediately crash without explanation 🤕
These NativeScript Expo plugins will not enter these properties for you; it's your responsibility to add them! Remember that when developing NativeScript apps, you'll have to run a rebuild of the app (e.g. tns build ios
) to copy your latest Info.plist
or AndroidManifest.xml
into the app bundle; it's not simply something that Webpack will do for you in watch mode (to my understanding).
MIT