share twitter detail throughout the app - ios

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/

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.

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

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];
}
}

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.

How to post UIImage on friends wall through Facebook using iOS

I'm using the social framework to attach text and an image to share on Facebook and twitter but the sharing is done on my wall. I need to add the option to post on a friend's wall.
My code as follows
“AttachmentTableViewController.h”
#import <UIKit/UIKit.h>
#interface SocialSharingViewController : UIViewController
- (IBAction)postToTwitter:(id)sender;
- (IBAction)postToFacebook:(id)sender;
#end
“AttachmentTableViewController.m”
#import <Social/Social.h>
- (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];
}
}
- (IBAction)postToFacebook:(id)sender {
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[controller setInitialText:#"First post from my iPhone app"];
[self presentViewController:controller animated:YES completion:Nil];
}
}
This code posts on my wall but I need to add the possibility to share on my friends' wall. Any help please.
Thanks a lot!

Resources