How to Change "via iOS" on native Facebook sharing in IOS6 - ios

Hi i am using following code to share message using IOS6 native lib
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
{
SLComposeViewController *mySLComposerSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[mySLComposerSheet setInitialText:#"Good morning all"];
//[mySLComposerSheet addImage:[UIImage imageNamed:#"img1.png"]];
[mySLComposerSheet addURL:[NSURL URLWithString:#"http://www.google.com/"]];
[self.superViewController presentViewController:mySLComposerSheet animated:YES completion:nil];
[mySLComposerSheet setCompletionHandler:^(SLComposeViewControllerResult result) {
NSString *output = #"";
switch (result) {
case SLComposeViewControllerResultCancelled:
output = #"ACtionCancelled";
break;
case SLComposeViewControllerResultDone:
output = #"Post Successfull";
break;
default:
break;
}
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Facebook Message" message:output delegate:nil cancelButtonTitle:#"Ok" otherButtonTitles:nil];
[alert show];
}];
}
it is successfully posted But in my facebook it is showing via IOS but i want to display my application name. I followed all steps when i am creating app id on facebook developer zone
How to change IOS to my application name?
I also tried this code http://www.developers-life.com/facebook-compose-view.html

When using SLComposeViewController you cannot change the "via" name, it will always show "iOS" as the source.
You are required to use the Facebook iOS SDK and set up your own custom compose view instead of using the native SLComposeViewController.
UPDATE
Facebook's 3.5+ SDK offers a number of great solutions, such as the Share Dialog, which uses the native Facebook and open graph.

Related

About "SLComposeViewController" in iOS 11 beta

In my project, I always use SLComposeViewController to share contents with third-party apps, but now, when I update my iPhone to iOS 11 beta, this no longer works.
The SLComposeViewControllerCompletionHandler always callback SLComposeViewControllerResultCancelled.
Why is this?
I was having problems with regard to the SLComposer in iOS 11. But I just removed the line that checks and apparently the own SDK makes the validacoes to me internally.
Remove this line serves for any SLServiceType:
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
So, develop your logic. In my case:
SLComposeViewController *mySLComposerSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[mySLComposerSheet setInitialText:#"#myInitialTextIsHere"];
[mySLComposerSheet addURL:[NSURL URLWithString:strURL]];
[mySLComposerSheet setCompletionHandler:^(SLComposeViewControllerResult result) {
switch (result) {
case SLComposeViewControllerResultCancelled:
NSLog(#"Post Canceled");
break;
case SLComposeViewControllerResultDone:
NSLog(#"Post Sucessful");
break;
default:
break;
}
}];
[self presentViewController:mySLComposerSheet animated:YES completion:nil];
I hope I have helped!
iOS 11 removed access to 3rd party accounts (such as Facebook and Twitter) through the Settings App. I’m currently struggling with the same thing.
You now must integrate the functionality with the SDK from the 3rd party. Twitter has a migration page here about steps to take:-
https://dev.twitter.com/twitterkit/ios/migrate-social-framework
I’ve yet to find specific instructions about how to migrate other social networks, but it’s safe to say it will require their 3rd party SDK.
No more easy out-the-box social sharing :-(
For iOS 11 this line:
([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
is always returning NO
I replaced it with check if user has Facebook app installed with:
static NSString *const canOpenFacebookURL = #"fbauth2";
+ adding it to LSApplicationQueriesSchemes in plist
-(BOOL)isFacebookAppInstalled {
NSURLComponents *components = [[NSURLComponents alloc] init];
components.scheme = canOpenFacebookURL;
components.path = #"/";
return [[UIApplication sharedApplication]
canOpenURL:components.URL];
}
And then just call SLComposeViewController *composeVC = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
as usual, the same how Matheus Domingos described. But with this check at least you know that user has facebook app installed.

How do I post image and text to Twitter via Twitter native app?

How do I post image and text to Twitter via Twitter native app ?
Is there any Twitter api to tweet via native Twitter app in IOS programmatically ?
or , How can I post image using Social or Twitter framework via Twitter native app?
Thanks
Please Try this answer. I think this will help u
- (void)postToTwitter
{
SLComposeViewController *tweetSheet=[SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
// if([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter])
// {
SLComposeViewControllerCompletionHandler __block completionHandler=^(SLComposeViewControllerResult result){
[tweetSheet dismissViewControllerAnimated:YES completion:nil];
switch(result){
case SLComposeViewControllerResultCancelled:
default:
{
NSLog(#"Cancel");
}
break;
case SLComposeViewControllerResultDone:
{
NSLog(#"Post");
}
break;
}
};
[tweetSheet setInitialText:#"your text"];
[tweetSheet addImage:[UIImage imageNamed:#"imageToSend"]];
[tweetSheet setCompletionHandler:completionHandler];
[self presentViewController:tweetSheet animated:YES completion:nil];
//}
}
Hi for sharing information via iOS app it is possible to use native share screen.
Using this code you going to share image via different social media.
UIImage *picture = [UIImage imageNamed:#"picture"];
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:#[picture] applicationActivities:nil];

Facebook posting

here is what I did
Created an app on facebook
installed the FB SDK with all the requirements
logged in the user via a login button
now I am trying to post with the code provided here from this threat
How to Post to Facebook on iOS 6 in Objective-C using ACAccountStore class
But nothing happens. Am I missing a step?
This is the code I am using
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) //check if Facebook Account is linked
{
mySLComposerSheet = [[SLComposeViewController alloc] init]; //initiate the Social Controller
mySLComposerSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook]; //Tell him with what social plattform to use it, e.g. facebook or twitter
[mySLComposerSheet setInitialText:[NSString stringWithFormat:#"Test",mySLComposerSheet.serviceType]]; //the message you want to post
[mySLComposerSheet addImage:yourimage]; //an image you could post
//for more instance methodes, go here:https://developer.apple.com/library/ios/#documentation/NetworkingInternet/Reference/SLComposeViewController_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40012205
[self presentViewController:mySLComposerSheet animated:YES completion:nil];
}
[mySLComposerSheet setCompletionHandler:^(SLComposeViewControllerResult result) {
NSString *output;
switch (result) {
case SLComposeViewControllerResultCancelled:
output = #"Action Cancelled";
break;
case SLComposeViewControllerResultDone:
output = #"Post Successfull";
break;
default:
break;
} //check if everything worked properly. Give out a message on the state.
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Facebook" message:output delegate:nil cancelButtonTitle:#"Ok" otherButtonTitles:nil];
[alert show];
}];
Your setInitialText method is incorrect.
If you use stringWithFormat to post the serviceType, you need to add it to the method with "%#", otherwise there isn't anything there to say it to appear.
In short, just change :
[mySLComposerSheet setInitialText:[NSString stringWithFormat:#"Test",mySLComposerSheet.serviceType]];
to :
[mySLComposerSheet setInitialText:[NSString stringWithFormat:#"Test %#",mySLComposerSheet.serviceType]];

Tweet a link from iOS app

I am creating a program in xCode that basically lets you post some something to your twitter. Everything works except that i am trying to figure a way to post a hypertext that will lead to say google.
Forexample i want the words wwww.google.com to lead to google when i click it..Any help is appreciated. Thanks
This is the code
-(void)tweetTapped{
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter])
{
SLComposeViewController *tweetSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
[tweetSheet setInitialText:#"Post to Twitter :) www.google.com"];
[self presentViewController:tweetSheet animated:YES completion:nil];
}
else
{
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:#"Sorry"
message:#"You can't send a tweet right now, make sureyour device has an internet connection and you haveat least one Twitter account setup"
delegate:self
cancelButtonTitle:#"OK"
otherButtonTitles:nil];
[alertView show];
}
}
You can't use hypertext in a tweet, but if you include a URL it should be automatically linked for you by Twitter. Twitter will generally use a URL shortener too. So just use a format like this:
NSString *tweet = #"This is a link to http://google.com";

iOS - Integrating Facebook framework

In my iOS app, I successfully integrated latest facebook framework.
Its working fine if "facebook" app is not on my iphone. If the app is not on my iphone, during authentication, its opening the browser and authenticating properly.
But if the facebook app is there on my iphone, after authentication and when returning to my app, its crashing with following error:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SBJsonParser errorTrace]: unrecognized selector sent to instance 0x2d9f60'
I have seen the samples provided by facebook and implemented the same in my app. Can some one point out me what might be the issue?
This is a bit of a stab in the dark but I think you might be calling the method errorTrace on an instance of SBJsonParser :)
What's probably happening is you're calling errorTrace on something that you have released early. Go through the code path triggered when facebook reopens your app and find a call to errorTrace. Set a breakpoint just before it and have a look around to see what's wrong.
If you want only share something in iOS 6.0 so you use social and account framework and do the job by iPhone internal login using following code
-(void)facebook_Share_in_IOS6.0{
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) //check if Facebook Account is linked
{
mySLComposerSheet = [[SLComposeViewController alloc] init]; //initiate the Social Controller
mySLComposerSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook]; //Tell him with what social plattform to use it, e.g. facebook or twitter
[mySLComposerSheet setInitialText:[NSString stringWithFormat:#"Test",mySLComposerSheet.serviceType]]; //the message you want to post
// [mySLComposerSheet addImage:yourimage];
[self presentViewController:mySLComposerSheet animated:YES completion:nil];
}else{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Attention" message:#"First Set your facebook account. To post your answer to facebook" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
}
[mySLComposerSheet setCompletionHandler:^(SLComposeViewControllerResult result) {
NSString *output;
switch (result) {
case SLComposeViewControllerResultCancelled:
output = #"Action Cancelled";
break;
case SLComposeViewControllerResultDone:
output = #"Post Successfull";
break;
default:
break;
} //check if everything worked properly. Give out a message on the state.
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Facebook" message:output delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
}];
}

Resources