First, we will write the iOS code. To access photos, we need permission from the user, so we need a way of asking users for permission. To do that, we need to add text that explains why we need permission to the info.plist file. This text will be displayed when we ask the users for permission. To open the info.plist file, right-click on the file and click Open With, then select XML (Text) Editor:
<key>NSPhotoLibraryUsageDescription</key>
<string>We want to show your photos in this app</string>
The first thing we will do is create a private Import method that reads what photos can be loaded:
- In the GalleryApp.iOS project, create a new class called PhotoImporter.
- Implement the IPhotoImporter interface.
- Resolve all the references.
- Create a private field with a PHAsset type array named results. This will be used to store photo information.
- Create a new private method named Import.
- Request authorization...