Facebook iOS App Invite Friends - ios

I am using Facebook SDK to connect Facebook in my app. User can send invitation to their friends. (Using the Requests dialog provided by FB SDK).
https://developers.facebook.com/docs/tutorials/ios-sdk-games/requests/
And I'm trying to keep the friend list clear if the friend is already invited (ever the friend is accepted or not), hide the friend from the list. But I can't find the way to do this. Is there a way to do this?

Facebook documentation is horrible but I found it is possible exclude authenticated friends as follows:
// See https://developers.facebook.com/docs/games/requests/v2.1 for explanation of the possible parameter keys
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
// Optional parameter for sending request directly to user
// with UID. If not specified, the MFS will be invoked
// #"RECIPIENT_USER_ID", #"to",
// Give the action object request information
// #"send", #"action_type",
// #"YOUR_OBJECT_ID", #"object_id",
#"app_non_users", #"filters",
nil];
[FBWebDialogs
presentRequestsDialogModallyWithSession:nil
message:#"Join me!"
title:#"Invite Friends"
parameters:params
handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error) {
// Case A: Error launching the dialog or sending request.
NSLog(#"Error sending request.");
} else {
if (result == FBWebDialogResultDialogNotCompleted) {
// Case B: User clicked the "x" icon
NSLog(#"User canceled request.");
} else {
NSLog(#"Request Sent.");
}
}
}];
#"app_non_users", #"filters", is the important part!

I dont think you can exclude friends that have had the request sent to them but you can suggest friends to populate in that list. Perhaps if you already know who you have sent the request to you can populate the list with the rest of your friends.

Related

Facebook invite people for my app from user friend list

I was using ios friend request dialog from facebook to send invitation to user for my app. After facebook announced closing of their API it stopped working, Does anyone have an idea how to invite people for application for ios.
You can use this code.
- (void)inviteFriendsOfFacebook
{
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:[mArrTempSelected componentsJoinedByString:#","], #"suggestions", nil];
[FBWebDialogs presentRequestsDialogModallyWithSession:nil
message:textView.text
title:nil
parameters:params
handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error) {
// Case A: Error launching the dialog or sending request.
NSLog(#"Error sending request.");
} else {
if (result == FBWebDialogResultDialogNotCompleted) {
// Case B: User clicked the "x" icon
NSLog(#"User canceled request.");
}
else
{
[Helper showAlertForMessage:#"Invitation Sent Successfully." title:nil cancelButton:#"Ok" otherButton:nil andDelegate:nil withTag:0];
}
}}];
}
Facebook has announced that this will work only for Games application, though one can do this. Just set canvas url for app on Facebook app and use faecbook request dialog. This is very usefull feature for any app.Facebook is working on this feature to make available easily.

List out all Facebook friends in native invite dialogbox in iOS

i'm trying to invite facebook friends in ios. successfully i got the output also. I attached that output image also.
My Question is, here i can see the suggested friends list instead of display my all friends. but while am searching any of friends in search bar, then it display that search list. My code is,
NSString *MY_URL = [NSString stringWithFormat:#"xxxxxxxxxx://host"];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithCapacity:0];
[params setObject:#"Hi, Check out this app, You'll love it!" forKey:#"message"];
[params setObject:MY_URL forKey:#"link"];
[FBWebDialogs presentRequestsDialogModallyWithSession:FBSession.activeSession
message:#"Friends Invite"
title:#"xxxxxxxx"
parameters:params handler:
^(FBWebDialogResult result, NSURL *resultURL, NSError *error)
{
if (!error) {
NSLog(#"Url : %#",resultURL);
NSLog(#"Result : %u",result);
NSDictionary *urlParams = [self parseURLParams:[resultURL query]];
if (![urlParams valueForKey:#"request"]) {
// User clicked the Cancel button
NSLog(#"User canceled request.");
} else {
// User clicked the Send button
NSString *requestID = [urlParams valueForKey:#"request"];
NSLog(#"Request ID: %#", requestID);
}
}
else
{
NSLog(#"Error : %#",[error localizedDescription]);
}
}];
My point is how can i display all my friends in this invite list itself.
For Facebook Apps registered later than April 2014, you can not access to all friends unless you are implementing a game/canvas app. (if this is your case, you will need to use invitable_friends endpoint)
Otherwise, unfortunately, you will be able to only access users facebook friends who have already signedin to your app.
Note: Even if your app was created before April 2014, all friends will be useless after april 2015.
For more info in facebook developer
New features available in v2.0
Taggable Friends API: We've added a new endpoint called /me/taggable_friends that you can use in order to generate stories that have friends tagged in them, even those friends don't use your app. If you want to use the taggable friends API, your app will require review.
Invitable Friends API: We've added a new endpoint called /me/invitable_friends that you can use to generate a list of friends for someone to invite to your game through a custom interface. This API is only available to apps that are games on Facebook Canvas.

how to send request notification for application using FBDialog in IOS?

I am trying to send invitation to my facebook friends through my application. I have friends list of my facebook friends in my application, I used FBWeb-dialog to send invitation to my friends. After selection my friends to whom I want to send request I am sending request them and its working fine, but my problem is that they are not receiving any notification to their wall. Can anybody tell me what should I do to notify them via notification. I am attaching my code also.
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:[arrSelectedFriends componentsJoinedByString:#","], #"suggestions",nil];
[FBWebDialogs presentRequestsDialogModallyWithSession:nil
message:#"User X” has invited you to join demoApp,Download the free app here."
title:nil parameters:params
handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error)
{
if (error)
{
// Case A: Error launching the dialog or sending request.
NSLog(#"Error sending request.");
}
else
{
if (result == FBWebDialogResultDialogNotCompleted)
{
// Case B: User clicked the "x" icon
NSLog(#"User canceled request.");
} else {
NSLog(#"Request Sent.");
}
}
}];

Facebook SDK method presentRequestsDialogModallyWithSession is not sending any request to my friends

I'm trying to send a comment using Facebook iOS SDK to my FB friends.
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:[[_usersFB valueForKey:#"selectValue"] componentsJoinedByString:#","], #"to",
nil];
[FBWebDialogs
presentRequestsDialogModallyWithSession:nil
message:#"Test Comment"
title:nil
parameters:params
handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error) {
// Error launching the dialog or sending the request.
NSLog(#"Error sending request.");
} else {
if (result == FBWebDialogResultDialogNotCompleted) {
// User clicked the "x" icon
NSLog(#"User canceled request.");
} else {
// Handle the send request callback
}
}
}];
I'm using FB SDK v3.5.3.
I see all the friends in the FBDialog but when I tap on the send button the callback returns no error assuming it worked but my selected friends hasn't received anything.
FYI - My FB app is not in sandbox mode.
Any pointers would be greatly appreciated.
Cheers
Make sure you open the facebook page or app in an iPhone device when you check if it worked.
The notifications will not appear on facebook on on desktop browsers, only on iPhones.
I hope it helps.

Facebook App Request not being sent in iOS

I have my app set up to send facebook app requests. I get the popup screen to pick friends and when I click on send button, the popup disappears. And I get a request ID printed out in the console as well.
Although the friends that I have selected to send the request has not received the app request.
I have facebook sdk 3.1 which works well with other activities such as posting to user's walls etc.
Possible duplicates:
Facebook iOS SDK - Sending a facebook user an app request
How to Send App request to facebook friends through facebook iOS sdk?
The answer on the second link provides a step by step procedure on how to fix this.
Make sure your facebook app id is same in both developer page and info in xcode next, enable sandbox mode and must fill canvas url [under app on facebook category] in developer page.
NSString *facebookID = #"Your friend facebook id";
NSMutableDictionary* params =
[NSMutableDictionary dictionaryWithObject:facebookID forKey:#"to"];
NSString *message = #"SOME_MESSAGE";
NSString *title = #"TITLE";
[FBWebDialogs presentRequestsDialogModallyWithSession:nil
message:message
title:title
parameters:params handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error)
{
// Case A: Error launching the dialog or sending request.
NSLog(#"Error sending request.");
}
else
{
if (result == FBWebDialogResultDialogNotCompleted)
{
// Case B: User clicked the "x" icon
NSLog(#"User canceled request.");
}
else
{
NSLog(#"Request Sent. %#", params);
}
}}];

Resources