EddyVerbruggen / nativescript-plugin-firebase

:fire: NativeScript plugin for Firebase
https://firebase.google.com
MIT License
1.01k stars 446 forks source link

Uncomment firebase-messaging in the plugin's include.gradle first #1569

Open peppeg85 opened 4 years ago

peppeg85 commented 4 years ago

hello i read other discussions but i still can't sole, anyone knows how to solve this error? "Uncomment firebase-messaging in the plugin's include.gradle first"

here is my configuration:

    "tns-android": {
            "version": "6.3.1"
        }
    },
    "dependencies": {
        "@nstudio/nativescript-checkbox": "^1.0.0",
        "@nstudio/nativescript-loading-indicator": "^1.0.0",
        "moment": "^2.22.2",
        "nativescript-plugin-firebase": "10.5.0",
        "nativescript-theme-core": "^1.0.4",
        "nativescript-ui-listview": "7.0.0",
        "nativescript-ui-sidedrawer": "7.0.0",
        "tns-core-modules": "^6.2.3"
    },
    "devDependencies": {
        "babel-traverse": "6.4.5",
        "babel-types": "6.4.5",
        "babylon": "6.4.5",
        "lazy": "1.0.11",
        "nativescript-dev-webpack": "~1.3.0"
    }

and in the app.js i init with this:

require("./bundle-config");
var application = require("application");
var firebase = require("nativescript-plugin-firebase");
var dialogsModule = require("ui/dialogs")

var applicationSettings = require("application-settings");
var frameModule = require("ui/frame");

setTimeout(() => {
    firebase.init({
        onMessageReceivedCallback: function (message) {
            if (message.foreground == false) {
                dialogsModule.alert({
                    title: message.data.title,
                    message: message.data.body,
                    okButtonText: "OK"
                });
                if(message.data.topic == "events"){
                    navigate("eventsList")
                }else{
                    navigate("notifications")
                }
            } else {
                dialogsModule.alert({
                    title: message.data.title,
                    message: message.data.body,
                    okButtonText: "OK"
                })

                if(message.data.topic == "events"){
                    navigate("eventsList")
                }else{
                    navigate("notifications")
                }

            }
        },
    }).then(
        function (instance) {
            firebase.subscribeToTopic("Generale");
            firebase.subscribeToTopic("events");
        },
    )
}, 0)

function navigate(view) {
    var navigationPoint = {
        moduleName: 'views' + '/' + view + '/' + view,
        clearHistory: false
    };
    frameModule.topmost().navigate(navigationPoint);
}

thank you

peppeg85 commented 4 years ago

i tried to console log the instance after the init and i have null, is it normal?

function (instance) { console.log('subscribe, ',instance)

manojdcoder commented 4 years ago

Which discussion you are referring to? Whats your exact issue?