Switching between apps with URL Schemes (iOS) - ios

I'm developing an iPhone app with Swift which acts on certain file types (.xml &.zip). I've added these filetypes to the project file as a UTI (Uniform Type Identifiers). When accessing these sorts of files, usually from my email, I press and hold the file and a menu pops up from below. I choose my app icon that says "Open in MyApp". Is there a way that I can return to the email which triggered this event from within the app?
I've done some research on this and found that URL Schemes are the best way for inter - app communication, but you cannot arbitrarily open an app just to open it.
https://developer.apple.com/library/mac/documentation/Miscellaneous/Reference/UTIRef/Introduction/Introduction.html
The vision I have in mind is sort of how Google apps communicate with each other. For example, when opening a link from gmail, it switches apps to chrome. When chrome loads, the page back navigator is in Chrome displays the text similar to "back to gmail"

In iOS 9 the system implements this automatically, as seen in this screenshot here.

Related

Open iOS application from universal links

I have implemented universal links in my application by uploading "apple-app-site-association" to my server and enabling "associated domains" in my project(by adding applinks). My app opens whenever I click on my server weblink from Safari browser.
1) Its not working on any other browser
2) I need to open my app from other apps as well, i.e. Instagram, Twitter etc.
How can I achieve the above scenarios using universal links. If not, is there any other way of achieving the same.
Not all apps will open universal links in you app. You can read a little more here:
"Pasting a Universal Link directly into the Safari URL field doesn’t cause the app to open automatically. If you do this, you will have to manually pull the website down so that a prompt will appear at the top asking you to open the respective app.
But, if you paste links in Facebook(app), Twitter(app), Mail(app) or even if you go to Facebook on Safari and then click on a universal link, the app opens directly.
Universal links will not works for all the apps in iOS. If you click on a universal link from any of the “BLACK LISTED” apps, it will not open the app. Go to this link to know more.
As in step one, for the first time you will have to manually pull down the website and click “open” to open the link using the respective app. The iOS will “remember” to open the app instead of opening the safari if the universal link with the registered domains are clicked."
https://medium.com/#abhimuralidharan/universal-links-in-ios-79c4ee038272
https://docs.branch.io/pages/deep-linking/universal-links/#appsbrowsers-that-support-universal-links

Opening file in an app from URL

I'm trying to create a link that, if clicked on a mobile device (ios), will open a PDF in a FileExplorer mobile app (or the App store if they don't have one installed). I've tried finding apps with their own URL scheme (similar to Facebook's "fb://" or YouTube's "youtube://"), but I'm not having any luck.
I've reviewed the content in the following pages and still have not found an answer:
iPhone apps: Can I open an app from a link in a website?
How to open ios app using url?
Opening an app from URL schema
There is the option to open the Files app at a specific location using the shareddocuments:// URL scheme, as described in this article.
There's no direct solution. Your best best is to let the user decide what to do with the PDF. Use a UIActivityViewController setup with the PDF. Then the user can choose. Typical options will be email, print, iBooks, Preview, other apps that handle PDFs, and as of iOS 11, the standard Files app.
You are not going to find URL schemes for "file explorer" apps in general. And there's little point to finding URL schemes to a few specific such apps. Any such apps the user may already have should appear in the activity view.

Sharing an image/link to my app in IOS

I'm trying to find out how I can add sharing support to my app using React Native. I've found documentation for displaying the action sheet from within my app but nothing on how I can add support for users to share images/links to my app. I'm not even sure what Apple calls this feature so it's possible I may not be searching with the right keywords.
e.g.
On #1 if you press the share button at the bottom middle of the safari app it will bring up a popup where you can choose an app e.g. Facebook, then if you press on Facebook it will open Facebook with a url to the page you want to share from safari where you can add a comment about the link. I want to replicate this behavior but within my own app. I want my app to be available to choose when I press the share button on the safari app which I will then open a popup window that displays the link the user wants to share allowing them to add a comment before posting the link. Is this possible with react native? I see that I have the option share with other apps (my fidelity app, sears shop your way, etc so It seems like you can have a non system app do this.
They are called Share extensions and they are part of the Extensibility features. They are system-wide Share Sheets. Not to be mistaken with Action Extensions.
Share extensions have colored icons.
Action extensions use monochromatic icons.
Anyway the links do not display UNTIL you have clicked the app in the share sheet.
Editor > Add Target > iOS > Application Extension > Share Extension
Configure the App Group for your app target.
On the Capabilities tab, turn on the App Groups switch and select the group you created. (if you want to enable code sharing between the extension and container app you can put the code in a framework and link to it)
Expand the group you created and you will see a storyboard file, an entitlements file, a view controller and a plist file under the Supporting Files group.
You can use the storyboard file to create a custom interface or do it programatically but Share extensions come with a default compose view that looks like the Facebook and Twitter views.

Open app through email without choosing from menu

I have a custom file type that needs to be opened within our app, but when I tap the file, a menu is presented asking if I want to open the file in Messages, Mail, Slack, Notes, and then our application. How can I get it so that the app opens automatically? Or at least get our app to the front of the list of possible applications.
you can't remove other apps from being able to open the UTI.
you can't influence the order of apps in the dialog
===
IF that is our own filetype, change the file's UTI ;)

iOS 9 Universal Links not launching the app from the same domain

I have setup my AASA JSON file to open the app when someone visits myDomain.com/ShowInTheApp/*
This works from Notes App, Email, Gmail App, Gmail web on safari and basically any other websites other myDomain.com .
When myDomain.com/chooseAppORweb.html contains a link to myDomain.com/ShowInTheApp/ , safari always opens it in the same tab, app wont get launched. I can tap and hold the link to show the context menu that contains an entry "Open In [My app name]" which will indeed launch my app. But not by single tapping on the link.
When I do the exact same steps from another domain, NOTmyDomain.com/chooseAppORweb.html always launches the app without issues.
Has anyone succeeded in launching the app consistently from the same domain using UL ?
Also, if there is an Apple's document that explains any of these behaviours, please share the link.
I'm not sure when Apple added this to their documentation, but it's explained on their Support Universal Links page, in the first note:
In iOS 9 and later, universal links let users open your app when they tap links to your website within WKWebView and UIWebView views and Safari pages, in addition to links that result in a call to openURL:, such as those that occur in Mail, Messages, and other apps.
When a user is browsing your website in Safari and they tap a universal link to a URL in the same domain as the current webpage, iOS respects the user’s most likely intent and opens the link in Safari. If the user taps a universal link to a URL in a different domain, iOS opens the link in your app.
For users who are running versions of iOS earlier than 9.0, tapping a universal link to your website opens the link in Safari.
(Emphasis added)
Essentially, once a user reaches a page hosted on your domain in Safari, any links they follow on your domain will be opened in Safari, even if they're defined as Universal Links by your app.
As st.derrick mentioned above, this is the in-place behavior for Universal links. If you have previously been taken to the App from the link, but then choose to be taken to the website when prompted with a long press, the functionality to open the App will break. You can remedy this by long-pressing again and choosing to open in-app. It's not an ideal solution, but it is the only way I've seen it be fixed. I hope this helps!

Resources