Skip to content

Commit

Permalink
Merge pull request #138 from Switch168/master
Browse files Browse the repository at this point in the history
WebSocket hack loads iff iOS Cordova
  • Loading branch information
ibc committed May 10, 2016
2 parents 6a4bff3 + 92bdb98 commit 3d4ed10
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,12 @@ If you are using the plugin we would love to [heard back from you](WHO_USES_IT.m

Don't call plugin methods within WebSocket events (`onopen`, `onmessage`, etc). There is an issue in iOS Safari (see [issue #12](https://github.com/eface2face/cordova-plugin-iosrtc/issues/12)). Instead run a `setTimeout()` within the WebSocket event if you need to call plugin methods on it.

Or better, just load the provided [ios-websocket-hack.js](extra/ios-websocket-hack.js) script into your Cordova iOS app and you are done.
Or better yet, include the provided [ios-websocket-hack.js](extra/ios-websocket-hack.js) in your app and load into your `index.html` as follows:

```
<script src="cordova.js"></script>
<script src="ios-websocket-hack.min.js"></script>
```

#### HTML5 video API

Expand Down
3 changes: 3 additions & 0 deletions extra/ios-websocket-hack.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@


(function () {
// run on iOS Cordova only
if (!(window.cordova && window.cordova.platformId === 'ios')) return;

// Store a reference of the native WebSocket class.
var NativeWebSocket = window.WebSocket;

Expand Down

0 comments on commit 3d4ed10

Please sign in to comment.