How do you get the "Add my app to the springboard" notification to pop-up in Mobile Safari? - ios

For some websites/webapps, using Mobile Safari on the website causes a pop-up to come up advising the user that they can add the site/app to their home screen. I tried to replicate it but I can't figure it out.
Is there a JS library to do this or is there a meta tag to add to my html?

Most of them use add to home screen from cubiq

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.

Issue with openning PDF in iOS 11.3 Using PWA

I've used Vuejs and Framework7 in my PWA. I want to open a remote PDF file in my PWA and also it's important to me that users be able to back to my PWA after opening PDF. I did this using :
window.open(pdf_url, "_blank");
And it works fine for iOS > 12 and after opening pdf file there is an "OK" button for closing pdf.
But for example in iOS 11.3 there is no button and user has to use home button to close PWA.
I tried to solve problem using iframe but I can show only first page of the pdf.
Is there any way to fix this issue?
You can resolve this issue by doing some tricks (for any device without back button):
if you use iframe, you can set height manualy with overflow scroll, and I think this will resolve issue (dependence of style or lib dependency, so that may be not work).
you can add back button to your navbar, or Toolbar to let user click on it to back to previous page. (I prefer this solution).
you can render pdf in popup nested of normal html page, and then you can customize popup component by handling back button, or handling close by dropback overlay.
I use second and third point in real project and its work fine...
This is sample close button code used in popup:
'<p>'+ i18nextHelper.i18next.t('Exit From PDF') +'</p>'
Note: You can also customize height page for pdf page only, and add normal button bellow it, or by add absolute positioning button above PDF, but I think if you use second or third point will be best.
Good luck.

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.

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

Web iPad app to be downloaded / short cut added to home screen from page - is that possible?

I am developing a web iPad app using Sencha Touch framework.
As it is a JS and Html5 framework It allows me to use cashing and work offline.
If I use the "+" button on iPad's Safari I can ad the icon/ shortcut to the home screen and make it behave as a native app (work without safari's address bar).
I was wandering would it be possible to create a button on the web page that would have the same functionality as the "+" button - so it allows users to add a web app shortcut to their ipad's home screens directly from the web page.
Is it possible? Can JS deal with it using apple's API?
Sorry, but this isn't possible. (JavaScript has no access to any special Apple API's - merely some additional events for touch handlers, etc.)
If it was, you can imagine that it would be trivial for any web site to automate this process (fake the user pressing the in-page "add" button) and hence add itself to the user's home screen without their permission.

Resources