GCM: get RegistrationId from Cordova hybrid app

Thread is closed for posting
4 posts, 0 answers
  1. Federico
    Federico avatar
    1 posts
    Member since:
    Jul 2016

    Posted 03 Aug 2016 Link to this post

    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!

  2. Anton Dobrev
    Admin
    Anton Dobrev avatar
    600 posts

    Posted 09 Aug 2016 Link to this post

    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
  3. Nagaraj
    Nagaraj avatar
    2 posts
    Member since:
    Apr 2014

    Posted 06 Feb Link to this post

    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.

  4. Anton Dobrev
    Admin
    Anton Dobrev avatar
    600 posts

    Posted 09 Feb Link to this post

    @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
Back to Top