I'm creating a college dining menu app, in which I need to send push notifications based on the daily menus. Originally, I was planning on storing user data in a database through Heroku and using cron jobs to compare the data in the database with the daily menus and send appropriate notifications to users.
After the news on Cloudkit, however, I thought I could use that instead to manage the server-related part of my code. After closer inspection, though, it seems like Cloudkit is currently capable of storing the data, but does not allow us to write server-side code.
I'm wondering if I interpreted this limitation correctly, or if I can, in fact, schedule a database on CloudKit to compare its data to the online menus each day and send appropriate push notifications.
Server-side
As you said CloudKit doesn't allow server-side code.
But.. Welcome to
Subscriptions
Subscriptions concept is that the client registers for specific updates. You can create a record type called
Daily
for instance and make users register to it. You should check the Apple documentation and WWDC14 videos (even if Subscriptions are not detailed, it's a good start point).The good thing is push notifications are linked with the subscription concept. So basically you say: Send my a notification for each new
CKRecord
of typeDaily
added.Crons
Now the problem is your users are registers to new posts but you don't want to connect to the iCloud Dashboard everyday in order to perform the push by adding a record. One solution here is to code an app on a mac server (I guess mac mini as server will become more popular with CloudKit) that add a new
Daily
CKRecord
every day.Limitations
The problem is AFAIK the notification message is written on the client side, so it doesn't depend on data you send.
It seems incredible you wouldn't use or consider Parse.com for something like this ...
(If not Parse, some other bAAs with a similar feature set.)
NOTE - Parse is now at back4app.com.
1) Parse is the easiest possible way to do push with an iOS app
2) the whole idea of Parse is that you have cloud code, and it's incredibly simple,
https://parse.com/docs/cloud_code_guide
you can have cloud code routines, and, you can have "cron" routines that go off regularly. it's why everyone's using Parse!
Note that it is super-easy to call "cloud functions" from iOS, with Parse.
Here's an example,
Notice I'm calling a cloud function "clientRequestFriendRemove". So that's just a piece of cloud code I wrote and which is on our Parse account, in fact here it is
(Fuller examples ... https://stackoverflow.com/a/24010828/294884 )
3) it's trivial to make Push happen from the cloud code in Parse, again this is why "everyone uses it"
For example, here's a Parse cloud code fragment that relates to Push ...
4) it's unbelievably easy to do everything relating to your food database, on a nosql environment. nothing could be easier than the Parse approach
5) you get the whole back end for free (for adding foods, whatever) - normally months of work
6) finally i guess Parse is quite free (until you have so many users you'd be making a fortune anyway)
So, I can't imagine doing what you say any other way - it would be a nightmare otherwise. Hope it helps