iOS - Posting to Facebook... is the icon this one? - iphone

I am posting to Facebook using the social api of iOS 6.
I am using the tradicional SLComposeViewController, like in..
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
...
at some point I do
[controller addImage:imageFacebook];
where imageFacebook is a screenshot that is 280 pixels high and then I post to Facebook.
My problem is this. I am following similar approach with the twitter API, but when that little window shows, there is a thumbnail of the image I am sending, hold by a clips on the right side, but on the facebook counterpart I see this safari-like icon. Is this normal? I would be a happy man if I was seen here a miniature of the image being posted, as I saw with the twitter API...
NOTE: the image is being posted correctly to Facebook... my problem is this icon on the posting window.
Is there a way to change that icon?
thanks

if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
SLComposeViewControllerCompletionHandler myBlock = ^(SLComposeViewControllerResult result){
if (result == SLComposeViewControllerResultCancelled) {
NSLog(#"Cancelled");
} else {
NSLog(#"Done");
}
[controller dismissViewControllerAnimated:YES completion:Nil];
};
controller.completionHandler = myBlock;
[controller setInitialText:#"Enter Your Text Here:"];
[controller addURL:[NSURL URLWithString:#"http://www.google.com"]];
[controller addImage:[UIImage imageNamed:#"image001-794043.jpeg"]];
[self presentViewController:controller animated:YES completion:Nil];
} else {
NSLog(#"UnAvailable");
}

Related

SLServiceTypeFacebook in SLComposeViewController hang my iphone app

I have implemented Facebook sharing in my app. But When composerview is opened and i tapped on post, after that it will block my app. I am not able to navigate to other view controller. Here is the code that i have used:
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
SLComposeViewControllerCompletionHandler myBlock = ^(SLComposeViewControllerResult result){
if (result == SLComposeViewControllerResultCancelled) {
} else {
}
[controller dismissViewControllerAnimated:YES completion:Nil];
};
controller.completionHandler = myBlock;
[controller setInitialText:strMsg];
[vc presentViewController:controller animated:YES completion:Nil];
I faced the same issue and debugged as well. In my case it was not a hang; after the SLCompeseViewController disappeared (moved up the screen) there were some UIViews, UIControls remaining on the controller.view which hinder user interaction (i think it is the same in your app).
If it is the same case, you will never be able to remove those Views because the completion handler is never called.
This is a bug in iOS8, here is the link.
https://developers.facebook.com/bugs/962985360399542/?search_id
I suggest you to use UIActivityViewController instead of SLComposeViewController.

post image to facebook page

Im using SocialFramework for posting image to facebook. When i click the button the facebook page is opening. But my need is, i need to share my image to not in my wall, share to following facebook page https://www.facebook.com/Google
code:
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[controller setInitialText:#"My image"];
[controller addImage:newImage.image];
[self presentViewController:controller animated:YES completion:Nil];
}

Social framework - how to know if message was sent or not

I'm using Social framework in my project (iOS6), so user can make posts on Facebook or Twitter.
My question is, if there is a way to find out if user have sent a post to social network or he have canceled it and haven't published anything?
I use this code to share posts on Twitter:
-(IBAction)askOnTwitter
{
if (SYSTEM_VERSION_LESS_THAN(#"6.0"))
{
[self showErrorAlert];
twitterButton.enabled = NO;
return;
}
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter])
{
slComposeViewController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
[slComposeViewController setInitialText:#"Hey"];
[self presentViewController:slComposeViewController animated:YES completion:nil];
// So have user published a post or he haven't? How to know?
}
}
Does somebody know the trick? Thanks in advance.
You can set the completion handler for your compose view controller. There you will get the result SLComposeViewControllerResultDone or SLComposeViewControllerCancelled
__block __weak SLComposeViewController *slComposeViewController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
[slComposeViewController setCompletionHandler:^
(SLComposeViewControllerResult result){
if (result == SLComposeViewControllerResultDone) {
NSLog(#"Done successfully");
}
else{
NSLog(#"Cancelled");
}
[slComposeViewController dismissViewControllerAnimated:YES completion:nil];
}];

shadow screen occur with Social Framework on iOS

I create application with feature 'shared with facebook'
I use this code for make a facebook sharing
[facebookViewController setInitialText:[NSString stringWithFormat:#"via %#", self.randomGame.name]];
NSLog(#"%#", self.resultImageView.image);
[facebookViewController addImage:self.resultImageView.image];
[facebookViewController setCompletionHandler:^(SLComposeViewControllerResult result){
if (result == SLComposeViewControllerResultCancelled) {
NSLog(#"Dialog Did Cancel");
}
}];
[self presentViewController:facebookViewController animated:YES completion:nil];
I already have allocation/initialization facebookViewController object with SLComposeViewController.
first time I share there is no problem.
But, I share second time I get a shadow screen like this
can anyone help ?
Thanks for advance.
i am not sure but every time you present the facebook popover you also need to dismiss it in the completion block like
[facebookViewController dismissViewControllerAnimated:YES completion:Nil];
hope it helps
I done it with code
facebookViewController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[facebookViewController setInitialText:[NSString stringWithFormat:#"via %#", self.randomGame.name]];
[facebookViewController addImage:self.resultImageView.image];
[self presentViewController:facebookViewController animated:YES completion:nil];

Twitter Post iOS6 'Cancel' button issue

I'm in the process of changing my app for iOS6 and iPhone use, I can't seem to figure out why when I post from Twitter using the new Social framework I have to press 'Cancel' twice to close, anybody else have this issue or a fix? Here is the code for the button.
- (IBAction)twitterPost:(id)sender
{
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter])
{
mySLComposerSheet = [[SLComposeViewController alloc] init];
mySLComposerSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
[mySLComposerSheet setInitialText:[NSString stringWithFormat:#"This is my tweet, hello!",mySLComposerSheet.serviceType]];
[self presentViewController:mySLComposerSheet animated:YES completion:nil];
}
[mySLComposerSheet setCompletionHandler:^(SLComposeViewControllerResult result) {
NSLog(#"dfsdf");
switch (result) {
case SLComposeViewControllerResultCancelled:
break;
case SLComposeViewControllerResultDone:
break;
default:
break;
}
}];
}
If your using the mySLComposerSheet this works great...
[mySLComposerSheet setCompletionHandler:^(SLComposeViewControllerResult result) {
[mySLComposerSheet dismissViewControllerAnimated:YES completion:nil];
My experience with SLComposeViewController is that twitter and weibo controllers need to be dismissed manually while the facebook controller seems to be better behaved.
If I don't dismissViewControllerAnimated myself, tapping the "Send" button will send the tweet or weibo posting but I'll be left with what seems to be an invisible view over my own view. Thus I can no longer interact with my app.
I don't know why my app is working like this... Interestingly, the completionHandler for cancel gets called just once. The second tap dismisses the view controller.
+ (void) shareText:(NSString*)text image:(UIImage*)image social:(NSString*)service url:(NSString*)url
{
SLComposeViewController* controller = [SLComposeViewController composeViewControllerForServiceType:service];
[controller setInitialText:text];
[controller addImage:image];
[controller addURL:[NSURL URLWithString:url]];
controller.completionHandler = ^(SLComposeViewControllerResult result) {
if( SLComposeViewControllerResultDone == result )
{
NSLog(#"rewards for share: %#!", service );
}
if( ![SLServiceTypeFacebook isEqualToString:service] ) // facebook behaves
[[CBLAppDelegate instance].activeViewController dismissViewControllerAnimated:true completion:nil];
};
[[CBLAppDelegate instance].activeViewController presentViewController:controller animated:true completion:nil];
}
Found the issue. It only happens when a completion handler is added to TWTweetComposeViewController. If added, make sure to call:
[self dismissModalViewControllerAnimated:YES];
Try this buddy
[mySLComposerSheet setCompletionHandler:^(SLComposeViewControllerResult result) {
switch (result) {
case SLComposeViewControllerResultCancelled:
[self performSelector:#selector(showalert)];
[mySLComposerSheet dismissViewControllerAnimated:YES completion:nil];
break;
case SLComposeViewControllerResultDone:
[self performSelector:#selector(showalert1)];
[mySLComposerSheet dismissViewControllerAnimated:YES completion:nil];
break;
default:
break;
}
}];
Posting comment above as an answer:
Have you tried setting the completionHandler before presenting the View Controller?