How to launch Facebook with Button - objective-c

Hey friends
I created a button on my app called: "Find us on Facebook". Right now I ran into a situation where I need the button to launch the Facebook application. I could really use some help such as launching the facebook application, detecting if there is a facebook application, and all the sorts of stuff like that, thanks

Some googling shows that the facebook app apparently registers to receive urls with the fb:// scheme. So you can construct a fb:// url (like, say fb://notes or something) and then ask the UIApplication object if it can open the URL. If it says that it can, then open it.

there is a tutorial and sample app at https://github.com/facebook/facebook-ios-sdk
Basically you need to try to call fb://profile/yourpageid to load the FB app on your page.
The sample app shows you how to do this and fall back to loading in Safari if the app is not installed on the device.

Related

Disable Twitter Universal Deep Links

Update: It appears Twitter has fixed this issue. Clicking the authorize button now works! Thank you all for the responses.
I have a UIWebView that opens and directs to Twitters Oauth/Authorize webpage. The user signs in with there Twitter details and authenticates the use of our application with there Twitter account. This process worked perfect before the release of Twitter 6.37 iOS application. What happens now is when the WebView detects https://twitter.com/oauth/authorize?oauth_token instead of staying in the WebView it opens the native Twitter application and dies. If you uninstall the Twitter application everything works as usually it staying within the WebView. How can I prevent this from happening? I want to stay within my UIWebView and not automatically open deep links. I have been reading about the new URL deep link changes in iOS 9, but not sure of how to stop them from my application to other native applications. Thanks for any help!
As a workaround, in twitter authentication screen we can use the Go button on iOS typing keypad instead of using the sign in button on web view until twitter fixes.
Please refer the attached screenshot link for clarity.
Screenshot for the workaround
I ran into this issue as well and figured out it was because my authorize endpoint was set to https://twitter.com/oauth/authorize?oauth_token="+oauthToken (I believe this was in the original documentation). If you add api as the subdomain: https://api.twitter.com/oauth/authorize?oauth_token="+oauthToken, it will no longer trigger the deep linking and load the twitter app.
My answer to this via a Xamarin question:
Unless Twitter removes/updates the apps section of "https://www.twitter.com/apple-app-site-association" to allow a bypass or a secondary oauth that is not in the apple-app-site-association file I do not see how you would do it. These files are signed and iOS handles them at an OS level.
I have not played around very much with the continueUserActivity delegate and the NSUserActivity object that is passed to apps launched from UNI links, but I do not see a way for the launched app (i.e. Twitter) to return control to the original app, and at that point the oauth call-chain would be broken anyway....
Unique. Unlike custom URL schemes, universal links can’t be claimed by other apps, because they use standard HTTP or HTTPS links to your website.
Secure. When users install your app, iOS checks a file that you’ve uploaded to your web server to make sure that your website allows your app to open URLs on its behalf. Only you can create and upload this file, so the association of your website with your app is secure.
Via: https://developer.apple.com/library/prerelease/ios/documentation/General/Conceptual/AppSearch/UniversalLinks.html
I would report as an issue (bug?) to Twitter's Dev forum: https://twittercommunity.com

How to pass Login With Google Process in Cocoa WebView

I am developing a cocoa app for Mac OSX. It's a basic browser application and I use webview component.
In the page I want to connect, there is standard Login with Google Account button in order to login with my existing Google Account. When I clicked on this button nothing happens.
The same functionality works properly when I visited the same page by using Safari or any other browser but there is no reaction on webview component.
I've checked the action behind the Google's login button and here is the JS code.
onclick="return Dialog.Login.loginWithGoogle(false, 'https://www.mywebsite.com/-/oauth2callback', 'https://www.mywebsite.com/')"
As a part of the standard oauth process the process also has many redirections after this URL is called and normally should be completed at my site's login screen as expected. However, webview doesn't handle this.
Please note that the web site I am trying to connect in my webview is not belong to me and I have no control on it.
I checked many solutions on the web for 2 days but nothing helped.
Any help/hint will be appreciated.

