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.
Related
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);
}
}
}
}];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys: #"The mechanic has done a fine job improving my vehicle…", #"name", #"Click below to download this awesome app for FREE and challenge me", #"description",iTunesLink, #"link", img, #"picture", nil];
//step 2
// Invoke the dialog
[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"])
{
// User clicked the Cancel button
//nslog(#"User canceled story publishing.");
} else
{
// User clicked the Share button
//NSString *msg = [NSString stringWithFormat: #"Posted story, id: %#", [urlParams valueForKey:#"post_id"]];
// Show the result in an alert
isSharedButtonTapped = YES;
self.btnFacebookShare.userInteractionEnabled = NO;
[[[UIAlertView alloc] initWithTitle:#"Success!" message:#"Successfully shared to Facebook" delegate:nil cancelButtonTitle:#"ok" otherButtonTitles:nil] show];
}
}
}
}];
If I'm providing the picture as "URL" its posting fine. Else its throwing error. I want to post an image that is within the application bundle. Can some on tell me where I'm coding wrong?
`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];`
[FBDialogs presentShareDialogWithPhotoParams:params
clientState:nil
handler:^(FBAppCall *call,
NSDictionary *results,
NSError *error) {
if (error) {
} else {
//share successdialog
}
}];
You can use something like this
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage *img = [info objectForKey:UIImagePickerControllerOriginalImage];
FBPhotoParams *params = [[FBPhotoParams alloc] init];
// Note that params.photos can be an array of images. In this example
// we only use a single image, wrapped in an array.
params.photos = #[img];
[FBDialogs presentShareDialogWithPhotoParams:params
clientState:nil
handler:^(FBAppCall *call,
NSDictionary *results,
NSError *error) {
if (error) {
NSLog(#"Error: %#",
error.description);
} else {
NSLog(#"Success!");
}
}];
}
For more details you can check here.
However this will add the shared image to Photos which would not be the way you want it to be. It will create a folder with the name of the app and the image will be added under this.
In my application, I need to use Feed Dialog for the cases when Facebook App is not installed in users phone.
Even though I can share content with FBDialogs canPresentShareDialogWithParams method, I can't get Feed Dialog work. Dialog isn't opening and handler is not getting called.
[FBWebDialogs presentFeedDialogModallyWithSession:nil parameters:params handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error) {
NSLog(#"Error publishing story: %#", error.description);
} else {
if (result == FBWebDialogResultDialogNotCompleted) {
NSLog(#"User cancelled.");
} else {
NSDictionary *urlParams = [self parseURLParams:[resultURL query]];
if (![urlParams valueForKey:#"post_id"]) {
NSLog(#"User cancelled.");
} else {
NSString *result = [NSString stringWithFormat: #"Posted story, id: %#", [urlParams valueForKey:#"post_id"]];
// do stuff
NSLog(#"result %#", result);
}
}
}
}];
Teste on iOS7 and iOS8 and the result it's always the same.
What worked for me is to change both the picture and link fields from type NSURL to NSString. In the Facebook docs there is a good example of how to do it:
NSMutableDictionary *params =
[NSMutableDictionary dictionaryWithObjectsAndKeys:
#"Facebook SDK for iOS", #"name",
#"Build great social apps and get more installs.", #"caption",
#"The Facebook SDK for iOS makes it easier and faster to develop Facebook integrated iOS apps.", #"description",
#"https://developers.facebook.com/ios", #"link",
#"https://raw.github.com/fbsamples/ios-3.x-howtos/master/Images/iossdk_logo.png", #"picture",
nil];
I believe this would fix your problem.
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);
}
}
}
}];
}
}
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?