Reputation: 155
I am working on an Android + Phonegap + jQuery-Mobile app and i am planning on using Pusher for implementing push notifications. I was testing the Pusher service using the getting started project from this link : http://blog.pusher.com/pusher-on-phonegap-for-android/
Project details :
Android API target 15
Cordova 2.3.0
Pusher JavaScript Library v1.12.7
jQuery Mobile 1.3.0 (final release)
I copied all the necessary .java files and .js files to my project. Here is how i instantiate the pusher connection :
var CONFIG = {
PUSHER: {
APP_KEY: 'my-key'
}
};
// Connect
var pusher = new Pusher(CONFIG.PUSHER.APP_KEY);
pusher.connection.bind('state_change', connectionStateChange);
function connectionStateChange(state) {
$('#connectionStatus').html(state.current);
}
// Subscribe
var channel = pusher.subscribe('my-channel');
channel.bind('pusher:subscription_succeeded', subscriptionSucceeded);
function subscriptionSucceeded() {
$('#subscriptionStatus').html('succeeded');
}
channel.bind('my-event', handleMyEvent);
function handleMyEvent( data ) {
// window.plugins.statusBarNotification.notify("You have a notification", data.message);
$('#pusher-data').append('<pre>'+data.message+'</pre>');
}
But once i run my project, i am unable to see any log entries regarding the Pusher connection but rather i see something like this in Logcat :
03-01 23:11:23.997: E/Web Console(3631): Uncaught TypeError: Object function (url) {
03-01 23:11:23.997: E/Web Console(3631): // get a new websocket object from factory (check com.strumsoft.websocket.WebSocketFactory.java)
03-01 23:11:23.997: E/Web Console(3631): this.socket = WebSocketFactory.getInstance(url);
03-01 23:11:23.997: E/Web Console(3631): // store in registry
03-01 23:11:23.997: E/Web Console(3631): if(this.socket) {
03-01 23:11:23.997: E/Web Console(3631): WebSocket.store[this.socket.getId()] = this;
03-01 23:11:23.997: E/Web Console(3631): } else {
03-01 23:11:23.997: E/Web Console(3631): throw new Error('Websocket instantiation failed! Address might be wrong.');
03-01 23:11:23.997: E/Web Console(3631): }
03-01 23:11:23.997: E/Web Console(3631): } has no method '__addTask' at file:///android_asset/www/pusher.js:1288
I am really stuck up at this point. Any help would be greatly appreciated.
Upvotes: 0
Views: 887
Reputation: 15467
The preferred solution here would be to drop the use of the WebSocket Java wrapper and instead use our HTTP fallback.
The new beta version of the Pusher JavaScript library is available via http://js.pusher.com/2.0.0-pre/pusher.min.js
Over HTTPs: https://d3dy5gmtp8yhk7.cloudfront.net/2.0.0-pre/pusher.min.js
We need to do additional testing in PhoneGap but the HTTP fallback should be a much better solution.
Upvotes: 1