-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mobile Permissions Support #3870
Comments
We've thought about this lately and my own thoughts are that we need to expose the files themselves ( It is good to know that |
Some considerations - On android, <uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" /> <uses-permission android:name="android.permission.BLUETOOTH_SCAN" /> These can't really be merged since the later may use bluetooth for location. Another consideration is Thus for merging solution, the most correct and maintainable solution might be to fail building on such conflicts with a conflict reason and have the user manually specify them in their config file. This would also mean that resolution needs to be done in reverse breadth first order. A downside to this is that permission files start to become spaghetti with some permissions needed by the application, some needed for conflict resolution from libraries, and others not specified but will be applied when merging. That said, maybe the easiest and most correct solution is not to do merging and propagation. Another reason for this: E.g. A library may have have bluetooth functionality, but a downstream application never uses that, so it actually does not need |
Feature Request
Currently, there is no way to request or manage permissions on mobile platforms in Dioxus applications. This affects critical functionality such as camera access, location services, file system access, and other platform capabilities that require user permission.
Background
Mobile applications require permissions to access sensitive device features and user data. Both Android and iOS have their own permission systems that differ significantly in implementation but serve the same purpose of protecting user privacy.
Platform Requirements
Android Permission System
Android uses a dual-layer permission system:
Manifest Declaration: All permissions must be declared in
AndroidManifest.xml
Runtime Requests: Permissions are categorized by protection level:
Normal Permissions (automatically granted at install, no runtime request needed):
android.permission.INTERNET
android.permission.ACCESS_NETWORK_STATE
android.permission.VIBRATE
android.permission.SET_ALARM
Dangerous Permissions (require runtime request):
android.permission.CAMERA
android.permission.READ_CONTACTS
android.permission.ACCESS_FINE_LOCATION
android.permission.READ_EXTERNAL_STORAGE
android.permission.RECORD_AUDIO
Special Permissions (require specific handling):
android.permission.SYSTEM_ALERT_WINDOW
android.permission.WRITE_SETTINGS
Android provides a unified permission request API that works consistently across different permission types.
iOS Permission System
iOS has a different approach:
Info.plist Declarations: All privacy-sensitive permissions must be declared in
Info.plist
with appropriate usage description strings (explaining why the app needs the permission)Per-Permission APIs: Unlike Android, iOS uses separate APIs for each permission type:
AVCaptureDevice.requestAccess(for:)
CLLocationManager.requestWhenInUseAuthorization()
PHPhotoLibrary.requestAuthorization()
Usage Descriptions: Every permission requires a corresponding entry in Info.plist:
NSCameraUsageDescription
NSPhotoLibraryUsageDescription
NSLocationWhenInUseUsageDescription
Special Entitlements: Some iOS capabilities require additional entitlements beyond Info.plist entries:
Platform-Specific Permissions
Each platform has unique permissions that don't exist on the other:
Android-only Permissions:
android.permission.SYSTEM_ALERT_WINDOW
android.permission.READ_SMS
/android.permission.RECEIVE_SMS
android.permission.READ_PHONE_STATE
android.permission.WRITE_SETTINGS
android.permission.REQUEST_INSTALL_PACKAGES
iOS-only Permissions:
NSUserTrackingUsageDescription
)NSLocalNetworkUsageDescription
)UNAuthorizationOptionCriticalAlert
)NSFaceIDUsageDescription
)NSPhotoLibraryAddUsageDescription
)Proposed Implementation
Due to the specific platform needs and evolving technologies, it may be best to expose
AndroidManifest.xml
andInfo.plist
to be used in the compiled platform projects. There should be a unified native experience for permissions. Maybe something likeWhich is can be used as guards that prompt the user for permission if not already granted.
Documentation Strategy
We should provide:
Alternative Implementation
A fully unified permission API in
Cargo.toml
ordioxus.toml
would be simpler for developers but wouldn't adequately address platform-specific requirements. Even with a unified configuration approach for common permissions, exposing direct access to platform configuration files is necessary for advanced use cases. Also the merging of generated platform files with user-provided configurations introduces complexity and potential conflicts.Unanswered Questions
How should libraries that require permissions interact with downstream applications? Maybe simply recommending including a section in the README for configuring
AndroidManifest.xml
andInfo.plist
is enough.Prior Art
The text was updated successfully, but these errors were encountered: