FBSessionLoginBehaviorWithNoFallbackToWebView opens safari if no app is installed - ios

I want to log the user into my app with Facebook using (in this order) these methods:
The account stored in settings (via the Accounts Framework)
Switching to the Facebook App
Displaying my own UIWebView inside the app (and sending the requests
manually)
If one method doesn't work, I want to fallback to the next.
The problem I'm having is that
[self.fbsession openWithBehavior:FBSessionLoginBehaviorForcingWebView
completionHandler:
opens Safari or shows a popup that I can't customise.
I absolutely need to follow this order because I use a webview for other social networks (ie Twitter, LinkedIn and GooglePlus).
Is there any way to manually open the Facebook App for the Oauth flow ?

To manually check if the Facebook app is installed you can use:
[[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:#"fb://requests"]]

Related

App not opened programmatically?

I installed Meeseva app on my device. When I try to open it programmatically it's not opening.
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:#"Meeseva App://location?id=1"]]) {
NSString *mystr=[[NSString alloc] initWithFormat:#"Meeseva App://location?id=1"];
NSURL *myurl=[[NSURL alloc] initWithString:mystr];
[[UIApplication sharedApplication] openURL:myurl];
}
When I opened fb, twitter, google+ and etc... all are opening successfully.
Can any solve this this issue?
App link is
https://itunes.apple.com/in/app/meeseva-app/id1121539928?mt=8
Is there any another way to open installed app programatically?
If your app can receive specially formatted URLs, you should register the corresponding URL schemes with the system. Apps often use custom URL schemes to vend services to other apps.
Hence "Meeseva" app might not have created a custom url for their app. So you can't do anything for it.
As mentioned above the apps which want to provide support for url schema then they have to create a custom URL schemes.
You need to find out what the correct URL scheme of the Meeseva App is. Meeseva App:// does not seem to be a valid URL scheme as it has a space in the middle.
For example the Google Maps URL scheme is comgooglemaps://, not Google Maps://
Usually developers make their URL scheme public in their documentation. However this is a feature that needs to be implemented and apps don't support this "out of the box". If the developer did not implement this, the app can't be opened via link.
Alternatively it is possible that the app reacts on "universal links". That means if there is a website for the app, iOS might ask you whether to open that website in the app or in Safari. In that case you could simply link to the website and let the user decide how the link should be opened. However, again, this needs to be implemented by the developer. If the app does not support universal links either, there's no way for you to open the app at all.

Flipping Safari and back to iOS app

I am trying to build an iOS app that can do single sign on using Safari. For example, I would like my app to go to https://example.com and then get some token from there and then switch back to the iOS app with that information for me to use in the app.
Currently, I tried using URL Schemes but if from within the app I try to
[[UIApplication sharedApplication] openURL:[NSURLvURLWithString:#"DevTest://example.com"]];
it is not going away from my app. It is not flipping to safari, but if I use https://example.com as the URLWithString, it flips to Safari, but I don't know on how to do the callback from Safari.
Thanks for your help!
You need to create a link on your website example.com that will start with DevTest://, then when user taps on that link in Safari your app will be started. Don't forget to register "DevTest://" URL scheme in info.plist of your app and implement appDelegate methods for URL launching, see here:
https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/Inter-AppCommunication/Inter-AppCommunication.html

URL shemes for apps

I wanted to open Facebook and Twitter apps from my app. I find very simple way like:
NSURL *url = [NSURL URLWithString:#"fb://profile"];
[[UIApplication sharedApplication] openURL:url];
And there are many others url for open different page of Facebook. How can I check if Facebook app exist on iPhone? What happens if the application is not install on device? Now I try to use this method on iOS Simulator but nothing happened. It's bug of iOS Simulator? Only tomorrow I will have chance to check on device.
You can check if a URL would likely open ahead of time using the canOpenURL method of UIApplication.
http://developer.apple.com/library/ios/DOCUMENTATION/UIKit/Reference/UIApplication_Class/Reference/Reference.html#//apple_ref/occ/instm/UIApplication/canOpenURL:
Also! You can pass values for the facebook page you'd like. This Stack Overflow includes a link to a wiki with all the variations:
Launching Facebook and Twitter application from other iOS app
If you know the URL scheme that the other app is using (e.g. fb:// for the Facebook app), you can first ask whether your UIApplication object can open such URLs in the first place, with canOpenURL:. You can use this, for instance, to decide whether to display a link at all, or whether to direct the user to Safari (with a normal web URL) instead.
As third-party apps cannot be installed on the Simulator as far as I know, the only way to test compatibility with them is on an actual device.

Is it possible to open a link into Safari from inside Websheet.app

I'd like to know if it is possible, on the iPhone, to open a link into Safari from inside the Websheet app which is displayed when one tries to access a captive network.
Any client-side solution would do the trick (custom protocol, javascript, whatever).
The scenario would be as follow:
the user joins the captive network
the Websheet pops in, and the user can authenticate
After that, the user is redirected to a custom URL, but in Safari
Thanks a lot
You can open any link in Mobile Safari from inside your application. Simply do this
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: launchUrl]
launchUrl is the url (in string format) you want to open in safari.

Is it possible to deep link to a specific page or location in the Facebook mobile app on iOS?

Is it possible to include a link inside my mobile app that opens the native Facebook app to a specific page, event, post, or other location?
Thanks,
Ryan
fb://profile – Open Facebook app to the user’s profile
fb://friends – Open Facebook app to the friends list
fb://notifications – Open Facebook app to the notifications list (NOTE: there appears to be a bug with this URL. The Notifications page opens. However, it’s not possible to navigate to anywhere else in the Facebook app)
fb://feed – Open Facebook app to the News Feed
fb://events – Open Facebook app to the Events page
fb://requests – Open Facebook app to the Requests list
fb://notes- Open Facebook app to the Notes page
fb://albums – - Open Facebook app to Photo Albums list
E.g.
fb://post/(postId)
Then call like this:
NSURL *url = [NSURL URLWithString:#"fb://<insert function here>"];
[[UIApplication sharedApplication] openURL:url];
Source with LOTS more examples: http://wiki.akosma.com/IPhone_URL_Schemes#Facebook

Resources