Connecting userID to devices

2 posts, 0 answers
  1. Pimskie
    Pimskie avatar
    6 posts
    Member since:
    Sep 2013

    Posted 21 Nov 2013 Link to this post

    How can I make the registration of a device happen after user login, in order to send segmented push notifications.

    Thanks!
    Femke
  2. Ivan Pelovski
    Admin
    Ivan Pelovski avatar
    16 posts

    Posted 21 Nov 2013 Link to this post

    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.");
            },
            function(err) {
                alert('REGISTER ERROR: ' + err.message);
            }
        );

    Regards,
    Ivan Pelovski
    Telerik

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top