The problem has been circumvented, now using Push Notifications instead of Local Notifications. Parse.com itself offers a feature called Cloud Code, where you can write a task to read the feed from time to time and trigger push notifications. Here is the commented code below:
Remembering that the code is done in Javascript by referencing the XMLReader libraries and SAX
var xmlreader = require('cloud/xmlreader.js');
var url = "http://www.zelda.com.br/rss.xml";
function SavePost(title, link){
var PostClass = Parse.Object.extend("Post");
var post = new PostClass();
post.set("title", title);
post.set("link", link);
post.save();
}
function SendPush(title, link){
var query = new Parse.Query(Parse.Installation);
Parse.Push.send({
where: query,
data: {
url: link,
alert: title,
sound: "default"
}
}, {
success: function() {
SavePost(title, link);
},
error: function(error) {
console.log("Error sending push: " + error);
}
});
}
Parse.Cloud.job("fetchPosts", function(request, response) {
Parse.Cloud.httpRequest({
url: url,
success: function(httpResponse) {
var responseText = httpResponse.text;
xmlreader.read(responseText, function (err, res){
var newPost = res.rss.channel.item;
var title = newPost.array[0].title.text();
var link = newPost.array[0].link.text();
var PostClass = Parse.Object.extend("Post");
var query = new Parse.Query(PostClass);
query.equalTo("link", link);
query.find({
success: function(results) {
if (results.length == 0){
SendPush(title, link);
} else {
response.error("Post already pushed");
}
}
});
});
},
error: function(httpResponse) {
console.error('Request failed with response code ' + httpResponse.status);
response.error("Error fetching posts from feed");
}
});
});