TypeError: firebase.messaging is not a function in node.js

前端 未结 5 1986
我在风中等你
我在风中等你 2021-01-17 19:58

While trying to fetch the FCM messages in node.js using firebase module, following error \"TypeError: firebase.messaging is not a function\" is occurring.

v         


        
5条回答
  •  离开以前
    2021-01-17 20:34

    The criteria you are trying to use only works on the browser:

    You have to require firebase-messaging, check this full sample it will guide you https://github.com/firebase/quickstart-js/tree/master/messaging

    For nodeJS implementation, you have to use admin.messaging

    https://firebase.google.com/docs/reference/admin/node/admin.messaging

    // Get the Messaging service for the default app
    var defaultMessaging = admin.messaging();
    

提交回复
热议问题