Skip to content

Commit

Permalink
chore: Add required permission on iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed May 29, 2024
1 parent 1f0282a commit cb63db8
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
<Button Command="{Binding Data.CheckAccessCommand}">Check access</Button>
<Button Command="{Binding Data.SaveCommand}">Save UnoLogo.png to gallery</Button>
<Button Command="{Binding Data.SaveRandomNameCommand}">Save with random name to gallery</Button>
<Button Command="{Binding Data.SaveAndOverwriteCommand}">Save UnoLogo.png to gallery and overwrite</Button>
</StackPanel>
</DataTemplate>
</sample:SamplePageLayout.DesignAgnosticTemplate>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,24 +109,5 @@ public class MediaGalleryHelperSampleVM : ViewModelBase
}.ShowAsync();
}
});

public ICommand SaveAndOverwriteCommand => new Command(async (_) =>
{
if (await MediaGallery.CheckAccessAsync())
{
var file = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/UnoLogo.png", UriKind.Absolute));
using var stream = await file.OpenStreamForReadAsync();
await MediaGallery.SaveAsync(MediaFileType.Image, stream, "UnoLogo.png");
}
else
{
await new ContentDialog
{
Title = "Permission required",
Content = "The app requires access to the device's gallery to save the image.",
CloseButtonText = "OK"
}.ShowAsync();
}
});
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
</array>
<key>XSAppIconAssets</key>
<string>Assets.xcassets/iconapp.appiconset</string>

<key>NSPhotoLibraryAddUsageDescription</key>
<string>This app would like to save photos to your gallery</string>
<!--
Adjust this to your application's encryption usage.
<key>ITSAppUsesNonExemptEncryption</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
<string>Assets.xcassets/iconapp.appiconset</string>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>

<key>NSPhotoLibraryAddUsageDescription</key>
<string>This app would like to save photos to your gallery</string>
<!--
Adjust this to your application's encryption usage.
<key>ITSAppUsesNonExemptEncryption</key>
Expand Down

0 comments on commit cb63db8

Please sign in to comment.