iOS: Run code only after it's been added to the home screen - ios

I'd like know if there's away to run a bit of code only after it's been installed to the home screen on iOS. This is for internal use only so I don't need it to work on other platforms. Just iOS.
Basically, I want to add a few custom icons to iOS devices that do specific things. One will open a PDF and that's the one I'm having a hard time working with.
So, here's the flow...
User goes to URL on their iOS based device, there is nothing to see here, but then they add the URL to their home screen. Once they click on the home screen icon, the page opens and redirects to the a PDF that lives online. The pdf can live online since they will always have wifi.
Any suggestions?

Related

How to return form the web(iOS) back to the app?

I am using an online builder for my app(ApperyDotIo, JQM framework). My application works fine with one exception. I have an in-app link to my website. The link in the iOS app, the link takes me to the page but since the iPhone doesn't have a "back" button I can't go back to the app. Looks like you have to close the app and then reopen it to get back into the app.
I tried to set the link to not open in the same window and vice versa.
Any easy work around?
Links and back buttons in Android apps work fine.
Thank you
You can consider using the inAppBrowser: https://docs.appery.io/docs/cordova-jquerymobile-inappbrowser
It will allow you to open the website in the child window of the application (with the "close" button) or in the native browser, without opening the website as application page.

Checking through safari whether the PWA is added to homescreen

So I have coded myself a way to display the pop-up encouragement to add the app to home screen on iOS for PWA. OK, user does it, when he clicks through the app all is good. However, when he returns to the website, I want to check whether the app has already been added to the home screen. I have found only this so far: https://stackoverflow.com/a/39986409/6470918
This states that basically it is impossible. Did this situation change during the last two years?
Thank you in advance,
Grzegorz

iOS how to launch another app as a redirection

An app is currently outdated and to avoid the users to use its incorrect results, we decided to suspend this app until we have the algorithm updated.
We have tried the following:
Titanium.Platform.openURL("http://example.net");
This will open the web browser to a URL of our selection. However, in iOS there is a little "go back" link in the top left hand corner, which will lead the user back to the broken app. We want to avoid this. Basically, we want the app to be inactive all the time - whenever the user attempt to activate it, the designated page behind the URL should be shown.
How can we do this?
Why not just temporarily replace the main page of you app with a full screen web view showing the desired URL? The user stays in your app but still can only access the web page you direct them to.

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

iPad Home Screen App refreshes on every open

I'm writing a web app for the iPad using HTML5 and SenchaTouch. The app uses cache manifest to function offline. Once it has been added in the home screen and opened without Safari, it will refresh itself every time it is opened, even if just navigating to the home screen and back. The desired behavior is to leave the app, do something else, and then come back to the app with everything untouched.
An example of a similar app that displays the same (undesired) behavior can be found here: http://ignitedmediadesign.com/WebApp/index.html
I've read that using a cache manifest should have solved this problem on iPhone ( http://www.stevesouders.com/blog/2011/06/28/lack-of-caching-for-iphone-home-screen-apps/ ), but doesn't seem to have done the trick for either iPhone or iPad.
Is there another way to fix this? Is there some secret to cache manifest files that stops this that I may have missed?
I'm under the impression this is simply the nature of the "home screen" web apps that operate outside of normal Safari. I have an app that operates just fine in Safari with some minimal state saving, but the blasted non-Safari version refreshes every time. EDIT: Even the showcased O’Reilly example that uses a cache manifest reloads every time when added to the home screen.
You may want to look into creating "routes" (URL fragments) that point to a controller/action pair. Look into the MVC PhoneGap example (If not using PhoneGap, you can scroll past all of that stuff and implement your own data model and store). Also see this Sencha Touch MVC tutorial.
Also, most of the rendered sencha touch components seem to maintain state between changes of the active item. For example. I have a main TabPanel that contains all sub panels. When switching between tabs on the main TabPanel's TabBar, each sub panel maintains its rendering, unless I've set a listener or controller action to do otherwise.
Hope this helps.

Resources