http://localhost:8080/restnotification/registration/application_registration_id
http://localhost:8080/restnotification/application/com.kapsel.gs/user/daniel_v
http://localhost:8080/restnotification/application/com.kapsel.gs
{"alert":"New Vacation Approval Request", "data":"For (i826565) request (7)" }
cordova plugin remove kapsel-plugin-appupdate
cordova plugin add kapsel-plugin-push --searchpath %KAPSEL_HOME%/plugins
<html>
<head>
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
<script type="text/javascript" charset="utf-8" src="serverContext.js"></script>
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script>
applicationContext = null;
window.onerror = onError;
var startTime = null;
function onError(msg, url, line) {
console.log("EventLogging: onError");
var idx = url.lastIndexOf("/");
var file = "unknown";
if (idx > -1) {
file = url.substring(idx + 1);
}
alert("An error occurred in " + file + " (at line # " + line + "): " + msg);
console.log("EventLogging: An error occurred in " + file + " (at line # " + line + "): " + msg);
return false; //suppressErrorAlert;
}
function init() {
console.log("EventLogging: init");
if (sap.Logger) {
sap.Logger.setLogLevel(sap.Logger.DEBUG); //enables the display of debug log messages from the Kapsel plugins.
sap.Logger.debug("Log level set to DEBUG");
}
sap.Logon.init(logonSuccessCallback, logonErrorCallback, appId, context);
}
function register() {
console.log("EventLogging: register");
sap.Logon.init(logonSuccessCallback, logonErrorCallback, appId, context);
}
function logonErrorCallback(error) {
console.log("EventLogging: logonErrorCallback: " + JSON.stringify(error));
if (device.platform == "Android") { //Not supported on iOS
navigator.app.exitApp();
}
}
function unRegister() {
console.log("EventLogging: unRegister");
try {
sap.Logon.core.deleteRegistration(logonUnregisterSuccessCallback, errorCallback);
}
catch (e) {
alert("problem with unregister");
}
}
function logonSuccessCallback(result) {
console.log("EventLogging: logonSuccessCallback " + JSON.stringify(result));
applicationContext = result;
startTime = performance.now();
if (window.localStorage.getItem("isPushRegistered") == "true") {
initPush(); //faster then calling registerForPush
}
else {
window.localStorage.setItem("isPushRegistered", "false");
registerForPush();
}
}
function logonUnregisterSuccessCallback(result) {
console.log("EventLogging: logonUnregisterSuccessCallback");
alert("Logon Unregistration success");
applicationContext = null;
window.localStorage.setItem("isPushRegistered", "false");
}
function errorCallback(e) {
console.log("EventLogging: errorCallback " + JSON.stringify(e));
alert("An error occurred " + JSON.stringify(e));
}
function registerForPush() {
console.log("EventLogging: registerForPush");
var nTypes = sap.Push.notificationType.SOUNDS | sap.Push.notificationType.ALERT;
sap.Push.registerForNotificationTypes(nTypes, pushRegistrationSuccess, pushRegistrationFailure, processNotification, null /* optional GCM Sender ID */);
}
function initPush() {
console.log("EventLogging: initPush");
sap.Push.initPush(processNotification);
}
function unregisterForPush() {
console.log("EventLogging: unregisterForPush");
var nTypes = sap.Push.notificationType.SOUNDS | sap.Push.notificationType.ALERT;
sap.Push.unregisterForNotificationTypes(pushUnregistrationCallback);
}
function pushRegistrationSuccess(result) {
console.log("EventLogging: pushRegistrationSuccess" + JSON.stringify(result));
window.localStorage.setItem("isPushRegistered", "true");
}
function pushRegistrationFailure(errorInfo) {
console.log("EventLogging: pushRegistrationFailure " + JSON.stringify(errorInfo));
alert("Error while registering for Push. " + JSON.stringify(errorInfo));
}
function pushUnregistrationCallback(result) {
console.log("EventLogging: pushUnregistration: " + JSON.stringify(result));
alert("Successfully unregistered for Push: " + JSON.stringify(result));
window.localStorage.setItem("isPushRegistered", "false");
}
function processNotification(notification) {
var endTime = performance.now();
console.log("EventLogging Perf: " + ((endTime - startTime)/1000).toFixed(3) + " seconds from logonSuccess till message received");
alert("in processNotification: " + JSON.stringify(notification));
console.log("EventLogging: processNotification: " + JSON.stringify(notification));
if (sap.Push.setPushFeedbackStatus && notification.additionalData) { //SP15 new feature
sap.Push.setPushFeedbackStatus('consumed', notification.additionalData.notificationId, pushFeedbackStatusSuccessCallback, pushFeedbackStatusErrorCallback);
}
}
function pushFeedbackStatusSuccessCallback(status) {
console.log("EventLogging: set the push feedback status to consumed");
}
function pushFeedbackStatusErrorCallback(status) {
console.log("EventLogging: push feedback error: " + JSON.stringify(status));
}
function onLoad() {
console.log("EventLogging: onLoad");
}
function onBeforeUnload() {
console.log("EventLogging: onBeforeUnLoad");
}
function onUnload() {
console.log("EventLogging: onUnload");
}
function onPause() {
console.log("EventLogging: onPause");
}
function onResume() {
console.log("EventLogging: onResume");
}
function onSapResumeSuccess() {
console.log("EventLogging: onSapResumeSuccess");
}
function onSapResumeError(error) {
console.log("EventLogging: onSapResumeError " + JSON.stringify(error));
}
function onSapLogonSuccess() {
console.log("EventLogging: onSapLogonSuccess");
}
document.addEventListener("deviceready", init, false);
document.addEventListener("pause", onPause, false);
document.addEventListener("resume", onResume, false);
document.addEventListener("onSapResumeSuccess", onSapResumeSuccess, false);
document.addEventListener("onSapLogonSuccess", onSapLogonSuccess, false);
document.addEventListener("onSapResumeError", onSapResumeError, false);
</script>
</head>
<body onload="onLoad()" onbeforeunload="onBeforeUnload()" onunload="onUnload()" >
<h1>Push Sample</h1>
<button id="register" onclick="register()">Register</button>
<button id="unregister" onclick="unRegister()">Unregister</button>
<button onclick="unregisterForPush()">Unregister For Push</button>
<br>
</body>
</html>
cordova run android
http://127.0.0.1:8080/restnotification/application/com.kapsel.gs/
{"alert":"New Vacation Approval Request", "data":"For (i82XXXX) request (7)" }
http://localhost:8080/restnotification/registration/59a72605-2a64-4778-953d-c215a7d565eb
{"alert":"New Vacation Approval Request", "data":"For (i82XXXX) request (7)" }
http://localhost:8080/restnotification/application/com.kapsel.gs/user/i82XXXX
{"alert":"New Vacation Approval Request", "data":"For (i82XXXX) request (7)" }
java.lang.UnsupportedOperationException: Device does not have package com.google.android.gsf
C:\Android\adt-bundle-windows-x86_64-20130522\sdk\extras\google\gcm\gcm-client\dist\gcm.jar
SELECT * from SMP-NOTIFICATION-TARGET where TARGETID = '<connection id>'
Verify that the
- row exists,
- TARGETID value is the connection ID,
- CONFIGID value is the application ID
- DEVICENOTIFICATIONKEY1 is the device ID from the gateway/ device ID from APNS or GCM
- NOTIFICATIONTYPE must not be null, 0 for APNS, 1 for GCM, 2 for Blackberry, 4 for WNS and 5 for MPNS
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
10 | |
10 | |
10 | |
9 | |
8 | |
8 | |
6 | |
6 | |
5 | |
5 |