Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UWP support #6

Open
dominik-weber opened this issue Jun 22, 2016 · 2 comments
Open

UWP support #6

dominik-weber opened this issue Jun 22, 2016 · 2 comments

Comments

@dominik-weber
Copy link

Have you thought about supporting Windows Universal platform? The code required should be fairly similar to the WP renderer.

@sunilyts
Copy link

Hi sean,

This "Cross-platform Cookie Access"" will support windows platform?

With Regards,
Sunil Rana

@sunilyts
Copy link

HI i got solution and it is working fine for Windows "UWP" application.
below in windows render code

public class CookieWebViewRenderer : Xamarin.Forms.Platform.UWP.WebViewRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs e)
{
base.OnElementChanged(e);

        if (e.OldElement == null)
        {
            Control.NavigationStarting += ControlOnNavigating;
            Control.NavigationCompleted += ControlOnNavigated;
        }
    }

    protected void ControlOnNavigated(object sender, Windows.UI.Xaml.Controls.WebViewNavigationCompletedEventArgs navigationEventArgs)
    {


        var filter = new HttpBaseProtocolFilter();
        HttpClient client = new HttpClient(filter);
        HttpCookieCollection httpCookieCollection = filter.CookieManager.GetCookies(navigationEventArgs.Uri);
        //httpCookieCollection.
        // Use this, while it comes from an instance, its shared across everything.
        var cookieCollection = new CookieCollection();
        foreach (var cookie in httpCookieCollection)
        {
            cookieCollection.Add(new Cookie
            {
                Domain = cookie.Domain,
                Name = cookie.Name,                    
                Value = cookie.Value,                    
                
            });
        }
        CookieWebView.OnNavigated(new CookieNavigatedEventArgs()
        {

            Cookies = cookieCollection,
            Url = navigationEventArgs.Uri.ToString()
        });
    }

    protected void ControlOnNavigating(object sender, Windows.UI.Xaml.Controls.WebViewNavigationStartingEventArgs navigatingEventArgs)
    {
        CookieWebView.OnNavigating(new CookieNavigationEventArgs()
        {
            Url = navigatingEventArgs.Uri.ToString()
        });
    }

    public CookieWebView CookieWebView
    {
        get { return Element as CookieWebView; }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants