Coding a simple SHARED Button for Facebook - ios

Which of the 2 ways am I supposed to use to create a simple share button for Facebook in my game app?
1) import Social Framework into project and then put in the following code...
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[controller setInitialText:#"High score is %i"];
[self presentViewController:controller animated:YES completion:Nil];
}
2) Add Facebook SDK into your project, get a Facebook App ID by signing up to Facebook's developer program, then add App ID into .plist file, link FBSDKShareKit.framework into project and then use the code provided by Facebook (and there's a LOT of it).
The 1st way of doing it works perfectly fine. Is it a MUST for me to do it the 2nd way? If I do it the first way, would I get in trouble with Facebook or would Apple reject my app? Also, if I do it the first way does it mean I can't use the Facebook "f" logo for the Facebook SHARE button?

If you're planning on sharing OpenGraph Stories within your game I would go with the Facebook SDK. According to Facebook's official docs:
"iOS 6+ includes a native share sheet that lets people post status updates, photos, videos and links to Facebook and includes support for setting the audience for the post and tagging the post with a location. You cannot share Open Graph Stories with the share sheet. The Facebook SDK supports the use of this native controller.
While you can use the iOS native view controller API (share sheet) directly, there are several reasons to use the native iOS Share dialog provided by the Facebook SDK. Using the native Share dialog provides a quick way to test that people have signed into Facebook on their iOS 6+ devices"
If you need more information to decide, I suggest you take a look at Sharing on iOS

Related

Adding Facebook as a Share button for iOS app

I don't understand in order to create a Facebook share button is it a MUST to download their SDK, and get a Facebook App ID, then link App ID to .plist file and then link FBSDKShareKit.framework to project OR can I just use the social.framework and link that to project and use the following code...
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[controller setInitialText:#"high score is %i"];
[self presentViewController:controller animated:YES completion:Nil];
}
Doing it this way with social framework and the above code works fine. Or is it a MUST to add the Facebook SDK and get a App ID with a Facebook developer account and all that?
If I do it the social.framework way instead of using the Facebook SDK and Facebook App-ID would my app get rejected and would I have a problem with Facebook company?
It isn't a must to do it the SDK way, but it is recommended. Also your app won't be rejected for that, I guess.
The SDK way offers you much more functionalities regarding the Social framework. By using it and linking with an App ID you could track all the Insights regarding the activity of your users with FB, request permission to get some data from their FB profiles and link it among your other apps and maybe a FB page, FB login...

SLComposeViewController won't set initialText for SLServiceTypeFacebook

