Reputation: 23
Does anyone make [FBDialogs canPresentShareDialogWithParams:nil] works properly ? It's always returning me NO. What should I put in params ?
if ([FBDialogs canPresentShareDialogWithParams:nil]) {
NSURL* url = [NSURL URLWithString:@"http://www.google.fr"];
[FBDialogs presentShareDialogWithLink:url
handler:^(FBAppCall *call, NSDictionary *results, NSError *error) {
if(error) {
NSLog(@"Error: %@", error.description);
} else {
NSLog(@"Success!");
}
}];
} else {
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
SLComposeViewController *fbComposer = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[fbComposer setInitialText:@"Google rocks !"];
[self presentViewController:fbComposer animated:YES completion:nil];
} else {
[[[UIAlertView alloc] initWithTitle:@"Informations" message:@"You have to be registered into the settings of your phone in order to share" delegate:nil cancelButtonTitle:@"Close" otherButtonTitles:nil] show];
}
}
Upvotes: 2
Views: 3250
Reputation: 318
Make sure to pass a non-nil instance of FBShareDialogParams to the canPresentShareDialogWithParams method. The SDK expects to receive a valid instance of FBShareDialogParmas so the SDK can make sure that the version of the Facebook app on the device can actually open the content that's going to be shared.
For example, if FB adds support for sharing video via Share Dialog in a future version of the Facebook app on iOS, the canPresentShareDialogWithParams would return NO if an older version of the Facebook app is present on the device.
I can understand how the docs: https://developers.facebook.com/ios/share-dialog/ might be confusing here (apologies!). We'll update them to reflect this.
Thanks for the feedback; hope that helps!
Upvotes: 0
Reputation: 1276
According to the HelloFacebookSample from the SDK (and my own experience!):
FBShareDialogParams *p = [[FBShareDialogParams alloc] init];
p.link = [NSURL URLWithString:@"http://developers.facebook.com/ios"];
BOOL canShareFB = [FBDialogs canPresentShareDialogWithParams:p];
canShareFB will return YES if the Facebook app is installed in the system; returns NO if no Facebook app is found.
Upvotes: 3