How can I make the registration of a device happen after user login, in order to send segmented push notifications.
Thanks!
Femke
1 Answer, 1 is accepted
0
Ivan Pelovski
Telerik team
answered on 21 Nov 2013, 04:52 PM
Hi Femke,
You are not providing much information about your application. I'll assume you use the JavaScript SDK and Icenium. Depending on the fact whether your application allows anonymous users or not you may need to register the device twice. In the first case you register the device on application launch and if the user authenticates herself then you register the device a second time. If your application requires the user to log-in then you can register the device after a successful authentication. Here is a code sample how you can do this:
var el = new Everlive('api-key');
el.Users.login('john', 'pass') // user authentication
.then(function () {
return el.push.currentDevice()
.register({ Age: 25 }); // custom parameters
})
.then(function() {
$("#messageParagraph").html(successText + "Device is registered in Everlive and can receive push notifications.");