I am trying to send a Facebook notification from my app using Graph API Explorer. So I have selected my app, POST, and entered this string after the /
So, because I get a success using the Graph Api Explorer, I had the idea to bypass the SLRequest object, and go for the usual post request (using AFNetworking).
NSURL* url = [NSURL URLWithString:@"https://graph.facebook.com"];
AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url];
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys: appToken, @"access_token", @"index.php", @"href", @"hello", @"template", nil];
[httpClient postPath:[NSString stringWithFormat:@"/%@/notifications", theRecipientFacebookId] parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSString *responseStr = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
NSLog(@"Request Successful, response '%@'", responseStr);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"[HTTPClient Error]: %@", error.localizedDescription);
}];
AND I GET A SUCCESS:TRUE! So If I have to take a guess, I would suggest that the access_token parameter (the app Access Token) is being overwritten when using an SLRequest, and that is being overwritten by the other "access_token" (the user access token). If this is the actual explanation, it does make sense of course. But why the hell those tokens should have the same name?
EDIT : I do see the notifications, now, it works. So the problem surely came from the use of SLRequest, which I believe overwrite the access_token parameter.
ADDITIONAL INFO : you can't send a notification to a user that has not installed the application yet. In order to "invite a friend", it seems the only solution for now is to use the Dialog function from the facebook SDK.