Open Safari to the last tab that was opened - ios

Is it possible to open Safari from code that will reopen Safari with the last tab open? I've searched around and I can only find how to open Safari with a URL (not what I want) or open it to a blank page (also not what I want). Is it possible to reopen Safari in its last state?
e.g. someone is on Google on Safari. They then hide the app and launch my app. I'd like my app to open Safari and show Google - I don't want to use the delegate bundle passed in during activation as the website may be expired or dynamic and so I don't want to reload the page.
Thanks

Related

iOS PWA standalone: how to force opening in a new window

I have a PWA saved on the home screen, this opens up standardly without search bar nor the bottom buttons (share, tabs, etc..).
So every link gets opened inside the PWA, and that is expected.
I have a problem when showing pdfs as they normally open in Safari with the "share" button and all the bottom bar, but in the PWA they open up without bottom bar and without any share button.
So my idea is to open the PDF link (http://www.mywebsite.com/download/pdf/12345) in a new safari window,.
I tried putting target="_blank" on the PDF link but this did not solve the problem.
I also tried forcing the iOS behavior by opening the app in safari with safari://http://www.mywebsite.com/download/pdf/12345 but with no luck.
How do I open a New Safari window to a link?
OK, the ONLY working solution is to tell iOS you are going onto another domain.
PWA stays in your app frame ONLY if you stay in the same domain.
To open a link within your domain in an EXTERNAL window (or inside the PWA but with Safari standard controls) you have to send it to an external/different domain.
So the PWA is on https://www.mywebsite.com/ and you want to open a PDF with all Safari control buttons, you just create a SUB domain and point the link to it, like https://media.mywebsite.com/download/pdf/12345 at this point the PWA thinks you are on a different domain and does the correct rendering! 🎉
You can try to use window.open(url).
But, remember to put it in an element with onclick event attribute.
For example,
<button class='btn' onclick='window.open("https://www.google.com", "_blank");'>Open Google search</button>
Reference: window.open(url, '_blank'); not working on iMac/Safari
EDIT
You can set a scope in manifest.json to customize where to open an external link.
You can refer https://developers.google.com/web/fundamentals/web-app-manifest on the property scope.

iOS PWA special mailto link opens tab inside pwa browser. And stuck at blank tab

The mailto link was working as expected on previous versions of iOS. After updating to 12.2+ when opening default mail app using the mailto link the mail app works. But when coming back to the PWA, the application stuck on a blank white screen due to the iOS feature update to PWA (saving app state when switching apps)
Now i'm stuck with a blank screen even after swipe close the app.
I'm using the following code to lunch the mail app
send mail
I have tried all other options of targets, only the _blank target opens the default mail app. Other targets are not working as mentioned in this stack overflow answer.
Here is the screenshot of how the blank screen looks after coming back from mail app
have anyone faced similar issue?
I've tried the following solution in my own PWA and it works great (iOS 12.3.1, iPhone 7+)!
On your PWA page, you create the link as following:
<a onclick="sendFeedback()">Send Mail</a>
And you define this function:
function sendFeedback(e)
{
window.location.href = "mailto:example#example.com";
}
Once clicked, it launches the default mail app. When you go back to your PWA, you will land on the page where the link is located. There won't be a blank screen.

Trigger iOS universal link on browser redirect

I have universal links set up for a native app. E.g. when I tap a link to my website (say https://my.website.com) from an email app, the native app opens automatically. But when I browse some website, which redirects me to https://my.website.com in safari, all I get is a bar at the top, suggesting me to open in the native app. Moreover that bar is only visible if I drag down a bit, so it's not visible immediately. How can it be fixed? how can I make the app auto-open in such case?

How can I reset iOS 9 Universal Linking settings?

While testing universal links on my iOS 9 app, I accidentally tapped "mywebsite.com >" (top right corner). This made the app navigate to the website again. Now I can't seem to make universal linking work again. Seems like iOS has remembered my preference that I would like to see links opened in Safari as opposed to my app.
Has anyone run into this? Is there a way to reset this?
You can long-press on a universal link and it will give you an action sheet with an "Open in 'AppName'" option. Once you select that option it will default to opening the links in your app again.
You need pull down in opened page in safari from email, etc to see button "Open" (this button is system in safari). If tap "open" after
I accidentally tapped "mywebsite.com >"
universal link will work again under the old scheme.The result of this action preserves.
example
#dan is right, long-pressing the hyperlink will give you the option to open with your app again through universal link.
If you have an Apple Smart Banner in place, you can also click on its 'Open' hyperlink to active universal links on your app again.
For a Branch.io deep link the long tap (at least in GMail) does not work and also you can't pull down from safari, it brings you to the App Store immediately.
Instead, copy the link to Notes and then do the long press.
More info here: https://blog.branch.io/3-steps-to-troubleshoot-ios-9-and-ios-10-universal-links/

apple-mobile-web-app-capable doesn't open in safari

Noticed this in iOS8 today and I'm not sure if this has always been the case or if it is something that's come in with iOS8.
My company's website, if I save the page to my home screen, adds the icon as expected. But when you open it, it doesn't open in safari, it opens as it's own standalone app. For example, double tapping the home button will show this app open, operating independently of safari.
I gather it has something to do with the apple-mobile-web-app-capable meta tag. Can anybody confirm if this is new or if it has always been the case. Also, some insight as to whether the above meta tag is actually responsible for this. Documentation specifies the default is to open in Safari.
Yes, the apple-mobile-web-app-capable meta tag will do this and it has been around for several iOS versions.
See more here:
https://developer.apple.com/library/ios/documentation/AppleApplications/Reference/SafariWebContent/ConfiguringWebApplications/ConfiguringWebApplications.html#//apple_ref/doc/uid/TP40002051-CH3-SW2

Resources