Skip to content

Instantly share code, notes, and snippets.

@chucre
Created April 5, 2011 13:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chucre/903612 to your computer and use it in GitHub Desktop.
Save chucre/903612 to your computer and use it in GitHub Desktop.
xmpp plugin for phonegap use
onMessage = function() {
var options = {
to:'outrousuario@jabber.org',
subject:'teste',
body:'teste'
}
window.plugins.xmpp.send(
options,
function(success) {
alert("send success")
}, function(fail) {
alert("send failed");
});
window.plugins.xmpp.onMessage(
function(success) {
alert("mensage inbound: "+JSON.stringify(success));
}, function(fail) {
alert("onMessage failed: " + fail);
});
}
login = function() {
var options = {
user:'usuario',
password:'senha'
}
var result = window.plugins.xmpp.login(
options,
function(success) {
alert("login success: " + success);
onMessage();
}, function(fail) {
alert("login failed: " + fail);
});
}
connect = function(){
var options = {
host:'jabber.org',
host:'jabber.org',
port:5222
}
var result = window.plugins.xmpp.connect(
options,
function(success) {
alert("connect success: " + success);
login();
}, function(fail) {
alert("connect failed: " + fail);
});
}
document.addEventListener("deviceready", connect, true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment