I am willing to mark a user's notification as read using the facebook graph api, but I am now starting to wonder if that is possible at all. Here is what I am trying now, which is a solution I found in this question on stackoverflow.
$http({method: 'POST', url: 'https://graph.facebook.com/' + item.id + '?unread=0'}).
success(function(data, status, headers, config) {
// this callback will be called asynchronously
// when the response is available
deferred.resolve(status);
}).
error(function(data, status, headers, config) {
// called asynchronously if an error occurs
// or server returns response with an error status.
});
Of course, item.id
is the id of the notification.
I am using angular for my http requests, but I dont mind other methods too, just angular's is the easiest for me. I am also looking forward to hear any ideas on how to mark notifications as read, I don't prefer any way, just want it to happen somehow.
This is the solution I found a while ago, forgot to post. (Note that I am using angular.js, if you are not either make the promise with q or rsvp libraries or don't)
function (notificationId) {
var deferred = $q.defer();
FB.api(
'https://graph.facebook.com/' + notificationId, 'post', {
unread: 0
},
function (response) {
if (!response || response.error) {
deferred.reject(response.error);
} else {
deferred.resolve(response);
}
});
return deferred.promise;
}