I am trying to share a link using the FB messenger. When i try to share the link to facebook i keep getting an error. I googled for an answer and the couple of solutions i found did not help since everything in the plist is correct. If anyone has any advice i would really appreciate it, been trying to solve this all day.
Error:
Invalid use of FBAppCall, fb839771929379526 is not registered as a URL Scheme. Did you set 'FacebookUrlSchemeSuffix' in your plist?
Code:
// Check if the Facebook app is installed and we can present
// the message dialog
FBLinkShareParams *params = [[FBLinkShareParams alloc] init];
params.link = [NSURL URLWithString:filePath];
params.name = #"My Video";
// If the Facebook app is installed and we can present the share dialog
if ([FBDialogs canPresentMessageDialogWithParams:params]) {
// Enable button or other UI to initiate launch of the Message Dialog
// Present message dialog
[FBDialogs presentMessageDialogWithLink:[NSURL URLWithString:#"https://developers.facebook.com/ios"] 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([NSString stringWithFormat:#"Error messaging link: %#", error.description
]);
} else {
// Success
NSLog(#"result %#", results);
}
}];
} else {
// Disable button or other UI for Message Dialog
}
}
Related
I have integrated Facebook Sharing of a link with a description, caption, etc via the Native Facebook App (if it is installed) using the code:
FBLinkShareParams *params = [[FBLinkShareParams alloc] initWithLink:[NSURL URLWithString:#"https://abcde.com"]
name:#"demo"
caption:#"demo"
description:#"demo"
picture:nil];
//Present share dialog
[FBDialogs presentShareDialogWithParams:params 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);
}
}];
When this method runs, and the native facebook app is installed, I get an option to share a post that has caption, link and description. When I click share and I go on FB to check it, it appears to only have the link?
Can someone suggest a possible fix?
Most likely it is due to newest Facebook sharing policy 2.3
When I try to share on Facebook using presentOSIntegratedShareDialogModallyFrom, I can not see the app name. I use the following code:
[FBSettings setDefaultDisplayName:[[FBSettings defaultDisplayName] precomposedStringWithCanonicalMapping]];
FBLinkShareParams *params = [[FBLinkShareParams alloc] init];
params.link = [NSURL URLWithString:[arrDetailsOfTour valueForKey:#"WebAddress"]];
params.picture = [NSURL URLWithString:[arrDetailsOfTour objectForKey:#"ImageUrl"]];
params.name = [NSString stringWithFormat:#"%#",[arrDetailsOfTour valueForKey:#"CompanyName"]];
[FBDialogs presentOSIntegratedShareDialogModallyFrom:self initialText:[NSString stringWithFormat:#"%#",[arrDetailsOfTour valueForKey:#"CompanyName"]] image:toursImageView.image url:[NSURL URLWithString:[arrDetailsOfTour valueForKey:#"WebAddress"]] handler:^(FBOSIntegratedShareDialogResult result, NSError *error) {
if(error) {
NSLog(#"Error: %#", error.description);
} else {
NSLog(#"Success!");
}
}];
but I am not able to see the app name in the post. I have put Facebook Display name in plist, but still it does not show. Please help.
Apple controls the UI for the iOS integrated dialog, and they don't show the app name. The native Facebook Share Dialogs and the web dialogs will.
I'm currently trying to add Facebook SDK to the iOS version of my app. The login, logout, share, and request features are all currently working, but I'm having difficulty getting the MessageDialog feature to work. The Facebook app and the Facebook Messenger app are currently installed on my devices. However, every time I call 'FBDialog canPresentMessageDialogWithParams:params' it returns false.
My guess is that this feature doesn't work while the app is still in development mode, but that is just a guess. Does anyone know if Message Dialog works with apps that are under development? Or do you have any ideas as to what I am doing wrong?
I've also included my code in case I've made any bone-headed mistakes. Any help is greatly appreciated!
// Check if the Facebook app is installed and we can present the share dialog
FBLinkShareParams *params = [[FBLinkShareParams alloc] init];
params.link = [NSURL URLWithString:#"https://www.facebook.com/"];
params.name = #"Flash Bear";
params.caption = nil;
params.picture = nil;
params.linkDescription = #"I'm playing Flash Bear. Why don't you come join me?";
// If the Facebook Messenger app is installed and we can present the share dialog
if ([FBDialogs canPresentMessageDialogWithParams:params]) {
// Present message dialog
[FBDialogs presentMessageDialogWithParams:params
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 messaging link: %#", error.description);
} else {
// Success
NSLog(#"result %#", results);
}
}];
} else {
// Present the feed dialog
// Put together the dialog parameters
UIAlertView *message = [[UIAlertView alloc] initWithTitle:#"Sorry!"
message:#"There was an error connecting to FB Messenger. Please make sure that it is installed."
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles:nil];
[message show];
}
I also had same problem with my application.
I resolved it by checking active session state. If state for active session is other than open then we need to open session again.
For doing the same use following code.
if([FBSession activeSession].state != FBSessionStateOpen){
BOOL result = [FBSession openActiveSessionWithAllowLoginUI:NO];
if(result)
{
//Do your stuff here
}
}
Best luck.
I am trying to post Facebook page link from my iPhone app on Facebook but it gave me error
Error publishing story :The operation couldn’t be completed.
(com.facebook.Facebook.platform error 102.)
I am using below code:
- (void)showShareFbDialog
{
// Check if the Facebook app is installed and we can present the share dialog
FBLinkShareParams *params = [[FBLinkShareParams alloc] init];
params.link = [NSURL URLWithString:#"https://www.facebook.com/hellothemes"];
params.name = #"Title";
params.caption = #"Caption";
params.picture = [NSURL URLWithString:imageName];
params.linkDescription = #"Description";
// 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
name:params.name
caption:params.caption
description:params.linkDescription
picture:params.picture
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([NSString stringWithFormat:#"Error publishing story: %#", error.description]);
NSLog(#"Error publishing story :%#", error.localizedDescription);
} else {
// actions to perform
}
}];
} else {
// Present the feed dialog
[self shareLinkWithAPICalls];
}
}
I am using latest Facebook SDK. Kindly help me to fix the issue.
Hi I have the following problem.
If I share an facebook event url (like https://www.facebook.com/events/) from an iOS app I have two possibillities:
(1) iOS facebook app is installed
(2) iOS facebook app is not installed
I case 1 everything works just fine. The facebook app fetches the event information, shows up a right preview and also the post on the facebook wall is right.
In case 2 I use the FBWebDialods class and it shows up a preview without the picutre and also the post on the facebook wall is just text. No image and no attend button.
Has somebody an idea of how I can get the same resulting post on the facebook wall in both cases?
i get the response from https://developers.facebook.com/docs/ios/share/:
// Check if the Facebook app is installed and we can present the share dialog
FBShareDialogParams *params = [[FBShareDialogParams alloc] init];
params.link = [NSURL URLWithString:#"https://developers.facebook.com/docs/ios/share/"];
params.name = #"Sharing Tutorial";
params.caption = #"Build great social apps and get more installs.";
params.picture = [NSURL URLWithString:#"http://i.imgur.com/g3Qc1HN.png"];
params.description = #"Allow your users to share stories on Facebook from your app using the iOS SDK.";
// If the Facebook app is installed and we can present the share dialog
if ([FBDialogs canPresentShareDialogWithParams:params]) {
// Present the share dialog
} else {
// Present the feed dialog
}
and in Present the share dialog you add :
[FBDialogs presentShareDialogWithLink:params.link
name:params.name
caption:params.caption
description:params.description
picture:params.picture
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([NSString stringWithFormat:#"Error publishing story: %#", error.description]);
} else {
// Success
NSLog(#"result %#", results);
}
}];
i hope this help you