jpush-phonegap-plugin/example/index.html

167 lines
6.8 KiB
HTML
Raw Normal View History

2014-01-21 14:15:14 +08:00
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Phonegap Sample App</title>
<link href="css/jquery.mobile-1.1.1.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery.mobile-1.1.1.js"></script>
<script type="text/javascript" src="cordova.js"></script>
2014-06-10 14:14:02 +08:00
<script type="text/javascript">
var onDeviceReady = function(){
2014-07-10 18:09:06 +08:00
console.log("JPushPlugin:Device ready!")
2014-06-12 11:02:33 +08:00
initiateUI();
2014-06-12 14:39:46 +08:00
}
2014-06-10 14:14:02 +08:00
var onTagsWithAlias = function(event){
2014-06-05 16:36:54 +08:00
try{
2014-06-12 11:02:33 +08:00
console.log("onTagsWithAlias");
2014-06-10 14:14:02 +08:00
var result="result code:"+event.resultCode+" ";
2014-06-12 11:02:33 +08:00
result+="tags:"+event.tags+" ";
result+="alias:"+event.alias+" ";
2014-06-10 14:14:02 +08:00
$("#tagAliasResult").html(result);
2014-06-05 16:36:54 +08:00
}
catch(exception){
console.log(exception)
}
}
2015-01-27 18:19:16 +08:00
var onOpenNotification = function(event){
try{
var alert = event.alert;
var extras = event.extras;
console.log(alert);
2015-01-27 18:31:05 +08:00
//console.log(extras);
2015-01-27 18:19:16 +08:00
}
catch(exeption){
console.log(exception)
}
}
2014-06-05 16:36:54 +08:00
var onGetRegistradionID = function(data) {
try{
2014-07-10 18:09:06 +08:00
console.log("JPushPlugin:registrationID is "+data)
2014-06-12 11:02:33 +08:00
2014-06-10 14:14:02 +08:00
$("#registrationid").html(data);
2014-06-05 16:36:54 +08:00
}
catch(exception){
2014-06-10 14:14:02 +08:00
console.log(exception);
2014-06-05 16:36:54 +08:00
}
}
2014-06-10 14:14:02 +08:00
var initiateUI = function(){
2014-06-12 14:39:46 +08:00
2015-01-15 10:31:43 +08:00
try{
window.plugins.jPushPlugin.init();
window.plugins.jPushPlugin.setDebugMode(true);
2015-01-15 10:31:43 +08:00
window.plugins.jPushPlugin.getRegistrationID(onGetRegistradionID);
// var extras={"name":"json"};
// window.plugins.jPushPlugin.addLocalNotification(1,"hh","ln",1111,1000*60,extras);
// window.plugins.jPushPlugin.removeLocalNotification(1111);
// window.plugins.jPushPlugin.clearLocalNotifications();
}
catch(exception){
console.log(exception);
}
2014-11-18 14:01:18 +08:00
2014-06-12 14:39:46 +08:00
//test android interface
//window.plugins.jPushPlugin.stopPush()
//window.plugins.jPushPlugin.resumePush();
//window.plugins.jPushPlugin.clearAllNoticication();
//window.plugins.jPushPlugin.setLatestNotificationNum(5);
//window.plugins.jPushPlugin.stopPush();
//window.plugins.jPushPlugin.isPushStopped(onIsPushStopped);
//window.plugins.jPushPlugin.init();
2014-07-24 16:41:42 +08:00
//window.plugins.jPushPlugin.setDebugMode(true);
2014-06-12 11:02:33 +08:00
//window.plugins.jPushPlugin.startLogPageView("mianPage");
2014-06-12 14:39:46 +08:00
2014-06-05 16:36:54 +08:00
$("#setTagWithAliasButton").click(function(ev) {
2014-06-10 14:14:02 +08:00
try{
var tag1 = $("#tagText1").attr("value");
var tag2 = $("#tagText2").attr("value");
var tag3 = $("#tagText3").attr("value");
var alias = $("#aliasText").attr("value");
var dd = [];
2014-06-06 18:15:08 +08:00
2014-06-10 14:14:02 +08:00
if(tag1==""&&tag2==""&&tag3==""){
}
else{
if(tag1 != ""){
dd.push(tag1);
2014-06-09 13:26:04 +08:00
}
2014-06-10 14:14:02 +08:00
if(tag2 != ""){
dd.push(tag2);
2014-06-09 13:26:04 +08:00
}
2014-06-10 14:14:02 +08:00
if(tag3 != ""){
dd.push(tag3);
}
2014-06-12 11:02:33 +08:00
}
2014-06-12 14:39:46 +08:00
window.plugins.jPushPlugin.setTagsWithAlias(dd,alias);
2014-06-10 14:14:02 +08:00
}
catch(exception){
console.log(exception);
}
2014-01-21 14:15:14 +08:00
})
}
2014-06-10 14:14:02 +08:00
document.addEventListener("jpush.setTagsWithAlias", onTagsWithAlias, false);
2015-01-27 18:19:16 +08:00
document.addEventListener("deviceready", onDeviceReady, false);
document.addEventListener("jpush.openNotification", onOpenNotification, false);
2014-01-21 14:15:14 +08:00
</script>
</head>
<body>
<div data-role="page" id="page">
<div data-role="content">
<form>
<div class="ui-body ui-body-b">
<div data-role="fieldcontain">
<center><h3>JPushPlugin Example</h3></center>
<span name="alias" id="alias"></span><hr />
2014-06-05 16:36:54 +08:00
<label>RegistrationID: </label>
<label id="registrationid">null</label>
</div>
2014-01-21 14:15:14 +08:00
<div data-role="fieldcontain">
<label>Tags: </label>
2014-06-04 13:20:24 +08:00
<table>
<tr>
<td>
<input type="text" id="tagText1"/>
</td>
</tr>
<tr>
<td>
<input type="text" id="tagText2"/>
</td>
</tr>
<tr>
<td>
<input type="text" id="tagText3">
</td>
</tr>
</table>
<label>Alias: </label>
<table>
<tr>
<td>
<input type="text" id="aliasText">
</td>
</tr>
</table>
2014-01-21 14:15:14 +08:00
</div>
<div data-role="fieldcontain">
<input type="button" id="setTagWithAliasButton" value="Add tag and alias" />
</div>
2014-06-05 16:36:54 +08:00
<div data-role="fieldcontain">
<label id="tagAliasResult" >null</label>
</div>
2014-01-21 14:15:14 +08:00
</div>
</form>
</div>
</div>
</body>
</html>