Giter Club home page Giter Club logo

wkwebviewdemo's Introduction

WKWebViewDemo

Update: It turned out that while the local storage mechanism I was using does work in Safari and not WKWebView, it was easier than expected: just use the localStorage JavaScript variable.

I'm leaving this project as a useful testbed for WKWebView usage.


I am trying to get local storage working with WKWebView.

This project is a Mac app that shows a window with some buttons and a WKWebView.

The three buttons show three variations of the same page: the Sticky Notes WebKit demo:

The first two do not work; the latter does.

What should happen is it should appear with one default sticky note, and an enabled New Note button will add new sticky notes.

In the Remote and Local variations, no note appears, and the New Note button is disabled, indicating that it couldn't access the local storage.

I'm hoping that I'm just doing something wrong in loading the WKWebView, but it's possible that this just isn't supported.

Here's my code for the 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 much appreciated! No longer needed.

wkwebviewdemo's People

Contributors

dejal avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.