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
Related
i have integrate the facebook sdk for post something on facebook.Its working for only single facebook-id which is used for integrating facebook it in my application, not working for other.
this is my code
-(IBAction)postOnFacebook:(id)sender {
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);
}
}
}
}];
}
// A function for parsing URL parameters returned by the Feed Dialog.
- (NSDictionary*)parseURLParams:(NSString *)query {
NSArray *pairs = [query componentsSeparatedByString:#"&"];
NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
for (NSString *pair in pairs) {
NSArray *kv = [pair componentsSeparatedByString:#"="];
NSString *val =
[kv[1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
params[kv[0]] = val;
}
return params;
}
this meth
Error come when i use another id for login
You are using the publish_action permission which can be made availaible to all users only after approval from facebook.
Currently you might have created the facebook app in your account and with that account id you will be able to post to facebook. This is because of the reason that facebook gives all the permissions to users who are added as Developers/Testers in the App Dashboard.
You can add people to your app as Testers/Developers by following the steps as described below
You'll need to be an admin to give someone a role on your Page. If the person is your Facebook friend:
Go to your Page and tap More.
Tap Edit Settings > Page Roles.
Tap Add Person to Page. You may need to enter your password to continue.
Begin typing a friend's name and tap their name from the list that appears.
Tap to choose a role > Add.
If the person isn't your Facebook friend, you can log into Facebook from a computer and add them by entering their email address.
Depending on their settings, the person may receive a notification or an email when you give them a role.
These users who are added will have all the permission that you are requesting.
If you want the permissions to be availaible to everyone, your facebook app should be approved and for that you have to submit your app to facebook for review. The guidelines for facebook app submision can be found from the following link
https://developers.facebook.com/docs/apps/review
Hope this helps you
I'm not sure if I understood your question.
But, for what I'm seeing. If you have created app at facebook (to integrate with your iOS app) you have to use the facebook app ID only, presented at Facebook.
Or, if this error is because you are trying to login with another facebook account. This is happening probably because you did not publish your app yet (facebook app). So it's not available to everyone, but its ok because you probably don't want to make it available right now. So you just need to go to the left menu at Roles in your facebook app page and add test users (the account that you're trying to login) or add as administrator.
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
}
}
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
I am attempting to share a generated image through the facebook app with the FBDialog class. The idea is to allow tagging of friends and locations so the SLComposeViewController isn't quite as ideal (though I am falling back to that). The problem is that after it opens the facebook app and the users presses share, it never actually shares. It gets stuck at the loading screen and the bar keeps starting back from 0%, going past 100%, then back to 0.
I'm using the following code. I'm not sure if this is a problem with my implementation or with the facebook app itself.
if ([FBDialogs canPresentShareDialogWithPhotos]) {
FBPhotoParams *params = [[FBPhotoParams alloc] init];
UIImage *img = [self generatePrayerImage];
params.photos = #[img];
[FBDialogs presentShareDialogWithPhotoParams:params
clientState:nil
handler:^(FBAppCall *call,
NSDictionary *results,
NSError *error) {
if (error) {
NSLog(#"Error: %#",
error.description);
} else {
NSLog(#"Success!");
}
}];
}
Thanks.
I was able to fix this by setting the correct facebook app name in my info.plist. For some reason there must have been a small difference between the one I set on developer.facebook.com and my app.
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.