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

Using WKWebView does not work #15

Closed
nadinasovaiala opened this issue Nov 17, 2015 · 8 comments
Closed

Using WKWebView does not work #15

nadinasovaiala opened this issue Nov 17, 2015 · 8 comments

Comments

@nadinasovaiala
Copy link

Hi Adam, The connection does not succeed when using WKWebView instead of UIWebView. The log shows "Disconnected" right after "Start" is called (no matter how many times I try). I am using Swift 2.0 and I tried on simulator and also on multiple devices. The transport method is WebSockets (I also tried with Auto). Is this a known issue? Are you able to replicate it? Thanks.

@adamhartford
Copy link
Owner

But UIWebView does work for you? No issues connecting with WKWebView that I know of. What version of iOS are you trying with?

@nadinasovaiala
Copy link
Author

Yes, UIWebView works fine. I tried using iOS 8.1 and 9.0

@adamhartford
Copy link
Owner

Are you using cookies for authentication by any chance?

@nadinasovaiala
Copy link
Author

No cookies, no headers

@adamhartford
Copy link
Owner

When you're running the app, use the Safari developer tools to watch the JavaScript console for your app. Do you see any errors when you try to connect?

@nadinasovaiala
Copy link
Author

I do get an error: [Error] XMLHttpRequest cannot load http://<url_here>/signalr/signalr/negotiate?clientProtocol=1.5&connectionData=%5B%7B%22name%22%3A%22hub%22%7D%5D&_=1447840328641. Origin null is not allowed by Access-Control-Allow-Origin.

@adamhartford
Copy link
Owner

Did you enable CORS on your server? Usually that looks like this:

public class Startup
{
    public void Configuration(IAppBuilder app)
    {
        app.UseCors (CorsOptions.AllowAll); // <-- This is the important part.
        app.MapSignalR ();
    }
}

UIWebView does not respect CORS, but WKWebView does. I should probably mention this in the README. It would explain why UIWebView works for you, but WKWebView does not.

@nadinasovaiala
Copy link
Author

You were right, it worked after updating the server. Thanks!

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