This thread was migrated from an old forum. It may contain information that are no longer valid. For further assistance, please post a new question or open a support ticket from the Customer Support portal.
Scenario: I have an iOS (iPhone/iPad) app which includes a browser widget which embeds a 3D model from an external web site in my app which is used as a navigation UX to explore items in the models. I'm using HandleRequest events to interact with the model, which is one of several reasons I don't want to open the model web site in Safari outside my app.
Question:
(1) How can I persist cookies from the 3rd party web site in my browser widget on iOS so the user doesn't have to log into the 3rd party site each time they launch my app? Ref to code sample appreciated; I've seen a number of recommendations I don't know how to implement and can't find supporting docs.
(2) Where can I find docs and samples of WKWebView browser widget? I looked on kony and searched google without much luck.
More Context:
I'm on Kony Visualizer Ent 8.0.5.v201711172005
3rd party site sets a couple cookies including a token which I can access via kony.net.getCookies()
UIWebView: Docs and some forums suggest cookies are persisted by default. Kony Browser widget on iOS (set as UI Web View) does not.
WKWebView: I'm happy to switch to WKWebView, though I do have an unrelated issue in which the browser doesn't render content in simulator (it works on device).
I'm looking at both NFI and FFI solutions to manually set cookies, but I'm hoping there is a easier solution to what seems like a common requirement.
For iPhone specifically, you don't have to do anything. The important thing is the cookie should be present in the device. From the URL you can send a cookie back to the device. Depending on the cookie domain name, and the browser widget URL hostname it would flow as part of the request. They both should have same domain names.
Please find the below documentation link explaining the cookie in browser widget.
Thanks for responding to my inquiry... couple clarifying questions...
Using kony.net.getCookies(), I can see the cookies on the iOS device. After login, several cookies are updated and two session level cookies are added. After closing and re-opening the app, I'm back to the original state. On all desktop browsers, the same non-session level cookies are persisted and the user is auto-logged in. Tokens or something does expire each month and the user has to re-login. Monthly login is ok, but I can't have the user manually logging in every time they open the app. Ideally, I'd like the app to login in with a service account. Persisting cookies seems like a quick, acceptable usr experience solution until I add auto-login later.
I've attached a screen shot of all cookies in the before/after login state.
Important context: The web site I'm loading in the browser detects that the page is being loaded by an unsupported browser. This does not have any negative effect on the content rendering in the widget, but this may somehow be related to the cookies not being persisted. Just a speculation.
This is a hugely important issue for me and I suspect a common issue for others who want to deeply integrate external web site experiences into their app. I have already written several FFI components in ObjC to get more control needed to support AWS and iOS integration scenarios, but i'm really hoping I can enable persisting cookies using the browser widget and not a custom widget I have to code up in ObjC.
More context... Apologies in advance for being verbose, but I'm hoping more context will help
On iOS, Both Safari and Chrome cache cookies that pre-populate the username and password, so the user has to click sign-in, but the credentials are cached and re-pop'd in the browser form each time they visit the site.
I think there are three approaches with increasing levels of user experience improvements, but I'm struggling with the implementation.
1) minimum viable solution: cache the username and password in the browser widget for parity with the iOS browser experience. Not ideal, but it'll suffice for now.
2) better: after successful login, store the token on the device or in cloud, and then upon re-launching the app inject the token back into the cookies or pass the token to the 3rd party site when loading the page in the browser widget. I have seen discussions about this approach, but I can't find sample code or documentation. And I haven't had any success trying to do this with requestURLConfig on the iOS client or from AppFabric. I'm happy to pursue this option, but I'd need sample code or more explicit docs.
3) best: this is just an evolution of option #2 that adds an explicit call to 3rd party site to collect the token each time the user launches the app. I already know how to get the token. Just don't know how to use it to automate login.