[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# Optimize server-initiated network use\n\nNetwork traffic sent by server programs to your app can be challenging to\noptimize. A solution to this problem is for your app to periodically poll the\nserver to check for updates. This approach can waste network connection and\npower when your app starts up a device's radio, only to receive an answer that\nno new data is available. A far more efficient approach would be for the server\nto notify your app when it has new data, but figuring out how to send a\nnotification from your server to potentially thousands of devices was previously\nno easy feat.\n\nThe Firebase Cloud Messaging (FCM) service solves this communication problem by\nallowing your servers to send notifications to instances of your app wherever\nthey are installed, enabling greater network efficiency and lowering power\nusage.\n\nThis lesson teaches you how to apply the FCM service to reduce network use for\nserver-initiated actions and reduce battery consumption.\n\nSend server updates with FCM\n----------------------------\n\nFirebase Cloud Messaging (FCM) is a lightweight mechanism used to transmit brief\nmessages from an app server to your app. Using FCM, your app server uses a\nmessage-passing mechanism to notify your app that there is new data available.\nThis approach eliminates network traffic that your app would perform, by not\ncontacting a backend server for new data when no data is available.\n\nAn example use of FCM is an app that lists speaker sessions at a conference.\nWhen sessions are updated on your server, the server sends a brief message to\nyour app telling it updates are available. Your app can then call the server to\nupdate the sessions on the device only when the server has new data.\n\nFCM is more efficient than having your app poll for changes on the server. The\nFCM service eliminates unnecessary connections where polling would return no\nupdates, and it avoids running periodic network requests that could cause a\ndevice's radio to power up. Since FCM can be used by many apps, using it in your\napp reduces the total number of network connections needed on a device and\nallows the device radio to sleep more often.\n| **Note:** When using FCM, your app can pass messages in normal or high priority. Your server should typically use normal priority to deliver messages. Using this priority level prevents devices from being woken up if they are inactive and in a low-power Doze state. Use high priority messages only if absolutely required."]]