Listen to iCal event changes from server - ios

I am building the server side for a calendar application. The client side is iOS only. The original plan was the app will know of iCal event changes then tell the server. But that might be a problem with reminders (via Parse Push). For example, if the event pushed forward the reminder should come earlier.
Is it possible from the server side to be notified on iCal events? For example, when users create/update/delete an iCal event I want to know from a server to grab this information. Is this possible? Or does everything need to be done via a native app thats running?
My server is currently on parse.com. But I could use a separate server say NodeJS if needed.

As iCal is user/device dependent, unless user has synced his calendar events with iCloud. And in second case where user has activated syncing of calendar events, it is completly insecure for end-user to share his icloud details to other server.
How about creating 1 API at backend, which will update/delete requests from Apps for the calendar events, and that will update Parse notification events in background process. For this you can also write customized Parse apis either in NodeJS or any other technology stack.
And in the apps, you can sync the events with iCal using Event Kit:
https://developer.apple.com/library/mac/documentation/DataManagement/Conceptual/EventKitProgGuide/ReadingAndWritingEvents.html#//apple_ref/doc/uid/TP40004775-SW1

first, you need to able to let iOS wake up your app running in the background, that requires to classify your app to one of the mode stated in the Apple Background Execution, I think the "Background fetch" is appropriate in your case, then in your application:performFetchWithCompletionHandler: you could check the Calendar database for changed events and preform necessary updates to the server.

I think this is your best bet:
https://stackoverflow.com/a/23997912/1967872
In your implementation of the storeChanged: method mentioned in that answer, you should iterate through all the events, detect any changes and submit those to the server.

I don't know exactly that is possible or not but I am thinking it's hard because still I didn't find any library/any features that apple is provides like that.
But I am putting one link that might be helpful for you. Please check it.
http://kb.kerio.com/product/kerio-connect/os-x/support-for-apple-ical-calendar-using-the-caldav-standard-1494.html

Related

How can I go about setting up push notifications using firebase cloud messaging and cloud functions?

