i try send notification ios devices in order allow phone make repetitive task in background.
i've used topic make solution: parse.com cloud code schedule every n minutes doesn't work well.
edit: solved, right code is:
parse.cloud.job("backgroundupdate", function(request, response) { var pushquery = new parse.query(parse.installation); pushquery.equalto('devicetype', 'ios'); //target ios devices parse.push.send({ where: pushquery, data: { "content-available": 1 } },{ usemasterkey: true }).then(function() { response.success("push sent"); }, function(error) { response.error("got error " + error.code + " : " + error.message); }); });
and code in ios one:
- (void) application:(uiapplication *)application didreceiveremotenotification:(nsdictionary *)userinfo fetchcompletionhandler:(void (^)(uibackgroundfetchresult))completionhandler { nslog(@"remote notification background execution, userinfo %@", userinfo); [self updatehistoric]; completionhandler(uibackgroundfetchresultnewdata); }
i want run "updatehistoric" function when receive notification , have notification without showing in phone first trying see if notification receive that's why put alert on it.