How to do FB feed share post without leaving my hybrid app?

I am making mobile app using Sencha touch which will be bundled as native app and installed on devices. In my app on certain pages I want to add "share" functionality which is supposed to post some data to user's feed. While testing on browser I can to do that by opening a window with FB sharing url like "https://m.facebook.com/dialog/feed" or "https://m.facebook.com/sharer.php" and passing all related params as explained in https://developers.facebook.com/docs/reference/dialogs/feed/
But when this app is bundled and I share with this, user is moved to browser and cannot return to app because redirect_uri cannot point to app which is why I wanted to open this dialog within my app, probably in an iFrame. This is also not possible because these dialogs are not allowed to be embedded in iframe by META tags and in order to surpass it I have to do user login which again is another dialog which I cannot open in my app's iFrame.
I also looked at sample sencha app http://blooming-day-7830.herokuapp.com/ but it also takes user to separate login page instead of opening in-app dialog.
So my questions is how does hybrid apps connect with FB without moving out user to browser?
if you decide to use PhoneGap you can try the following two options. You will have to check for the iOS version before you switch your Phonegap call to. . .
Option 1 : for iOS before 6.0
Phonegap has a pretty nifty ChildBrowser plugin that you can use to load the FB share page without leaving the app for iOS 5.0 and below.
Option 2 : for iOS 6.0+
Facebook Share functionality has now been added to iOS. So all you have to do, is call a custom plugin class that you create, and call the standard FB share code using a basic Phonegap plugin call. You won't leave the app, the ChildBrowser doesn't have to show up, instead, you'll get the stock iOS-FB share sheet that will show up, you can add pictures, text, and so on, and post to facebook.

Bare bones Facebook integration demo app

So I just started looking into integrating FB into my app and whipped up this little test app. I wanted to have a bare bones app without all of the bs that's in the Hackbook demo app. Basically, it's overly complicated for what I want.
The problem is that something I'm doing isn't working. My app tries to authenticate with FB, but doesn't return auth tokens. Something else that I noticed is that...
If I have the facebook app installed... it switches to it, shows a white loading screen for a second, then dismisses it and pops back to my app.
If the facebook app isn't installed... it will open in safari and actually show the app approval window, let me login and then it pops back to my app.
Both ways fail with getting and storing the auth tokens however.
What the heck am I doing wrong? Would someone mind seeing if this code works for them?
Full source here: Deleted.
Thanks for looking.
It definitely sounds like you don't have your app registered in the Facebook developer portal.
https://developers.facebook.com/apps
Looks like Facebook just updated their SDK which now includes some simplified example apps. Much better than just hackbook.

Launching Facebook and Twitter application from other iOS app

Hey guys,
I am still continuing to build my iPhone project and I am having trouble with launching the facebook application. First of all, I am assuming every SDK Xcode developer knows that the Facebook application doesn't have the facebook or twitter app in the simulation. Since I have a facebook page and a twitter account about my company, I can't seem to test to launch my facebook page from the facebook application or my twitter page from the twitter application because they are not there in the iOS Simulator. So I was wondering how can I open my facebook and twitter page from the facebook and twitter application if they are not there? I don't want to use a Facebook or Twitter URL, then load it into a UIWebView, I want to open the Facebook and Twitter application to launch after the click of a button in my project, then the project will close and open either Facebook or Twitter application (the ones from the app store), so hopefully someone know how they can help me step by step or if they have a code that knows how to run the facebook or twitter application and sorry if my english is not clear enough, but hopefully you can help me or have a better solution to help solve my problem, thanks
I believe the facebook app listens to URI's like fb://, so I would suggest googling around for that.
Look here for example: http://wiki.akosma.com/IPhone_URL_Schemes#Facebook