-1

I'm building an app where I need to get new PFObjects as users upload them. Currently what I'm doing is running a query every 10 seconds to query the database for new objects.

As you could imagine, this is extremely inefficient and heavy on requests.

I was wondering if there was any way of triggering a query if the database in parse has been updated? For example a user saves an object to parse, which triggers a query on all other users devices to download the new object.

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
dan martin
  • 1,307
  • 3
  • 15
  • 29

1 Answers1

0

I would recommend when you new item is created in a data you should post a push notification with to inform others that new data and when you app get push notification app should pull new data.

let push:PFPush = PFPush()
        let dic:[String:NSNumber] = ["content-available" :NSNumber(integer: 1)]
        push.setData(dic)
        push.sendPushInBackground()

And on didReceiveRemoteNotification check for content-available if it has value the fetch new content

func application(application: UIApplication!, didReceiveRemoteNotification userInfo:NSDictionary!) {

    var notification:NSDictionary = userInfo.objectForKey("aps") as NSDictionary

    if (notification.objectForKey("content-available") != nil){
    }
}
Adnan Aftab
  • 14,377
  • 4
  • 45
  • 54