What shared data API has been available since iOS 9?

I want to create an app which allows a few users with different AppleID to exchange short text messages through a shared database. The amount of data is minimal, something like "Reminders" app gathering task of a few users in one file or database.


The perfect solution seems to be CKShare from CloudKit, but here comes another requirement: the app needs to install on iOS 9. While Apple introducedCloudkit already with iOS 8, the CKShare part was introduced only with iOS 10. :-(


What other API available with iOS 9 can I use to give a few users access to the same small data container through their internet connections?


Can implement shared functionality with CloudKit public data (available since iOS 8), and keep that data private for small groups of users?

Shall I use some variant of CoreData?


What is the best approach?

Accepted Reply

You can store the information in the public database of CloudKit and let users find it using a query to their own 'share' word. Create a record with a field "ShareCode" and have a group of users create a ShareCode like "OurFavoriteClubTheBozos" or an opaque UUID that you would exchange among them using an email link. Then they search for records with that value for the ShareCode. The only drawback is that you (the developer) have to pay for storage if there is too much storage in the public database.

Replies

You can store the information in the public database of CloudKit and let users find it using a query to their own 'share' word. Create a record with a field "ShareCode" and have a group of users create a ShareCode like "OurFavoriteClubTheBozos" or an opaque UUID that you would exchange among them using an email link. Then they search for records with that value for the ShareCode. The only drawback is that you (the developer) have to pay for storage if there is too much storage in the public database.

Your answer has been a great help. The app is being evolved, but... how can I register subscription to be notified when other user modifies, adds, or deletes record which I previously queried from the public database in iOS9?


When I call:

let subscription = CKSubscription(recordType: "Collections",
                                  predicate: groupPredicate,
                                  subscriptionID: subID,
                                  options: [.firesOnRecordUpdate, .firesOnRecordDeletion])

Xcode complains with:

'init(recordType:predicate:subscriptionID:options:)' is unavailable in Swift


I am aware that there is a CKQuerySubscription() class available, but this is since iOS 10. My code has to run on iOS 9.


Is there other subscription/notification mechanism to be used in iOS9?

Is there any other option to use old iOS9-ish CKSubscription() classes?

Interesting. I suspect you will be able to use the deprecated CKSubscription as long as your deployment target is iOS9. I'd write code using both by:


if (@available(iOS 10.0, *)){


}else{


}