Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

How do I add an IWKHttpCookieStoreObserver to a HttpCookieStore?

$
0
0

I'm trying to add an observer to an HttpCookieStore connected to a WebsiteDataStore for a WKWebView. I can't figure out how to build an observer that i can pass to AddObserver on HttpCookieStore. I'm really just trying to have a class that will have the CookiesDidChangeInCookieStore called when cookies change so I can save them, but it looks like it is implemented as an extension method in the docs.

I tried to do this:

public class CookieObserver : IWKHttpCookieStoreObserver
{

}

public static class CookieObserverExtensions
{
    public static async void CookiesDidChangeInCookieStore(this IWKHttpCookieStoreObserver This, WKHttpCookieStore cookieStore)
    {
        var cookies = await cookieStore.GetAllCookiesAsync();

        Debug.WriteLine("Found " + cookies.Length + " cookies");

        foreach (var cookie in cookies)
        {
            Debug.WriteLine(cookie.Domain + " - " + cookie.Name + ":" + cookie.Value);
        }
    }
}

But I get a the error "CookieObserver" does not implement interface member INativeObject.Handle.

What is the proper way to create and assign an observer for HttpCookieStore?


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>