Can't pass PDF URL to Facebook using SLComposeViewController
I have created an exchange module for Titanium Appcelerator using social.framework. Below is my code:
- (id) Facebook {
//if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
//{
NSLog(@"Sharing via Facebook", nil);
SLComposeViewController *fbSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[fbSheet setInitialText: [dictPost valueForKey: @"post"]];
[fbSheet addURL: [NSURL URLWithString: [dictPost valueForKey: @"link"]]];
NSLog(@"Sharing via Facebook 2", nil);
[[TiApp app] showModalController: fbSheet animated: YES];
NSLog(@"Sharing via Facebook 3", nil);
/*} else {
UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Facebook" message:@"Post can't be shared. Please check Settings." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles: nil] autorelease];
[alert show];
}*/
}
- (id) Tweet {
SLComposeViewController *tweetSheet = [SLComposeViewController
composeViewControllerForServiceType:SLServiceTypeTwitter];
[tweetSheet setInitialText: [dictPost valueForKey: @"post"]];
[[TiApp app] showModalController: tweetSheet animated: YES];
}
- (void) SharePost : (id) args {
ENSURE_UI_THREAD(SharePost, args);
ENSURE_UI_THREAD(Tweet, nil);
ENSURE_UI_THREAD(Facebook, nil);
NSArray *val = args;
NSDictionary *dict = [[val objectAtIndex: 0] retain];
dictPost = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects: [dict valueForKey: @"post"], [dict valueForKey: @"link"], [dict valueForKey: @"title"], [dict valueForKey: @"image"], nil] forKeys: [NSArray arrayWithObjects: @"post", @"link", @"title", @"image", nil]];
if ([[dict valueForKey: @"type"] intValue] == 1) {
[self Tweet];
} else if ([[dict valueForKey: @"type"] intValue] == 2) {
[self Facebook];
}
}
I just need to call SharePost
and he will do everything. This is the only code that applies to both Twitter and Facebook. But when I share some urls on Facebook the dialog is displayed correctly and when I select POST
it gives me an error after some (about 5) seconds. The following error occurred:
Unable to Send to Facebook - The message could not be sent because the connection to Facebook failed.
And from this error, the same can be successfully posted by choosing "Try Again". I have added screenshots here.
Please let me know if any of you have any hints.
source to share
No one has answered this question yet
See similar questions:
or similar: