Firebase Notificaion ios

Thread is closed for posting
3 posts, 0 answers
  1. suralal
    suralal avatar
    18 posts
    Member since:
    Mar 2016

    Posted 02 Mar 2017 Link to this post

    Hi,

    I am using firebase for push notification.In android i am getting the notification in background and clicking on it transfers to the desired function page.But in ios i am able to get the notificaiton but clicking on it redirects to the application home page as addOnMessageReceived is not getting invoked in application for ios.

    i am attaching the sample code which i am using :

    firebase.addOnMessageReceivedCallback( function(message){

    dialogsModule.alert({ title: "Push message: " +  (message.title !== undefined ? message.title : ""),      

    message: JSON.stringify(message),       okButtonText: "OK"    

    })

    });

  2. Nikolay Iliev
    Admin
    Nikolay Iliev avatar
    351 posts

    Posted 06 Mar 2017 Link to this post

    Hi Suralai,

    The provided information is not enough to test the described scenario on our side but I can make some suggestions how to resolve your issue. First of all - to enable notifications via Firebase there are several plugins and I am guessing that you are either using one of them or creating your own implementation. (e.g. is it nativescript-local-notification or nativescript-plugin-firebase or your own code).Please refer to the detailed guides in the README sections of the used plugin as there are many small but crucial steps to enable the Cloud Messaging.

    Notice that in iOS the notifications might be truly tested only on a real device and are harder or even impossible to test on a simulator. To test on a real device you will have your Firebase console configured (with created push notification certificate), the application has to be created with setting up your development profile and then after providing all the steps required by the specific push notification plugin you can send a notification from your Firebase console to your iOS application. Again it will only appear on a real device and should not be triggered on a simulator (or at least not all notification functionalities will work on the simulator)

    Note that if you are using nativescript-local-notifications for iOS addMessageReceivedCallback should be triggered in both background and foreground (which ease the testing process) so you can check if your notifications are triggering the callback method with a simple log (or as in your case with a logic to show a dialog or redirect to another page). Are your logs from addMessageReceivedCallback triggered?
    e.g.
    firebase.addOnMessageReceivedCallback(function(message) {
         console.log("Received message: "  + JSON.stringify(message));
        // are you receving this on sent notificitaion?
    });
    Please make sure that you are executing each step provided by the author of the plugin.Setting up Firebase can indeed be a job that relays on many small but crucial steps. If using nativescript-local-notifications you can also try this demo (with providing your own Firebase settings and files) and test the differences between your code and the code of the author. If none of this work please provide us with a sample code that can reproduce this one and/or log an issue at the plugin's repository.

    As a side note, one of the best plugins in terms of provided functionality for using Firebase with NativeScript is nativescript-plugin-firebase which enables almost all of what Firebase can offer. There is a sub-section especially created for working with Cloud Messaging (a.k.a. push notifications) here. Fully working application demonstrating the usage of the plugin with Firebase Cloud Messaging can be found in our nativescript-marketplace-demo.

    Regards,
    Nikolay Iliev
    Telerik by Progress
    Did you know that you can open private support tickets which are reviewed and answered within 24h by the same team who built the components? This is available in our UI for NativeScript Pro + Support offering.
  3. Nikolay Iliev
    Admin
    Nikolay Iliev avatar
    351 posts

    Posted 06 Mar 2017 Link to this post

    Hey Suralai,

    To demonstrate all the steps needed for enabling the push notifications and also to test your case I have created this application here. After all the steps are executed I was able to successfully send notification and to receive data and execute logic in the onMessageRecivedCallback.

    I hope you will find this info useful!

    Regards,
    Nikolay Iliev
    Telerik by Progress
    Did you know that you can open private support tickets which are reviewed and answered within 24h by the same team who built the components? This is available in our UI for NativeScript Pro + Support offering.
Back to Top