Reputation: 5722
I'm trying to load a web Url from inside my app and I need to set a cookie. At the moment I'm using:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:_myURL]];
but this approach results in my app switching to Mobile Safari which is quite ugly as the user loses the focus on my app. Loading the web page inside the new WKUIWebView (and using NSHttpCookieStorage) is not an option as apparently those cookie would be sandboxed. Is there any other way I can create a cookie which is visible from Mobile Safari?
Upvotes: 1
Views: 409
Reputation: 3107
As of iOS9 you can use the SFSafariViewController which does share cookies with Safari mobile. You can use this in conjunction with custom URL schemes or universal links to "communicate" between them.
Upvotes: 1
Reputation: 34945
No you can't. Applications having access to Safari's cookies would be a security concern.
If you have control over the site that you are opening then you could do something with a one-time login code in the url as a request parameter.
Upvotes: 1