Facebook iOS SDK 4.X - How to send "App Requests" - ios

Facebook 3.X
[FBWebDialogs presentRequestsDialogModallyWithSession:nil
message:[NSString stringWithFormat:#"Discover celebrities in real life."]
title:nil
parameters:nil
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 4.X documentation says that FBWebDialogs "is replaced by strongly typed dialogs. See FBSDKGameRequestDialog, FBSDKAppGroupAddDialog, FBSDKAppGroupJoinDialog."
I'm looking at initializing FBSDKAppGroupJoinDialog but how is this done, is there an example?

FBSDKAppGroupJoinDialog *appGroupJoinDialog = [[FBSDKAppGroupJoinDialog alloc] init];
appGroupJoinDialog.delegate = self;
appGroupJoinDialog.groupID = groupID; // <-- this is the group ID to join
[appGroupJoinDialog show];

Related

IOS Facebook Friend Invite Not Working in facebook sdk

i m working on project where i require invite facebook friend but notification is not sent in facebook account.
NSString *frindId=[[self.checkitem1 objectAtIndex:indexPath.row]valueForKey:#"id"];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"Come check out my app.", #"message",
frindId, #"to",
nil];
[FBWebDialogs presentRequestsDialogModallyWithSession:nil message:[NSString stringWithFormat:#"Come check out my app."]
title:#"MyWorkOut"
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.");
}
}
}
];
i have done above code for invite friend using Facebook sdk. is their any solution for inviting friend using facebook sdk
invitable_friends only available to Games, and requires the user_friends permission.
For more details visit
https://developers.facebook.com/docs/graph-api/reference/user/invitable_friends/

Facebook IOS Sdk Invite friends to download App

I have an invite feature to ask friends to download App.
These are my approach
1. The approach below required canvas page which i don't have.
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:nil];
[FBWebDialogs presentRequestsDialogModallyWithSession:nil
message:#"MCommerce - World Class App"
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.");
}
}}];
Post to friends wall. I am using FeedDialog and posting to friend wall is disabled by Facebook.
Any alternate way of sending an invite to ask friend download the App?

Request sent successfully but not reflecting on friend profile

// Display the requests dialog
[FBWebDialogs presentRequestsDialogModallyWithSession:nil message:#"Learn how to make your iOS apps social." 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
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);
}
}
}
}];
To clarify, requests won't show up in users wall/feed, but rather as notifications under the "globe" icon. However, requests won't show up in the notifications if:
1) The application is in Sandbox mode, and the receiver isn't a developer on the app. (any level)
2) The user has disabled requests for the app / notifications from FB. (https://www.facebook.com/settings?tab=notifications)
From personal experience, I would also add that Facebook tends to not show notifications for requests if you spam them too much or if you have low rating for posts. (Check facebook.com/insights)

The permission of Facebook post is "Only me" using FBWebDialogs

I want to post text and link from iOS app to user timeline. I copy and paste FBWebDialogs example.
Problem 1:
The post appear in my timeline but the permission is "Only me", not friend or public.
Problem 2:
The result object (FBWebDialogResult) is nil. Log appear in my console.NSLog(#"User canceled story publishing.");
Problem 3:
The permission of preview box is "only me" even I set it to public
Attached setting of my Facebook page:
Here is my code:
[FBWebDialogs presentFeedDialogModallyWithSession:nil
parameters:params
handler:
^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error) {
// Error launching the dialog or publishing a story.
NSLog(#"Error publishing story.");
} else {
if (result == FBWebDialogResultDialogNotCompleted) {
// User clicked the "x" icon
NSLog(#"User canceled story publishing.");
} else {
// Handle the publish feed callback
NSDictionary *urlParams = [self parseURLParams:[resultURL query]];
if (![urlParams valueForKey:#"post_id"]) {
NSLog(#"User canceled story publishing.");
} else {
NSString *msg = [NSString stringWithFormat:
#"Posted story, id: %#",
[urlParams valueForKey:#"post_id"]];
[[[UIAlertView alloc] initWithTitle:#"Result"
message:msg
delegate:nil
cancelButtonTitle:#"OK!"
otherButtonTitles:nil]
show];
}
}
}
}];
The setting page of my app is "only me" by default. I don't expect all my users change this setting here.
OMG. I stuggled for whole day but no progress. I found solution as soon as I ask question.
The problem is I copied inappropriate sample code. Ichanged to [FBSession openActiveSessionWithPublishPermissions] and problem solved.
Here is the login code I used. My post can be public now.
- (void)buttonRequestClickHandler:(id)sender {
// FBSample logic
// Check to see whether we have already opened a session.
if (FBSession.activeSession.isOpen) {
// login is integrated with the send button -- so if open, we send
// [self sendRequests];
NSLog(#"Login in facebook");
} else {
NSArray *permission = [NSArray arrayWithObjects:#"publish_actions", nil];
[FBSession openActiveSessionWithPublishPermissions:permission defaultAudience:FBSessionDefaultAudienceEveryone allowLoginUI:YES completionHandler:^(FBSession *session,
FBSessionState status,
NSError *error) {
// if login fails for any reason, we alert
if (error) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Error"
message:error.localizedDescription
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles:nil];
[alert show];
// if otherwise we check to see if the session is open, an alternative to
// to the FB_ISSESSIONOPENWITHSTATE helper-macro would be to check the isOpen
// property of the session object; the macros are useful, however, for more
// detailed state checking for FBSession objects
} else if (FB_ISSESSIONOPENWITHSTATE(status)) {
// send our requests if we successfully logged in
NSLog(#"Login in facebook"); }
}];
}

IOS fb invites sent but not shown on users wall

I am sending requests from my app to the fb friends but i am not getting any notification on the wall of fb user whom i sent request ?
I am using FB SDK 3.2 (i hope its the latest)
Following is the code i am using to send request
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
friendList, #"to",
nil];
[FBWebDialogs presentRequestsDialogModallyWithSession:nil
message:[NSString stringWithFormat:#"I just smashed %d friends! Can you beat it?", 15]
title:#"Total Smashed Score"
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.");
}
}
}
];
The request dialog is properly shown, when i click send button the invites are sent but not shown on the users wall. Any type of help will be appreciated.
Regards.
Invites are never shown on the user's wall / timeline. There are only viewable in private by the user they are sent to. The will show up on the Requests page or as a notification to the user.
Here is my solution
//friendlist = NSString of fb id's
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
friendList, #"to",
nil];
[FBWebDialogs presentRequestsDialogModallyWithSession:nil
message:[NSString stringWithFormat:#"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 {
NSDictionary *urlParams = [self parseURLParams:[resultURL query]];
if (![urlParams valueForKey:#"request"]) {
// User clicked the Cancel button
NSLog(#"User clicked cancel button.");
} else {
nslog("succesfully sent invites");
}
}
}
}
];

Resources