It seems as a bug in Social framework, it won't set the initial text for Facebook service type. This is my implementation using Swift:
let view = SLComposeViewController(forServiceType: SLServiceTypeFacebook)
if view.setInitialText("Some text") {
NSLog("Success")
} else {
NSLog("Failure")
}
view.addURL(NSURL(string: "https://google.ro"))
self.presentViewController(view, animated: true, completion: nil)
What it works:
The URL shows up for both, Facebook, and Twitter
The initialText works correctly just for Twitter
What is doesn't work:
The initialText won't show up for Facebook, even though the code above outputs "Success"
Update 2
It seems like Facebook really doesn't want developers to set the initial text of a message when Sharing as that it's impossible even with their SDK. In the app I was implementing I've chosen screenshots from the app (uploaded as images) for letting the user share their progress on Facebook.
Update
The solution is to use the Facebook SDK for iOS, that feature of Social framework is not supported by Facebook anymore.
Not a bug, Facebook doesn't allow it anymore.
Use of the iOS share sheet is subject to Facebook Platform Policy, including section 2.3 which states that apps may not pre-fill. In the context of the share sheet, this means apps may not pre-fill the share sheet's initialText field with content that wasn't entered by people earlier in their use of the app.
Facebook dose't allow to pre fill message anymore.
For more info here
Saying that, if you use native Facebook sdk it won't solve your problem, because Facebook will not publish your app.
So as written on Facebook guidelines, the only solutions that you have are:
Populate the user message parameter with content that the user manually entered earlier in your app's flow.
Your app’s composer can include a call-to-action that disappears when people start to write a post. For example, Facebook's composer uses grey scale text to ask “What's on your mind?” that disappears when people start to write.
I think it is an iOs 8.3 bug.
Before I updated to that version it was working correctly. :-(

iOS App and Posting to FaceBook

In my app, I would like to provide a facebook icon so my users can post to their wall. I have read ALOT about Facebook and the Facebook SDK, but I am hoping some Facebookers out there can give me some ideas on the best approach.
I have built a test app that logs in to facebook, but then I saw another app that brings me to the settings to configure facebook.
SO, what is the best way to do this in an app? Here are some questions:
1) Should I provide the login from my app, or is it better to use the built in native settings?
2) If the settings are better, is there an example of how I bring up the dialog? Do I use SLComposeViewController?
3) Do I ONLY need the Graph API?
I apologize if these questions are silly, but I have seen sooo many different ways, and many are pre 2012, so I do not want to do anything that is old. If I follow the Facebook docs, I do not see anything about the native iOS settings dialog.
Any help is greatly appreciated!!!!
If you are going to post only text or image than better way is using SLComposeViewController. Why? No need to register app on developer.facebook.com. Native login, and easy to create post.
Example to do it:
SLComposeViewController *controllerSLC = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[controllerSLC setInitialText:#"My post"];
[controllerSLC addURL:[NSURL URLWithString:#"http://www.example.com"]];
[controllerSLC addImage:[UIImage imageNamed:#"img.jpg"]];
[self presentViewController:controllerSLC animated:YES completion:nil];
If all you are looking to achieve is post to the user's wall, I would recommend using the SLComposeViewController. This abstracts all the work in logging into Facebook and implementing the GraphAPI. A previous post answered this here: Tutorial for SLComposeViewController sharing
If you want more control over the Facebook integration, i.e. Read the User's Timeline, View/Change User Settings, etc. you will have to install the Facebook SDK and register your application with Facebook. This is more labor intensive, but the extra control and access to data may be what you need. The SDK can be access here as well as some demos and example code: https://developers.facebook.com/docs/ios

Creating share buttons in iOS app ( twitter facebook...)

I was wondering what is a good way to create share buttons in iOS, and by share buttons I mean these 3 kinds of buttons:
1- Follow me on Twitter
2- Like a page on Facebook
3- Send a mail (Optional)
I have heard about sharekit but I am interested in just creating these 3 buttons that will be found on the back of the page of the app.
You can use something like:
NSString *launchUrl = #"http://twitter.com/intent/user?screen_name=USER NAME";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: launchUrl]];
which will open Mobile Safari and let you follow that user. You may be required to log in.
I guess there is a similar URL for Facebook.
To send a mail from within your app, use the MessageUI Framework.
Posting data to social services is much more complicated than just setting up a button. You must register your application, choose user, authenticate, then communicate via the internet.
ShareKit does most of that for you.
You may not just 'create share button' and have it share data to fb or twitter.
Posting to those service is complicated because you'll have to create Apps on those social networks as well as handle the oauth handshake the occurs which allows your app to share on behalf of the user. The Socialize SDK (www.getsocialize.com) is the fastest way to get Facebook/Twitter authentication without coding it yourself. Sample code below:
Socialize* socialize = [[Socialize alloc] initWithDelegate:self];
[self.socialize createShareForEntityWithKey:#"http://www.url.com" medium:SocializeShareMediumFacebook text:#"Check this out!"];
You could use ShareKit 2.0
https://github.com/ShareKit/ShareKit
I believe it supports sharing on most common social networks.

iOS: Adding a Facebook Like button to a native iPhone app

I would like to know whether it is possible to add a Facebook Like button to a native iPhone app. In the app, the user browses a business directory or deals. When they tap on an item to view the details, it would be nice to have a Facebook Like button that can be used to post the item to the user's Facebook page.
Facebook writes: "Currently, the Like button is only available in mobile web apps".
My app is a native app and not a web app, so therefore I assume it's not possible. However, I do assume that it is possible to mix native UI components on a screen along with web components and therefore it might be possible to implement the Like button, although I am not sure how you pass data from the native portion to the web portion.
If the only solution is a hack, then I won't implement it because at some point the hack will fail when Facebook alters their API.
read around SO a little, you get many leads. Here's one:
Like button in iOS application
And a comment points to github.com/brow/FacebookLikeView
It has same caveats, but it seems there aren't any magic solutions.
There are these blogposts as well:
http://angelolloqui.blogspot.com/2010/11/facebook-like-button-on-ios.html
http://petersteinberger.com/2010/06/add-facebook-like-button-with-facebook-connect-iphone-sdk/
But not sure you get a native UIButton. Maybe you can open a webview in the background and emulate a click on it...
GL, update if you have some findings,
Oded.
Now you can use the FBlike button using the following code but it need to download latest sdk and it is the beta version :(
Here is the code:
[FBSettings enableBetaFeature:FBBetaFeaturesLikeButton];
[FBSettings enablePlatformCompatibility:NO];
FBLikeControl *like = [[FBLikeControl alloc] init];
like.objectID = #"http://shareitexampleapp.parseapp.com/photo1/";
like.likeControlHorizontalAlignment=FBLikeControlHorizontalAlignmentRight;
like.likeControlStyle=FBLikeControlStyleBoxCount;
[self.view addSubview like];
It looks like Facebook finally decided to allow this, more directly, via the Open Graph API.
See documentation here
Check this out, FB just made it possible through their SDK. Only for testing and ios for now
https://developers.facebook.com/docs/ios/like-button/

Resources