Mobile PWA open previous seen page - progressive-web-apps

I added a web app manifest to my web app and now I can add my web app to my iPhone home screen. I also added google workbox and implemented some caching strategies.
Unfortunately when closing my web app and open it again, it always shows the start screen.
I would like to jump back to the last seen screen automatically (call the last opened url) instead of always jumping to the starting page.
Is there a way to achieve this?
Thanks in advance!

One possible way
-- Subscribe to your router
this.router.events.subscribe(event => {
if (event instanceof NavigationEnd) {
// call a method here to save the current
// page to a local storage variable
}
});
When your app opens, if there is a value in local storage, go to that page

Related

How to open a flutter web app link in Messenger in external browser?

When trying to open my Flutter web app from a link in the Messenger app on iOS, the web app is opening in Messenger's built-in browser. I do however need it to open in an external browser (i.e. Safari, Chrome, etc.), and I've tried several options to achieve this. Unfortunately, I've had no luck yet.
The Challenge
The web app is opening in Messenger's built-in browser, restricting panning in the app's map. Thus, I need to open the app in an external browser. The issue is shown in the gif below.
What I've tried
Most of the online solutions I've found regarding this issue refers to the url_launcher package with the option mode set to LaunchMode.externalApplication. I've tried adding a button for launching the app's url in an external browser based on this option, but this just causes the app to reload in the current in-app browser window (see gif below, in which I am tapping the _launchInExternalBrowser button several times).
A button tap runs the following function:
_launchInExternalBrowser() async {
if (!await launchUrl(Uri.base,
mode: LaunchMode.externalApplication)) {
setState(() {
_launchInExternalBrowserStatus = "Could not launch ${Uri.base}";
});
} else {
setState(() {
_launchInExternalBrowserStatus = "Could launch ${Uri.base}";
});
}
}
Any insight into how this issue can be solved would be highly appreciated!

How can I have a separate setup process and home page in Flutter?

I am currently building an app that has a first page with two buttons: 'New users -->" and "Existing users -->". The goal is for new users to click their button and go through a setup process that ends with their home page that is saved when the app is closed. The next time a user opens the app, once they click their existing users button, I want the app to open to the home page the setup process ends at. How do I achieving this? Any help would be appreciated!
You can use GoRouter (from flutter team) plugin for handling this scenario and navigation.
https://pub.dev/packages/go_router
While initialising the router, you can provide redirect where you can handle if user should be navigated to the setup screen or home screen.
Use database / shared preference / secure storage to store whether the setup process was completed and what data was saved.
Now if you are using any framework like GetX or something you can easily navigate to the desired pages or you can use Navigator.to.... if not using a framework.
you can use something like
bool isSetupDone = // get from storage
the use this Boolean value to either alert, show/hide button/ popup message accordingly as per your usecase.

Open link in browser or open app

I have made an iphone app. The app calls the webpage and displays the content. Server side coding is in php. The problem is I have several links in the webpage. When I click on the link in the webpage it opens the entire page and I am no longer able to go back to where I was.
I tried iframe but not all the website support it like google, facebook. What I am looking is someway to open the link in browser or launch the another app, like the app of facebook. I have quite thoroughly searched for the solution without much luck.
Any pointers would be greatly appreciated.
Thanks
To implement navigation for UIWebView you can do the following: create two buttons, one for going forward in history and one for going back. And here is the code for that buttons you must include:
//For going forward
if (yourWebView.canGoForward)
{
yourWebView.goForward();
}
//For going back
if (yourWebView.canGoBack)
{
yourWebView.goBack();
}

Possible to open iPhone Safari and target a specific window?

I have an app that uses OAuth to authenticate, which means the user must be directed to the website to authorize the application. I prefer to make it obvious to the user that they are using a standard browser to authorize at the original site rather than just using a web view to show the content within my app. However, every time they are directed to Safari (via openURL), it launches a new Safari window and once Safari has 8 windows open, it simply fails to work at all.
I'm wondering if there is an equivalen to the "target" attribute of an anchor tag in html which would allow me to cause all openURL calls from my application to open in the same window.
There is other functionality that I can expose via the web application, creating a hybrid app between native iphone functionality and web app functionality in Safari, but if I have to launch a new window every time I switch between the app and Safari, it becomes unworkable. The Youtube app is obviously able to return the user to the previous page after showing a video, but that might well be a custom plugin in Safari for iphone. Also, while returning to the previous page is somewhat useful, sending them to a new URL in the existing window really opens up a lot of possiblities.
I'm pretty sure there is no way to pass a target parameter to openURL:.
What I noticed about Safari is that it won't open another tab if the page you are opening with openURL: is/was already open in Safari. It just reloads that page. This might sound trivial and not helpful but perhaps you could use it to your advantage if you can make your web application only use one page. Different views or states could be expressed with #anchor tags.
An example is http://m.flickr.com. Notice their URL structure? It goes http://m.flickr.com/#/home, http://m.flickr.com/#/explore/interesting/, http://m.flickr.com/#/search and so on. All of these are different web pages to the user but to Safari it's all the same page.
I found iOS 6.0.1 Safari will open the same tab with a simple hashtag, without the slashes. So with the above example http://m.flickr.com, openURL to http://m.flickr.com#someinfo opens to the same tab.
In your webpage, use window.location.hash to return the params. In the above example it will return #someinfo.

Tell if WebApp launched via URL or link on iPhone home screen

Is there a way of telling whether my Web Application has been launched from a button on the user's iPhone home screen? I want to display a "add this WebApp to your home screen" prompt if the user has accessed the WebApp via safari by typing in a URL.
window.navigator.standalone
True if you have launched from the Home Screen. False if in the Safari browser.
Documented here:
https://developer.apple.com/library/content/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html
It works with OS 2.1 and up.
In Safari, the scrollY will start at a negative value if inside Safari, and at 0 if running as an application.
Likely the viewport will change as well (if it does, this is a more reliable method)
jQTouch detects this (try the demo). It's open source, so you should be able to find out how.
If I remember correctly there's a thing in the server log that shows what the user's previous page was. So the only way I can think of is if the user was on a previous page display the "add" thing, and if they didn't don't