HeimgardTechnologiesAS / cordova-plugin-advanced-websocket

MIT License
27 stars 18 forks source link

iOS crash when ping interval is defined #5

Closed boedy closed 6 years ago

boedy commented 6 years ago

I was not able to get this plugin working on iOS (havn't tried android). It crashes when I defined pingInterval. If I leave it the success callback fires, but I don't receive any events.

var accessToken = "abcdefghiklmnopqrstuvwxyz";
var wsOptions = {
    url: "wss://echo.websocket.org",
    timeout: 5000,
    pingInterval: 10000,
    headers: {"Authorization": "Bearer " + accessToken},
    acceptAllCerts: false
}

CordovaWebsocketPlugin.wsConnect(wsOptions,
                function(recvEvent) {
                    console.log("Received callback from WebSocket: "+recvEvent["callbackMethod"]);
                },
                function(success) {
                    console.log("Connected to WebSocket with id: " + success.webSocketId);
                },
                function(error) {
                    console.log("Failed to connect to WebSocket: "+
                                "code: "+error["code"]+
                                ", reason: "+error["reason"]+
                                ", exception: "+error["exception"]);
                }
            );

Device console reports:

+[NSTimer scheduledTimerWithTimeInterval:repeats:block:]: unrecognized selector sent to class 0x379d8ed4

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSTimer scheduledTimerWithTimeInterval:repeats:block:]: unrecognized selector sent to class 0x379d8ed4'
    *** First throw call stack:
    (0x2104791b 0x207e2e17 0x2104d1d1 0x2104aee1 0x20f76238 0x114cff 0x118175 0x20bb5823 0x20bb580f 0x20bc3ba9 0x21009b6d 0x21008067 0x20f57229 0x20f57015 0x22547ac9 0x2562b189 0x71ef3 0x20bff873)
boedy commented 6 years ago

This is the problem: https://stackoverflow.com/questions/40521799/trivial-nstimer-scheduledtimerwithtimeintervalrepeatsblock-unrecognized

Your plugin is only compatible on iOS10 or greater

chax commented 6 years ago

@boedy thanks for the report. I will try to fix it next week.

chax commented 6 years ago

@boedy it should be fixed now. I published new version of the plugin v1.1.2