This is a migrated thread and some comments may be shown as answers.

Connecting userID to devices

1 Answer 98 Views
Push Notifications
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Pimskie
Top achievements
Rank 1
Pimskie asked on 21 Nov 2013, 04:20 PM
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

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

Regards,
Ivan Pelovski
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
Push Notifications
Asked by
Pimskie
Top achievements
Rank 1
Answers by
Ivan Pelovski
Telerik team
Share this question
or