osx - Cocoa: WKWebView local storage -
i trying local storage working wkwebview.
i have created small demo project. mac app shows window buttons , wkwebview.
the 3 buttons show 3 variations of same page: sticky notes webkit demo:
remote loads sticky notes webkit demo page in
wkwebview.local loads same content copy in app bundle.
safari loads sticky notes webkit demo in browser.
the first 2 not work; latter does.
what should happen should appear 1 default sticky note, , enabled new note button add new sticky notes.
in remote , local variations, no note appears, , new note button disabled, indicating couldn't access local storage.
i'm hoping i'm doing wrong in loading wkwebview, it's possible isn't supported.
here's code remote variation:
wkwebviewconfiguration *config = [wkwebviewconfiguration new]; config.websitedatastore = [wkwebsitedatastore defaultdatastore]; self.webview = [[wkwebview alloc] initwithframe:self.container.frame configuration:config]; self.webview.autoresizingmask = nsviewwidthsizable | nsviewheightsizable; [self.container addsubview:self.webview]; nsurl *url = [nsurl urlwithstring:@"https://webkit.org/demos/sticky-notes/"]; nsurlrequest *request = [nsurlrequest requestwithurl:url]; [self.webview loadrequest:request]; any assistance appreciated!
update: turned out while local storage mechanism using work in safari , not wkwebview, easier expected: use localstorage javascript variable.
Comments
Post a Comment