Forum Xamarin.iOS
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

How do I add an IWKHttpCookieStoreObserver to a HttpCookieStore?

AustinGriggAustinGrigg USMember ✭✭

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?


  • Hey Austin.
    Did you ever solve this?
    If so, could you please share the solution with us?

Sign In or Register to comment.