Is there a way to prevent Safari on iOS from clearing the cookies for a website on close? - ios

One of the users of my mobile web app is complaining that he has to log back into the app after every time he goes to use it after he turns his phone screen off. What's happening is Safari clears the cookies for the site when the screen goes off (or when you close safari out completely by double tapping the home button and sliding safari away). If you open safari back up though it will show the last screen you were on but you can't use any session data because it's all gone.
Is there a way to prevent this in safari?

If you don't add an expiry date to your cookie, Safari will add an expiry time of session.
Exmaple Here - developer.mozilla.org

Related

Is it possible app "restarts" when it is suspended?

Sometimes user moves to other app, i.e. to browser, and when returns to app, app do not show the latest screen, because it seems it has restarted. Is it possible? Users states it happens.

In iOS, is it possible open a url in safari, then go back to the app and reopen safari without pushing a new url?

I have a simple app that opens a link in Safari with UIApplication.shared.open. The user might navigate to any number of urls in the site, and then hit the Back arrow in the top left corner as return to the app. Is it possible to launch Safari again, but without a new url, and simply open the tab at the same url location where navigation stopped, prior to pressing the back button? The only way I know to open Safari is to push a url it, which means a user cannot resume using a site in Safari where they left off. I would appreciate any ideas on how to implement this feature.

Do apps like Twitter implement custom relaunching when opened from background?

I've noticed that when I go off an app like Snapchat, Twitter etc for a few seconds then go back on it, it opens from background as expected, on to the view controller I was last on. However, if I go off the app for more than a few minutes, when I tap on the app it loads the splash screen again and opens the home page.
I initially thought this was standard iOS behaviour, but when I installed my app onto my device I have noticed that even if I go off it for hours, when I come back onto it, the last view controller I was on is shown.
I have thought about checking how long the app was in background by saving times in NSUserDefaults, but don't actually know if this is the right way of going about achieving that kind of behaviour?
Thanks!

Performing a task through a website and going back to an iOS app

I'm developing an iOS 7+ app that I need to offer the option of navigating to a certain web page to let the users to fill in a form there, and after that to come back to the app's view where the user was.
Is it possible to programmatically open Safari with a given url? If it is, I suppose that then there is no way to automatically redirect the user to your app from there... right? Is then a UIWebView the only option? Is it possible to navigate back or dismiss the view with the UIWebView without the need of user interaction?
Thanks
You can open links in Safari as detailed in this post How to launch safari and open URL from iOS app
I don't believe you can set a 'callback' and have it return to your app on completion, as you have no control over the user once they have exited your app's sandbox.
Opening the link in UIWebView would provide control, as you can utilize the UIWebView callbacks.

Is it allowed to add a UITabBarItem that opens up Safari?

I want to add a UITabBarItem on the TabBar which when clicked opens up Safari instead of loading its corresponding tab. (Not UIWebView but the app goes to background and opens up Safari instead)
I already know how to do this, but I was wondering if this is allowed by Apple. I know they're OK with using the TabBarItem to trigger other actions such as opening a modal in the app, etc. However I am not sure if it's OK to open a safari.
I am just being cautious because I don't want it to get rejected for this and wait another week.
I don't see a reason why it shouldn't be allowed.
But: it could lead to confusion amongst your users, because they would most likely not expect that touching an item on the TabBar leads to an app switch. I would rather open a webView and offer the additional possibility to open the page in Safari.
There is no harm doing such and it is also allowed by Apple.
But, I would personally suggest to use UIWebView, over Safari navigation. Because it will create unhealthy user experience, where he/she requires to jump around to swith in-between Safari and App. Rather you can open the same link in UIWebView, which will kepp our user in app only.

Resources