I'm been coding for a year now and know swift really well and the basics to javascript. I've built a social media like app and its completely done besides the push notification functionality... which i've been struggling with for quite a while now.
I'm having trouble figuring out how to implement these in order to send notifications like when a user follows another user or they receive a new messege.
I don't understand how to integrate the cloud functions that I would write using and node.js with my xcode project.
When I look for documentation online its usually just how to send push notifications using the firebase notifications console which is cool but doesn't trigger based off specific user actions or events (ex: when the user gets a new follower)
I think since im struggling with grasping the concept of how to implement it, the actual technical set up of it makes even less sense. Any advice or resources would be greatly appreciated.
Thank you
Conceptually, what you have to do is set up server-side processing of your database to manage when events occur. This is what the Node.js code will be. Everything is connected through the database-- your Xcode and Node.js code work independently, but both communicate with Firebase. You can create a Cloud Function that will automatically run when it detects changes in your database, and this will automatically send push notifications.
I've done a similar project-- I set up a listener for my Realtime Database in my Cloud Function. Every time the user got a new follower, i.e. their followers tree was updated, I sent a notification to the device using an FCM token (which I also stored in the database).
exports.onTimeEnd = functions.database.ref("users/{user}/followers")
.onUpdate((snapshot, context) => {
// your code here
}
In that block, you can call a .once() to find out the user's token to send them a notification with.
https://firebase.google.com/docs/functions/get-started
This link here told me everything I had to do in regards to set up in the terminal. Super helpful.

How to trigger an event in an iOS app from a UNNotificationServiceExtension?

My app has an UNNotificationServiceExtension object that exists in a separate project, which handles the receipt and processing of notifications.
I'd like to be able to trigger an event in the main app under certain circumstances, whether the app is active or not. Is this possible? If so, what mechanism would I use to achieve this?
If not, I'm worried that I'll have to use the main app to poll a shared data source when it's activated and respond to the data it reads.
Hmm.. after a bit of googling I found this:
Using URL Schemes to Communicate with Apps
This will allow me to communicate between apps.

Consuming external json with parse.com

I'm working on an iOS application developed with Swift. The application is going to need notifications to receive alerts when certain events occur.
To handle push notifications I'm using parse.com. I was able to create an account and integrate push notifications into my application, as it's explained in the Parse.com guide, and are working fine when I send something from the Push section.
What I'm trying to do, and I cannot figure it out, is consume a 3rd party JSON, process that JSON to check some status and report, to the users that are using the application, a status change via a push notification. I know I should process all this in the backend/server side and then push the result or what I'm trying to notify, but I don't know what to do.
Ex. of What I'm trying to archive:
3rd party website ---(json)---> parse.com ---(push notification)--->
My App
I'm aware the tools that Parse.com provides, such as REST API, Cloud Code, Webhooks and Jobs, but I'm totally lost here! I cannot find any guide or documentation that allows me to do what I previously described. I don't even know if its possible, and the documentation at parse.com it's not necesarily up to date.
I hope anyone can help me, or guide me, if parse.com it's not enought for my purpouse.
Thanks for reading.
I would suggest looking into Cloud Code or a Job from Parse and seeing if you can get one to run on a time interval to look for updated JSON.
You can decode JSON using JS, which is exactly what Parse Cloud Code is, you actually write it out on your own computer and then upload it. I've only use the afterSave functions. I would think you probably have to keep some type of object in parse to see what is updated and notify who ever needs to notified when that data is updated.
Also, you'll probably want to pass something to the app to actually update when the user selects the push alert. You can do this in the push alert itself. It converts to a dictionary in the app delegate's method for handling received notifications or launching with one.
Alternatively, if the web server is under your control, you can create a PHP script that will trigger the push to parse.
My best shot at this (after not having used Parse for a long while) would be to set up a Job on Parse that queries the 3rd-party service, and takes that response and throws it into a Cloud Code function, which in turn parses out that JSON and sends off a notification.
Parse's reference materials would probably be a good starting point.
The toughest part for you is the up-to-date-ness of your data. Since you're still polling that 3rd-party service at a regular interval, it's going to be a trade-off between freshness of updates and frequency of jobs (which cost money at a certain scale).

IOS Simple Messaging client, presence and typing

I'm considering adding a messaging feature to an iphone app. The idea being that given a user-based IOS app, a user may have a list of other users. He may then want to send one a message. A straight network call could accomplish this, but it misses a couple pieces:
1) The ability for a logged in user to "listen" for incoming messages without necessarily polling the server every few seconds. Does IOS support an open socket connection for listening somehow?
2) The ability for the server to detect presence of users (when they are logged in, active and listening; and immediately if they connect/disconnect)
3) the ability to detect typing, if possible
I've heard this can be achieved in javascript apps with socket.io libs, and wondering what equivalent tools exist in IOS natively? Or should a webview with JS be attempted?
EDIT:
Push notifications will likely be leveraged for offline use, but am not sure they can be a substitute for all the real time interaction.
EDIT2:
Found this SocketIO tool for IOS, but have no experience with this. It is a possibility though.
https://github.com/pkyeck/socket.IO-objc
For number one you should look at this tutorial:
http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1
It uses pushnotifications to detect incoming messages.
the other two parts are probably timing, just say a user is active for 2 min since their last activity. And every time they use something in the app or poll the server you update the time and make them active for another two minutes or so.
And you can detect typing if something is typed into the textfield. UITextField has a onChanged method. You could also start a timer to detect changes between a certain amount of time. So it doesn't say typing if someone just left their textfield filled but didn't send the message.
Hope this helps.

In Newsstand app how do I find a list of devices that are subscribed?

I can't afford UrbanAirship so I'm trying to program the server side of a Newsstand app myself.
I plan on using the JavaPNS API.
The one thing I can't seem to figure out is how to find a list of users who have a subscription in my app.
Can I query this information from Apple some how?
If I can't then I guess that means that each time a user subscribes they send their device token directly to my server. I hope this is not the case because I was hopping to run the server on my laptop and send out pushes myself without having to keep the laptop running all day listening for new subscribers.
Thanks!
Looks like I do need to register each device with my server: http://www.ibm.com/developerworks/web/library/mo-ios-push/index.html#resources
You kind of found your answer but just in case you really need a server for not only handling the push notification (for telling your app in Newsstand to check the new issue and download it in the background) but also for subscription and in-app purchasing.
Every time you launch the app you should check few things before you refresh the UI. You should check if the user is a subscriber or has user already bought the issue so you can show view/download button instead of Buy button.
Check out these tutorials if they help to understand these communications better but believe me you will end up with one of those services like Urban Airship (Which I think UA is the best option because it handles all in one not just push notification):
http://ios-blog.co.uk/tutorials/how-to-make-a-magazine-app-in-ios-part-i/
this one is more focus on server part:
http://ios-blog.co.uk/tutorials/how-to-make-a-magazine-app-in-ios-part-ii/
http://www.viggiosoft.com/blog/blog/2011/10/17/ios-newsstand-tutorial
http://www.raywenderlich.com/2797/introduction-to-in-app-purchases
And as always this is the best place for start (it has everything you need):
https://developer.apple.com/devcenter/ios/newsstand/
These are some resources to help you in developing app for Newsstand but still there are not enough people out there to share their experience.
Best of luck.
Edit: Add these two links two this list:
http://www.marco.org/2012/10/11/the-magazine
http://www.marco.org/2012/12/12/the-magazine-future-of-publishing

Resources