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

GCM: get RegistrationId from Cordova hybrid app

3 Answers 98 Views
General Discussion
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Federico
Top achievements
Rank 1
Federico asked on 03 Aug 2016, 03:39 PM

Hello, I've just started to develop apps for android.

I've done an Hybrid Cordova app in telerik platform, so I'm using javascript as language.

I need to get push notification sent from a server to my android device.

I have a project in Firebase and I set thecorrect google API Key and ProjectId in my code.

In order to send the message from the server, I need the Registration ID of my app. How could I get?

I found a lot of examples in Java, but none in javascript.

Thanks!

3 Answers, 1 is accepted

Sort by
0
Anton Dobrev
Telerik team
answered on 09 Aug 2016, 08:29 AM
Hello,

You may consider using the Telerik Push Notifications plugin from here.

It will give you the option to obtain the registration Id for the device and save it on your server or use the integration with Telerik Platform push notifications.

One notable details is that it still relies on the GCM for Android (instead of FCM) and you will need to configure a project in the Google Developers console.

Let me know if this answers your question.

Regards,
Anton Dobrev
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Nagaraj
Top achievements
Rank 2
answered on 06 Feb 2017, 06:33 PM

Hello,

     I am creating an Hybrid app and backend as Asp WEBAPI 2.0, I have configured in FCM  for my  project and I am using PushSharp push notification for my app. I am also facing same issue to get the registration token.,Please guide me on this issue.

0
Anton Dobrev
Telerik team
answered on 09 Feb 2017, 04:05 PM
@Nagaraj

The plugin is tailored to work with Telerik Platform Backend Services JS SDK for using with Telerik Platform Notifications service (which allows for managing the device registrations and sending push notifications). More information here.

However, you can use the plugin API (visible here) to manage it yourself.

For example:

var pushNotification;
 
document.addEventListener("deviceready", function(){
    pushNotification = window.plugins.pushNotification;
    ...
});

For Android:
pushNotification.register(
    successHandler,
    errorHandler,
    {
        "senderID":"replace_with_sender_id",
        "ecb":"onNotification" //this is a callback function name called when the notification is received
    });

For iOS:

pushNotification.register(
    tokenHandler,
    errorHandler,
    {
        "badge":"true",
        "sound":"true",
        "alert":"true",
        "ecb":"onNotificationAPN" // this is a callback function name when a notification is received
    });

When you obtain the token, save it to your server and use it when sending push notifications.

I hope this helps.

Regards,
Anton Dobrev
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussion
Asked by
Federico
Top achievements
Rank 1
Answers by
Anton Dobrev
Telerik team
Nagaraj
Top achievements
Rank 2
Share this question
or