Dismiss FBWebDialogs programmatically in ios - ios

I have integrated the facebook SDK with version 3.17.1 in my application and I am not able to dismiss the FBWebDialogs programmatically, I have tried the solutions provided in this link: "https://stackoverflow.com/questions/21741101/how-to-dismiss-fbwebdialogs" but no use.
Code snippet to present the FBWebDialogs:
[FBWebDialogs presentFeedDialogModallyWithSession:nil parameters:params handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error)
{
DLog(#"FBSESSION IS : %#", FBSession.activeSession);
if (error) {
// An error occurred, we need to handle the error
// See: https://developers.facebook.com/docs/ios/errors
DLog(#"%#",[NSString stringWithFormat:#"Error publishing story: %#", error.description]);
} else {
if (result == FBWebDialogResultDialogNotCompleted) {
// User canceled.
DLog(#"User cancelled.");
} else {
// Handle the publish feed callback
NSDictionary *urlParams = [self parseURLParams:[resultURL query]];
if (![urlParams valueForKey:#"post_id"]) {
// User canceled.
DLog(#"User cancelled.");
} else {
// User clicked the Share button
NSString *result = [NSString stringWithFormat: #"Posted story, id: %#", [urlParams valueForKey:#"post_id"]];
DLog(#"result %#", result);
}
}
}
}];
Can anyone help me to sort out this issue?

Related

Facebook share shows blank image on iOS but works fine on desktop

I am using AddThis from the following page: http://www.douglasstratton.com/Beaches/Amnesia/flypage.tpl.html
When sharing from the desktop, the image shares fine, but when sharing from iOS, the image is blank on the facebook wall.
Has anyone else had this issue?
You can share with this code.Only import #import <FacebookSDK/FacebookSDK.h>:-
// Put together the dialog parameters
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
APP_NAME, #"name",
self.strSerialName , #"caption",
modelObject.strChapterDescription, #"description",
#"", #"link",
modelObject.strChapterImage, #"picture",
nil];
// Show the feed dialog
[FBWebDialogs presentFeedDialogModallyWithSession:nil
parameters:params
handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error) {
// An error occurred, we need to handle the error
// See: https://developers.facebook.com/docs/ios/errors
NSLog(#"Error publishing story: %#", error.description);
} else {
if (result == FBWebDialogResultDialogNotCompleted) {
// User cancelled.
NSLog(#"User cancelled.");
} else {
// Handle the publish feed callback
NSDictionary *urlParams = [self parseURLParams:[resultURL query]];
if (![urlParams valueForKey:#"post_id"]) {
// User cancelled.
NSLog(#"User cancelled.");
} else {
// User clicked the Share button
NSString *result = [NSString stringWithFormat: #"Posted story, id: %#", [urlParams valueForKey:#"post_id"]];
NSLog(#"result %#", result);
}
}
}
}];

Sending facebook friend request invite returns the message: User canceled request

i am using this code , to send Invite friend request for facebook freinds,this code give the message is User canceled request.
[FBRequestConnection startWithGraphPath:#"/me/friends"
parameters:nil
HTTPMethod:#"GET"
completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
) {
// NSLog(#"%#", result);
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys: [NSString stringWithFormat:#"%#", result], #"to", #"send", #"action_type", #"YOUR_OBJECT_ID", #"object_id", nil];
//for (NSDictionary *params in [result objectForKey:#"data"])
{
[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 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 = [appDelegate 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);
}
}
}
}];
}
}];
Please check by adding only the following code and removing the block above this code.
[FBWebDialogs
presentRequestsDialogModallyWithSession: nil
message:#"Your invite message"
title:nil
parameters:nil
handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error) {
// An error occurred, we need to handle the error
// See: https://developers.facebook.com/docs/ios/errors
NSLog(#"Error publishing story: %#", error.description);
} else {
if (result == FBWebDialogResultDialogNotCompleted) {
// User canceled.
NSLog(#"User cancelled.");
} else {
// Handle the publish feed callback
}
}
}];

Intigration With Facebook in iOS using facebook sdk

I am trying to post image in imageview(display_image) on user's profile by using facebook SDk.Code is Like below.
FBLinkShareParams *params = [[FBLinkShareParams alloc] init];
params.link = [NSURL URLWithString:#"https://developers.facebook.com/docs/ios/share/"];
// If the Facebook app is installed and we can present the share dialog
if ([FBDialogs canPresentShareDialogWithParams:params]) {
// Present share dialog
[FBDialogs presentShareDialogWithLink:params.link
handler:^(FBAppCall *call, NSDictionary *results, NSError *error) {
if(error) {
// An error occurred, we need to handle the error
// See: https://developers.facebook.com/docs/ios/errors
NSLog(#"Error publishing story: %#", error.description);
} else {
// Success
NSLog(#"result %#", results);
}
}];
// If the Facebook app is NOT installed and we can't present the share dialog
} else {
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:image_display.image, #"picture", #"hello",#"caption",nil];
[FBWebDialogs presentFeedDialogModallyWithSession:nil
parameters:params
handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error) {
// An error occurred, we need to handle the error
// See: https://developers.facebook.com/docs/ios/errors
NSLog(#"Error publishing story: %#", error.description);
} else {
if (result == FBWebDialogResultDialogNotCompleted) {
// User canceled.
NSLog(#"User cancelled.");
} else {
// Handle the publish feed callback
NSDictionary *urlParams = [self parseURLParams:[resultURL query]];
if (![urlParams valueForKey:#"post_id"]) {
// User canceled.
NSLog(#"User cancelled.");
} else {
// User clicked the Share button
NSString *result = [NSString stringWithFormat: #"Posted story, id: %#", [urlParams valueForKey:#"post_id"]];
NSLog(#"result %#", result);
}
}
}
}];
}
it's working good with out sending image value in params dictionary. Using image app will crash here with below error
reason: '-[UIImage length]: unrecognized selector sent to instance 0x7fdd5a80e160'
can any one help me to solve this problem?
Thanks
You cannot post image you can only post image URL Example:-
-(void)fbShare{
// If the Facebook app is installed and we can present the share dialog
if ([FBDialogs canPresentShareDialog]) {
NSURL *imageURL = [NSURL URLWithString:#"https://profile_VMGhBTJVM5_1413618023060.jpg"];
[FBDialogs presentShareDialogWithLink:[NSURL URLWithString:#"http://www.Testinfo.com/"] name:#"name related to link" caption:nil description:#"Testing Desc" picture:imageURL clientState:nil handler:^(FBAppCall *call, NSDictionary *results, NSError *error) {
if(error) {
// An error occurred, we need to handle the error
// See: https://developers.facebook.com/docs/ios/errors
NSLog(#"Error publishing story: %#", error.description);
} else {
// Success
NSLog(#"result %#", results);
}
}];
// If the Facebook app is NOT installed and we can't present the share dialog
} else {
// FALLBACK: publish just a link using the Feed dialog
// Put together the dialog parameters
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"testing name", #"name",
#"Testing caption.", #"caption",
#"Desc.", #"description",
#"http://www.Testinfo.com/", #"link",
#"https://profile_VMGhBTJVM5_1413618023060.jpg", #"picture",
nil];
// Show the feed dialog
[FBWebDialogs presentFeedDialogModallyWithSession:nil
parameters:params
handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error) {
// An error occurred, we need to handle the error
// See: https://developers.facebook.com/docs/ios/errors
NSLog(#"Error publishing story: %#", error.description);
} else {
if (result == FBWebDialogResultDialogNotCompleted) {
// User canceled.
NSLog(#"User cancelled.");
} else {
// Handle the publish feed callback
NSDictionary *urlParams = [self parseURLParams:[resultURL query]];
if (![urlParams valueForKey:#"post_id"]) {
// User canceled.
NSLog(#"User cancelled.");
} else {
// User clicked the Share button
NSString *result = [NSString stringWithFormat: #"Posted story, id: %#", [urlParams valueForKey:#"post_id"]];
NSLog(#"result %#", result);
}
}
}
}];
}
}

FBWebDialogs does not show - no reaction

Please if any of you could help me with this Facebook SDK. I don't know what's going on, and the problem is that when button with facebook is clicked nothing shows up - FBWebDialog is dead but "Memory managment/consumption bar in Xcode when app is fired allocs additional memory (about 22 MB) after that action. I have followed official tutorial: https://developers.facebook.com/docs/ios/share and reainstalled facebook SDK, added things like AppID etc. Even that haven't helped me. What's wrong with that?
I'm using iphone simulator and ios 8 and Xcode 6.0. About 2 mounths ago everything worked fine. Pop-up window was showed in application until now.
Any help with this will be appreciated.
UPDATE:
MY CODE:
[FBLoginView class];
FBLinkShareParams *params = [[FBLinkShareParams alloc] init];
params.link = [NSURL URLWithString:#"https://developers.facebook.com/docs/ios/share/"];
// If the Facebook app is installed and we can present the share dialog
if ([FBDialogs canPresentShareDialogWithParams:params]) {
// Present the share dialog
[FBDialogs presentShareDialogWithLink:params.link
handler:^(FBAppCall *call, NSDictionary *results, NSError *error) {
if(error) {
// An error occurred, we need to handle the error
// See: https://developers.facebook.com/docs/ios/errors
NSLog(#"Error publishing story: %#", error.description);
} else {
// Success
NSLog(#"result %#", results);
}
}];
} else {
// Present the feed dialog
// Put together the dialog parameters
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"Sharing Tutorial", #"name",
#"Build great social apps and get more installs.", #"caption",
#"Allow your users to share stories on Facebook from your app using the iOS SDK.", #"description",
#"https://developers.facebook.com/docs/ios/share/", #"link",
#"http://i.imgur.com/g3Qc1HN.png", #"picture",
nil];
// Show the feed dialog
[FBWebDialogs presentFeedDialogModallyWithSession:nil
parameters:params
handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error) {
// An error occurred, we need to handle the error
// See: https://developers.facebook.com/docs/ios/errors
NSLog(#"Error publishing story: %#", error.description);
} else {
if (result == FBWebDialogResultDialogNotCompleted) {
// User cancelled.
NSLog(#"User cancelled.");
} else {
// Handle the publish feed callback
NSDictionary *urlParams = [self parseURLParams:[resultURL query]];
if (![urlParams valueForKey:#"post_id"]) {
// User cancelled.
NSLog(#"User cancelled.");
} else {
// User clicked the Share button
NSString *result = [NSString stringWithFormat: #"Posted story, id: %#", [urlParams valueForKey:#"post_id"]];
NSLog(#"result %#", result);
}
}
}
}];
}
Standard code from Facebook site but still no reaction.

How to post our predefined text and image on facebook using iOS FBDialogs

Im using following code of FBDialogs to share the post on facebook. (our requirement i not to use SLComposer present)
I want to share predefined text and image on the facebook post.
- (void)postAStatusMessage
{
// Check if the Facebook app is installed and we can present the share dialog
FBLinkShareParams *params = [[FBLinkShareParams alloc] init];
params.link = [NSURL URLWithString:#"https://developers.facebook.com/docs/ios/share/"];
// If the Facebook app is installed and we can present the share dialog
if ([FBDialogs canPresentShareDialogWithParams:params]) {
// Present share dialog
[FBDialogs presentShareDialogWithLink:nil
handler:^(FBAppCall *call, NSDictionary *results, NSError *error) {
if(error) {
// An error occurred, we need to handle the error
// See: https://developers.facebook.com/docs/ios/errors
NSLog(#"Error publishing story: %#", error.description);
} else {
// Success
NSLog(#"result %#", results);
}
}];
// If the Facebook app is NOT installed and we can't present the share dialog
} else {
// FALLBACK: publish just a link using the Feed dialog
// Show the feed dialog
[FBWebDialogs presentFeedDialogModallyWithSession:nil
parameters:nil
handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error) {
// An error occurred, we need to handle the error
// See: https://developers.facebook.com/docs/ios/errors
NSLog(#"Error publishing story: %#", error.description);
} else {
if (result == FBWebDialogResultDialogNotCompleted) {
// User cancelled.
NSLog(#"User cancelled.");
} else {
// Handle the publish feed callback
NSDictionary *urlParams = [self parseURLParams:[resultURL query]];
if (![urlParams valueForKey:#"post_id"]) {
// User cancelled.
NSLog(#"User cancelled.");
} else {
// User clicked the Share button
NSString *result = [NSString stringWithFormat: #"Posted story, id: %#", [urlParams valueForKey:#"post_id"]];
NSLog(#"result %#", result);
}
}
}
}];
}
}
I present the facebook screen empty as follows,
But i want to share my predefine text with the one selected image how to achieve this?

Resources