我正在使用framework.realtime.co创建一个网站。它在网络上运行得很完美,但是当我将mi web编译为带有phonegap的应用程序时,该应用程序运行完美但连接实时无法正常工作。
在网络版上我有msj"已连接"但是在带有phonegap的编译版本中,它什么也没说。
这是html
<div id="status">
Loading...
</div>
这是代码js
loadOrtcFactory(IbtRealTimeSJType, function (factory, error) {
if (error != null) {
//////console.log("Factory error: " + error.message);
} else {
client = factory.createClient();
client.setClusterUrl('https://ortc-developers-useast1.realtime.co/server/ssl/2.1');
client.onConnected = function(c) {
document.getElementById('status').innerHTML = "connected";
// send("New hello world");
c.subscribe('channelAlerta', true, elem_received);
}
client.onDisconnected = function() {
document.getElementById('status').innerHTML = "disconnected";
}
client.onReconnecting = function() {
document.getElementById('status').innerHTML = "reconnected ...";
}
client.connect(appkey, token);
}
});
答案 0 :(得分:0)
您需要使用websocket PhoneGap插件。检查示例 https://github.com/realtime-framework/Messaging/tree/master/PhoneGap