Created
May 14, 2013 23:10
-
-
Save ricardoalcocer/5580452 to your computer and use it in GitHub Desktop.
ACS Push Notification from web page. Code credit goes to Juan José Ríos - @Digibix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> | |
<script type="text/javascript" src="http://sdk.cocoafish.com/js/cocoafish-1.2.min.js"></script> | |
</head> | |
<body> | |
<script> | |
var sdk = new Cocoafish('<APIKEY>'); // app key | |
var data = { | |
login: 'user_name', //acs administrator type user | |
password: 'password' //acs password (not recomended) | |
}; | |
sdk.sendRequest('/users/login.json', 'POST', data, callback); | |
function callback(data) { | |
if(data) { | |
if(data.meta) { | |
var meta = data.meta; | |
if(meta.status == 'ok' && meta.code == 200 && meta.method_name == 'loginUser') { | |
// alert('Login user successful!'); | |
} else { | |
alert('error'); | |
} | |
} | |
} | |
} | |
function fnot() { | |
var txt=document.all.tmsg.value; | |
var data = { | |
channel: '<channel_name>', | |
payload: {"sound": "default","alert": txt} | |
}; | |
sdk.sendRequest('push_notification/notify.json', 'POST', data, callback); | |
function callback(data) { | |
if(data) { | |
if(data.meta) { | |
var meta = data.meta; | |
if(meta.status == 'ok' && meta.code == 200 && meta.method_name == 'Notify') { | |
alert('DONE'); | |
} | |
} | |
} | |
} | |
} | |
</script> | |
<b>Enter text to send:</b><br> | |
<input type="text" name="tmsg" value="" maxlength=120 size="120"> | |
<input type="button" value="Send" onclick="fnot();"> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment