Fix Permission CTD for packaged/unpackaged apps using CameraView#3157
Open
ne0rrmatrix wants to merge 3 commits intoCommunityToolkit:mainfrom
Open
Fix Permission CTD for packaged/unpackaged apps using CameraView#3157ne0rrmatrix wants to merge 3 commits intoCommunityToolkit:mainfrom
ne0rrmatrix wants to merge 3 commits intoCommunityToolkit:mainfrom
Conversation
Updated CameraViewPage to grant permissions automatically for unpackaged apps, avoiding unnecessary prompts. Changed CreateStopCameraPreviewCommand to use Command<CancellationToken> for consistency with start command.
2 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aligns the CameraView stop-preview command factory with the existing bindable property type, and updates the sample app’s permission flow to account for packaged vs. unpackaged app behavior.
Changes:
- Fix
CreateStopCameraPreviewCommandto returnCommand<CancellationToken>(matchingStopCameraPreviewCommandProperty/StopCameraPreviewCommand). - Update the CameraView sample to request camera/mic permissions only when the app is packaged, otherwise treat them as granted.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs | Makes the stop-preview command default value creator return the correct generic Command<CancellationToken> type. |
| samples/CommunityToolkit.Maui.Sample/Pages/Views/CameraView/CameraViewPage.xaml.cs | Adjusts runtime permission requests based on AppInfo.Current.PackagingModel to support unpackaged scenarios. |
You can also share your feedback on Copilot code review. Take the survey.
2 tasks
VladislavAntonyuk
previously approved these changes
Mar 17, 2026
Member
Author
|
@VladislavAntonyuk can you take one more pass. I realized i excluded android,ios and mac catalyst. Fixed now. |
VladislavAntonyuk
requested changes
Mar 17, 2026
| var packagingModel = AppInfo.Current.PackagingModel; | ||
| PermissionStatus microphonePermissionsRequest; | ||
| PermissionStatus cameraPermissionsRequest; | ||
| if (packagingModel == AppPackagingModel.Packaged || OperatingSystem.IsAndroid() || OperatingSystem.IsIOS() || OperatingSystem.IsMacCatalyst()) |
Contributor
There was a problem hiding this comment.
Maybe better to use !Windows?
Member
Author
There was a problem hiding this comment.
Updated as you suggested. Good idea.
Refactored the logic for requesting camera and microphone permissions in OnAppearing. Instead of explicitly checking for Android, iOS, or MacCatalyst, permissions are now requested on all non-Windows platforms or when the app is packaged. This makes the condition more maintainable and future-proof.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of Change
There is a bug in CameraView in sample app where it requests permission for microphone and camera in an unpackaged app. This will crash the sample app. An unpackaged app does not require permissions for either camera or microphone when not packaged.
This also fixes a bug where the method signature for a
Commandis incorrect which is crashing sample app.Linked Issues
PR Checklist
approved(bug) orChampioned(feature/proposal)mainat time of PRAdditional information
This is another packaged/unpackaged app issue that is related to permissions. Includes a second bug that needed to be fixed to test and prevent crashes.