Gets the Messaging service for the
default app or a given app.
firebase.messaging() can be called with no arguments to access the default
app's Messaging service or as
firebase.messaging(app) to access the
Messaging service associated with a
specific app.
Calling firebase.messaging() in a service worker results in Firebase
generating notifications if the push message payload has a notification
parameter.
The Messaging SDK does not work in a Node.js environment.
example
// Get the Messaging service for the default appvar defaultMessaging = firebase.messaging();
example
// Get the Messaging service for a given appvar otherMessaging = firebase.messaging(otherApp);
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-09-28 UTC."],[],[],null,["- [firebase](/docs/reference/js/v8/firebase).\n- messaging \nThe Messaging SDK does not work in a Node.js environment.\n\nCallable\n\n- messaging ( app ? : [App](/docs/reference/js/v8/firebase.app.App) ) : [Messaging](/docs/reference/js/v8/firebase.messaging.Messaging)\n- Gets the [`Messaging`](/docs/reference/js/v8/firebase.messaging.Messaging) service for the\n default app or a given app.\n\n `firebase.messaging()` can be called with no arguments to access the default\n app's [`Messaging`](/docs/reference/js/v8/firebase.messaging.Messaging) service or as\n `firebase.messaging(app)` to access the\n [`Messaging`](/docs/reference/js/v8/firebase.messaging.Messaging) service associated with a\n specific app.\n\n Calling `firebase.messaging()` in a service worker results in Firebase\n generating notifications if the push message payload has a `notification`\n parameter.\n\n The Messaging SDK does not work in a Node.js environment.\n\n example\n :\n\n // Get the Messaging service for the default app\n var defaultMessaging = firebase.messaging();\n\n\n example\n :\n\n // Get the Messaging service for a given app\n var otherMessaging = firebase.messaging(otherApp);\n\n\n namespace\n :\n\n Parameters\n -\n\n Optional app: [App](/docs/reference/js/v8/firebase.app.App) \n The app to create a Messaging service for.\n If not passed, uses the default app.\n\n Returns [Messaging](/docs/reference/js/v8/firebase.messaging.Messaging)\n\nIndex\n\nInterfaces\n\n- [FcmOptions](/docs/reference/js/v8/firebase.messaging.FcmOptions)\n- [MessagePayload](/docs/reference/js/v8/firebase.messaging.MessagePayload)\n- [Messaging](/docs/reference/js/v8/firebase.messaging.Messaging)\n- [NotificationPayload](/docs/reference/js/v8/firebase.messaging.NotificationPayload)\n\nFunctions\n\n- [isSupported](/docs/reference/js/v8/firebase.messaging#issupported)\n\nFunctions\n\nisSupported\n\n- isSupported ( ) : boolean\n-\n\nReturns boolean"]]
The Messaging SDK does not work in a Node.js environment.