This question is locked. New answers and comments are not allowed.
Hi
I am trying to use the Everlive Push Notification without the MVVM template that it comes with. The approach i have taken is to remove the reference of main.js from index.html and include a different js file to host my code. I don't think MVVM should be essential for using Push Notifications.
The code that i currently have is as follows:
"use strict";
document.addEventListener("deviceready", onDeviceReady, false);
// PhoneGap is ready
function onDeviceReady() {
var app = new kendo.mobile.Application(document.body);
var el = new Everlive('xxxxxxxx');
var currentDevice;
var successCallback = function(arg) {
alert('Device already registered');
currentDevice= arg;
}
//el.push.currentDevice().getRegistration(successCallback, function() {alert("Registering the device.");currentDevice = el.push.currentDevice();});
var pushSettings = {
iOS:{
badge: true,
sound: true,
alert: true
},
android:{
senderID: '55555555555555
},
notificationCallbackIOS: function(e){
alert('Initialized successfully' + + JSON.stringify(e));
},
notificationCallbackAndroid: onAndroidPushReceived
};
el.push.currentDevice().enableNotifications(pushSettings, function() {alert('Initialized successfully');}, function() {alert('Initialization error');});
}
var onAndroidPushReceived = function(args) {
alert('Notification Received');
alert('Android notification received: ' + JSON.stringify(args));
};
function registerInEverlive() {
alert("Starting REgistration");
var el = new Everlive('xxxxxxxxx');
// el.push.currentDevice().register({ Group: 15 }, function() {alert('Registered successfully');}, function() {alert('Registeration NOT successfully');});
var currentDevice = el.push.currentDevice();
if (!currentDevice.pushToken) currentDevice.pushToken = "some token";
el.push.currentDevice()
.register({ Age: 15 })
.then(
function() {
alert('Device registered with Everlive');
},
function(err) {
alert('REGISTER ERROR: ' + JSON.stringify(err));
}
);
}
With the above code i am able to register Android device on Everlive (and i am able to confirm the same from the portal). However, any push notification that i send from the portal is not reaching the device. I have supplied the Everlive key, Google API Project ID in the code above. In the Everlive portal, I am using the Server Key (of GCM).
Earlier, using the template the notifications were able to reach the device.
Cheers
Abhishek Kant
I am trying to use the Everlive Push Notification without the MVVM template that it comes with. The approach i have taken is to remove the reference of main.js from index.html and include a different js file to host my code. I don't think MVVM should be essential for using Push Notifications.
The code that i currently have is as follows:
"use strict";
document.addEventListener("deviceready", onDeviceReady, false);
// PhoneGap is ready
function onDeviceReady() {
var app = new kendo.mobile.Application(document.body);
var el = new Everlive('xxxxxxxx');
var currentDevice;
var successCallback = function(arg) {
alert('Device already registered');
currentDevice= arg;
}
//el.push.currentDevice().getRegistration(successCallback, function() {alert("Registering the device.");currentDevice = el.push.currentDevice();});
var pushSettings = {
iOS:{
badge: true,
sound: true,
alert: true
},
android:{
senderID: '55555555555555
},
notificationCallbackIOS: function(e){
alert('Initialized successfully' + + JSON.stringify(e));
},
notificationCallbackAndroid: onAndroidPushReceived
};
el.push.currentDevice().enableNotifications(pushSettings, function() {alert('Initialized successfully');}, function() {alert('Initialization error');});
}
var onAndroidPushReceived = function(args) {
alert('Notification Received');
alert('Android notification received: ' + JSON.stringify(args));
};
function registerInEverlive() {
alert("Starting REgistration");
var el = new Everlive('xxxxxxxxx');
// el.push.currentDevice().register({ Group: 15 }, function() {alert('Registered successfully');}, function() {alert('Registeration NOT successfully');});
var currentDevice = el.push.currentDevice();
if (!currentDevice.pushToken) currentDevice.pushToken = "some token";
el.push.currentDevice()
.register({ Age: 15 })
.then(
function() {
alert('Device registered with Everlive');
},
function(err) {
alert('REGISTER ERROR: ' + JSON.stringify(err));
}
);
}
With the above code i am able to register Android device on Everlive (and i am able to confirm the same from the portal). However, any push notification that i send from the portal is not reaching the device. I have supplied the Everlive key, Google API Project ID in the code above. In the Everlive portal, I am using the Server Key (of GCM).
Earlier, using the template the notifications were able to reach the device.
Cheers
Abhishek Kant