Adding URL in Twitter and Facebook sharing in iOS application using Social framework for iOS 8.4 is not working.
Only setInitialText:
method is working but not the addURL
and setTile
methods.
My code is as follows:
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
SLComposeViewController *fbFeed = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[fbFeed setInitialText:self.travelogueTitle];
[fbFeed addURL:[NSURL URLWithString:self.saveTraveloguePublishedURL]];
[fbFeed setTitle:@"My Trip's Memories"];
NSLog(@"Save published url:%@",self.saveTraveloguePublishedURL);
NSLog(@"Share published url:%@",travelogue.publishedUrl);
// [fbFeed setInitialText:[NSString stringWithFormat:@"http://mvm064/MVPWeb/ViewTravelogue?travelogueId=OB1YlsTz/gngmCUTESuqlQ=="]];
[fbFeed setCompletionHandler:^(SLComposeViewControllerResult result) {
if (result == SLComposeViewControllerResultCancelled) {
NSLog(@"The user cancelled.");
}
else if (result == SLComposeViewControllerResultDone) {
NSLog(@"The user posted to Facebook");
}
}];
[self presentViewController:fbFeed animated:YES completion:nil];
}}
There is no method in SLComposeViewController
to setTitle
. SLComposeViewController
is basically subclass
of UIViewController
so giving you facility to set title of SLComposeViewController
. It will not going to post on Facebook
. For post on Facebook
you have method called setInitialText
.
I have tried with your code and its get uploaded successfully, you can check out in following image.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.