Skip to content

Instantly share code, notes, and snippets.

View cikichen's full-sized avatar
🎯
Focusing

Simon cikichen

🎯
Focusing
View GitHub Profile
//===================================================================================================
//取得與設定APP內部的cookie
//===================================================================================================
- (void)setCookie:(NSString *)key withValue:(NSString *)value {
NSArray *keys = [NSArray arrayWithObjects:
NSHTTPCookieDomain,
NSHTTPCookieExpires,
NSHTTPCookieName,
NSHTTPCookiePath,
NSHTTPCookieValue, nil];
@cikichen
cikichen / WKWebViewCookie.m
Created February 15, 2019 03:27 — forked from markcerqueira/WKWebViewCookie.m
Getting cookies into a WKWebView
// API reference: https://developer.apple.com/reference/webkit/webpolicydelegate/1536273-webview?language=objc
// Adapted from the Swift implementation: http://stackoverflow.com/a/32196541
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction
decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {
if (![self requiresCookie:navigationAction]) {
decisionHandler(WKNavigationActionPolicyAllow);
return;
}