Share image to Facebook (IOS app/Objective-C) - ios

pls help. I have not made an update to my app in over a year. Now I tried to add a button to share an image to Facebook. But the button will not don't work. In general, nothing happens after pressing on it. How can I fix it ?
Best regards,
Ivan (yeah yeah my english is poor)
-(void)shareWithFacebook{
NSLog(#"fb");
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
{
SLComposeViewController *fbSheet = [SLComposeViewController
composeViewControllerForServiceType:SLServiceTypeFacebook];
[fbSheet setInitialText:#"Document from Docement scanner"];
[fbSheet addImage:self.savedImage];
[self presentViewController:fbSheet animated:YES completion:nil];
}
}

Related

SLComposeViewController setInitialText not working on Twitter in iOS 11

I am creating a SLComposeViewController of type SLServiceTypeTwitter and I'm adding an url and text to it. However, the text is not shown, only the url.
Does anybody know why SLComposeViewController's setInitialText is not working on Twitter in iOS 11?
Here is a snippet of my code:
SLComposeViewController *twPostSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
[twPostSheet setInitialText:copy];
[twPostSheet addURL:[NSURL URLWithString:url]];
UIViewController *controller = RCTPresentedViewController();
twPostSheet.completionHandler = ^(SLComposeViewControllerResult result) {
// Shared with success
};
[controller presentViewController:twPostSheet animated:YES completion:nil];
This behaviour is intended. You should use Twitter iOS kit. With it you can share Tweets with text, URLs, photos and video. The same goes for Facebook share.

Unable to set initialtext in ios9 in native facebook share dialog

I am trying to set initial text to SLComposeViewController in iOS 9 , but it is displaying blank in dialog.
Here is my code.
SLComposeViewController *composeController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
NSString *initialText = #"Tesing text issue.";
if (initialText != Nil)
{
[composeController setInitialText:initialText];
}
dispatch_async(dispatch_get_main_queue(), ^
{
//show progress hud here
[self presentViewController:composeController animated:YES completion:nil];
});
I have aslo check this in another sharing app, they have also same issue. Can anybody have any workaround here?
Facebook has deprecated the api to set initial text programmatically while sharing. Below are the references:
https://developers.facebook.com/docs/apps/review/prefill
https://developers.facebook.com/docs/sharing/ios
Hope this helps.
You can set the initial text using graph API and custom share dialogue.
https://developers.facebook.com/docs/sharing/opengraph/ios#custom

How can I set fixed text for twitter posts?

I would like the twitter posts from my app to be fixed so that users cannot edit them before posting. How can I achieve this? Below is the basic code I am using to post normal editable text.
-(void)tweetResults {
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter])
{
SLComposeViewController *tweetSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
[tweetSheet setInitialText:#"Tweeting from my own app! :)"];
[self presentViewController:tweetSheet animated:YES completion:nil];
CCLOG(#"it's working okay");
}
}
Your best bet would be either subclassing SLComposeViewController, or creating your own custom class using lower level API access to the users Twitter account.

Detecting if Twitter account is set up on iOS 7

I've been following some tutorials on integrating Twitter into my application. Here is what I have so far:
- (IBAction)postToTweeter:(id)sender {
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) {
SLComposeViewController *tweetSheet = [SLComposeViewController
composeViewControllerForServiceType:SLServiceTypeTwitter];
[tweetSheet setInitialText:#"this is a test"];
[self presentViewController:tweetSheet animated:YES completion:nil];
}
}
My storyboard has a button, and when a user taps that button, this is the code that gets called. However, this only works whenever they have a Twitter account setup on their iPhone first. How can I handle the case where a user has not set up a twitter account yet, and show them an alert instructing them to add a Twitter account?
SLComposeViewController has a very handy built-in mechanism, whereby it will offer to send the user to Settings if you instantiate a ComposeViewController when the user hasn't set up / logged into the social-media service in question. To test this, all you need to do is remove the conditional so your code looks like this:
- (IBAction)postToTweeter:(id)sender {
SLComposeViewController *tweetSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
[tweetSheet setInitialText:#"this is a test"];
[self presentViewController:tweetSheet animated:YES completion:nil];
}
...and you'll find that iOS will automatically pop up an alert which will take the user through to Settings.
Note that I've found that this doesn't tend to work in the simulator, so it's best to test on a device.

share twitter detail throughout the app

I am implement twitter share in my IOS app. I ma using MGTwitterEngine. If I implement login and sharing from the same controller it is working but if I separate out login and share functionality in 2 controllers it is not working.
SA_OAuthTwitterEngine *_engine;
_engine returning blank.
If you're targeting iOS6 or newer, you'll be better use iOS social API:
- (IBAction)postToTwitter:(id)sender {
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter])
{
SLComposeViewController *tweetSheet = [SLComposeViewController
composeViewControllerForServiceType:SLServiceTypeTwitter];
[tweetSheet setInitialText:#"Great fun to learn iOS programming at appcoda.com!"];
[self presentViewController:tweetSheet animated:YES completion:nil];
}
}
For more info see here: http://www.appcoda.com/ios-programming-101-integrate-twitter-and-facebook-sharing-in-ios-6/

Resources