Xamarin.iOS - CloudCaptions
This sample shows how to use
CloudKit to upload and retrieve
CKRecords and associated assets. In this example, there are two record types, an
Image record type and a
Post record type. Users are able to upload their own photos or select an image already found in an image record type. This example also uses an
NSPredicate in its
CKQueries to filter results based on tags.
It is strongly recommended to watch WWDC 2014 videos to become familiar with CloudKit:
- Introducing CloudKit
- Advanced CloudKit
How to setup
CloudCaptions.entitlements file lists two entitlements:
com.apple.developer.icloud-services. For this sample you must create an iCloud container via Apple's Member Center. You can find instructions for creating iCloud containers here – you are interested in the "Enabling iCloud in Xamarin" section.
Don't forget change iCloud container identifier from
iCloud.(Your Bundle ID)
Try running CloudCaptions on your device. You may run into provisioning issues – in this case you should check your CloudCaptions.entitlements and provisioning settings.
Once the app is running, you may see a
CKInternalError in the console output. To resolve this, all you need to do is view your container in CloudKit dashboard.
Try running the app again. You will start seeing
CKUnknownItem errors in the log output. These occur because we're querying for records that CloudKit has never seen before. To resolve these, all we need to do is upload a new post. Tap compose, then tap
Take Photo, take a picture and write a caption. Finally, tap
You will no longer see
CKUnknownItem errors in the console. You now will start seeing
CKInvalidArgument errors. By default, CloudKit can't sort or query by record metadata like creation date or last modified date. To change this, go to your container's dashboard and click
Record Types. You should see two new record types:
Post. For each record type, click
Metadata Index and check the box to sort by date created.
Run CloudCaptions one more time and you should see the post you just made. Your container is now set up to use CloudCaptions.
Building this sample requires Xcode 6.0 and iOS 8.0 SDK
This sample runnable on iPhoneSimulator/iPadSimulator iPhone/iPad
Xamarin port changes are released under the MIT license