I implemented Safari View Controller in iOS app, but is there a way to send some data from javascript of opened site to main iOS app.
I am opening my web app in the Safari VC.
You cannot do this. from Apple Guideline and i quote.
The view controller includes Safari features such as Reader, AutoFill,
Fraudulent Website Detection, and content blocking. It shares cookies
and other website data with Safari. The user's activity and
interaction with SFSafariViewController are not visible to your app,
which cannot access AutoFill data, browsing history, or website data.
You do not need to secure data between your app and Safari
Related
If I have an iOS app, how can I open a browser view inside the app (upon the user tapping a button) which contains no cookies from any domains?
This means the browser view should not remember cookies from the previous time the user opened the browser, nor share cookies with the Safari app.
There are now three classes to do web views as far as I understand, SFSafariViewController, WKWebView and the dated UIWebView. Which of these allows what I want to achieve?
WKWebView is the way to go. Upon initialisation it won't contain any cookies from previous sessions. From the Apple documentation:
Each web view is given its own Web Content process until an implementation-defined process limit is reached; after that, web views with the same process pool end up sharing Web Content processes.
Furthermore, WKWebView is intended as a replacement for the older UIWebView.
SFSafariViewController shares cookies and other website data with Safari.
As per Apple documentation ,Support Universal Links , we can move control from Safari to App using Universal Links.
In my app, when user is in doing some actions in web pages, only for particular action I want to move control from Safari to my App. Then I want to do some action in App and then again want to move control to Safari's web page, from where I had moved control to App , with output data that got generated in App by using web service.
I know user can go back to Safari from App by clicking on breadcrumb button in the status bar. But I want to achieve this programatically.
How can I achieve this.
Just use openURL in your app to open the web page you want to return to in Safari. The Universal Link will not be in effect in this case, since you're in your app and iOS will correctly deduce you just want to open Safari.
configuring Universal Links does not require you to include the query part, which means you can still use it to pass data (in both ways)
You registered http://acme.com/foo/bar in your apple-app-side-association
You can use openURL to open http://acme.com/foo/bar?data=xxx and your webpage can process the data in the query part of the URL
Is there a way to send an iOS app user to a certain webpage in Safari and then have a user back in an app, after one has done some action on a webpage?
Yes.
From the Web, you have to link to an URL scheme registered to your App, for example, register your app with the "myownurlscheme", and you can start adding links and redirects in your Web, example:
myownurlscheme://goto/restaurant/drink&what=beer
https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/Inter-AppCommunication/Inter-AppCommunication.html
Beginning with iOS 9, there's now Universal Linking.
So when a user visits your site, iOS automatically pushes you to the App (and the App receives the full URL), if the users doesn't have the App, keeps seeing the Web version.
https://developer.apple.com/library/prerelease/ios/documentation/General/Conceptual/AppSearch/UniversalLinks.html#//apple_ref/doc/uid/TP40016308-CH12
Is there a way to not have this happen? I don't want to take my users to the safari browser before getting redirected to the App Store.
Right now if I send out an email link, it hits my server (for click tracking purposes), and then our server will redirect the to the app store. The problem is that this methodology will cause safari to pop open momentarily.
Is there a way to design it such that the user will not have safari opened and we can still track the click?
You need to do it in two different steps. First send a NSURLRequest to your server using NSURLConnection and separately open the AppStore URL.
Alternatively or in addition use the iTunes Referral Program for tracking.
The flow I am trying to do here is as follows:
user visits a page in my webapp with the chrome iOS app
user clicks a login link which starts a session and shows a link with an url scheme my iOS app can handle
user clicks that link and my iOS app opens up
my iOS app does it thing ( it authenticates the user )
when finished, I would like to be able to get the user back to the chrome iOS app on the same tab he started from. This tab is polling my server every x seconds to see if my iOS app has finished.
Is this possible? I can open up the chrome app easily just by using the googlechromes url scheme but this opens up a new tab. I need the user to land on the same tab
Similary for the safari app, I can get the same behaviour by using the https url scheme to open up safari.
Ok it seems it is not possible as explained here: Open safari in same tab from iPhone application
I guess it makes sense not allowing this, so other apps cannot manipulate your current open tabs.