Customize a message across platforms Stay organized with collections Save and categorize content based on your preferences.
TheFirebase Admin SDK and theFCM v1HTTP API lets your message requests to setall fields available in themessage object. Thisincludes:
- a common set of fields to be interpreted byall app instances thatreceive the message.
- platform-specific sets of fields, such as
AndroidConfigandWebpushConfig, interpreted only by app instances running on the specifiedplatform.
Platform-specific blocks give you flexibility to customize messages fordifferent platforms to ensure that they are handled correctly when received. TheFCM backend will take all specified parameters into account and customize themessage for each platform.
When to use common fields
Use common fields when you're:
- Send fields to any platform
- Send messages to topics
All app instances, regardless of platform, can interpret the following commonfields:
When to use platform-specific fields
Use platform-specific fields when you want to:
- Send fields only to particular platforms
- Send platform-specific fieldsin addition to the common fields
Whenever you want to send values only to particular platforms, useplatform-specific fields. For example, to send a notification only to Apple andWeb platforms but not to Android, you must use two separate sets of fields, onefor Apple and one for Web.
When you are sending messages with specific delivery options, useplatform-specific fields to set them. You can specify different values perplatform if you want. However, even when you want to set essentially the samevalue across platforms, you must use platform-specific fields. This is becauseeach platform may interpret the value slightly differently—for example,time to live is set on Android as an expiration time in seconds, while on Appleit is set as an expirationdate.
Notification message with platform-specific delivery options
The following HTTP v1 API send request sends a common notification title andcontent to all platforms, but also sends some platform-specific overrides.Specifically, the request:
- sets a long time to live for Android and Web platforms, while setting theAPNs (Apple platforms) message priority to a low setting
- sets the appropriate keys to define the result of a user tap on thenotification on Android and Apple —
click_action, andcategory,respectively.
{"message":{"token":"bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...","notification":{"title":"Match update","body":"Arsenal goal in added time, score is now 3-0"},"android":{"ttl":"86400s","notification"{"click_action":"OPEN_ACTIVITY_1"}},"apns":{"headers":{"apns-priority":"5",},"payload":{"aps":{"category":"NEW_MESSAGE_CATEGORY"}}},"webpush":{"headers":{"TTL":"86400"}}}}To learn more, see theHTTP v1reference page for more detailon the keys available in platform-specific blocks in the message body. For moreinformation about building send requests that contain the message body, seeSend a message using FCM HTTP v1 API.
Notification message with color and icon options
In the following example, the send request sends a common notification title andcontent to all platforms, but it also sends some platform-specific overrides toAndroid devices.
For Android, the request sets a special icon and color to display on Androiddevices. As noted in the reference forAndroidNotification,the color is specified in #rrggbb format, and the image must be a drawable iconresource local to the Android app.
Here's an example of the visual effect on a user's device:
![]()
Node.js
consttopicName='industry-tech';constmessage={notification:{title:'`$FooCorp` up 1.43% on the day',body:'FooCorp gained 11.80 points to close at 835.67, up 1.43% on the day.'},android:{notification:{icon:'stock_ticker_update',color:'#7e55c3'}},topic:topicName,};getMessaging().send(message).then((response)=>{// Response is a message ID string.console.log('Successfully sent message:',response);}).catch((error)=>{console.log('Error sending message:',error);});Java
Messagemessage=Message.builder().setNotification(Notification.builder().setTitle("$GOOG up 1.43% on the day").setBody("$GOOG gained 11.80 points to close at 835.67, up 1.43% on the day.").build()).setAndroidConfig(AndroidConfig.builder().setTtl(3600*1000).setNotification(AndroidNotification.builder().setIcon("stock_ticker_update").setColor("#f45342").build()).build()).setApnsConfig(ApnsConfig.builder().setAps(Aps.builder().setBadge(42).build()).build()).setTopic("industry-tech").build();Python
message=messaging.Message(notification=messaging.Notification(title='$GOOG up 1.43% on the day',body='$GOOG gained 11.80 points to close at 835.67, up 1.43% on the day.',),android=messaging.AndroidConfig(ttl=datetime.timedelta(seconds=3600),priority='normal',notification=messaging.AndroidNotification(icon='stock_ticker_update',color='#f45342'),),apns=messaging.APNSConfig(payload=messaging.APNSPayload(aps=messaging.Aps(badge=42),),),topic='industry-tech',)Go
oneHour:=time.Duration(1)*time.Hourbadge:=42message:=&messaging.Message{Notification:&messaging.Notification{Title:"$GOOG up 1.43% on the day",Body:"$GOOG gained 11.80 points to close at 835.67, up 1.43% on the day.",},Android:&messaging.AndroidConfig{TTL:&oneHour,Notification:&messaging.AndroidNotification{Icon:"stock_ticker_update",Color:"#f45342",},},APNS:&messaging.APNSConfig{Payload:&messaging.APNSPayload{Aps:&messaging.Aps{Badge:&badge,},},},Topic:"industry-tech",}C#
varmessage=newMessage{Notification=newNotification(){Title="$GOOG up 1.43% on the day",Body="$GOOG gained 11.80 points to close at 835.67, up 1.43% on the day.",},Android=newAndroidConfig(){TimeToLive=TimeSpan.FromHours(1),Notification=newAndroidNotification(){Icon="stock_ticker_update",Color="#f45342",},},Apns=newApnsConfig(){Aps=newAps(){Badge=42,},},Topic="industry-tech",};REST
POST https://fcm.googleapis.com/v1/projects/myproject-b5ae1/messages:send HTTP/1.1Content-Type: application/jsonAuthorization: Bearer ya29.ElqKBGN2Ri_Uz...HnS_uNreA{ "message":{ "topic":"industry-tech", "notification":{ "title": "`$FooCorp` up 1.43% on the day", "body": "FooCorp gained 11.80 points to close at 835.67, up 1.43% on the day." }, "android":{ "notification":{ "icon":"stock_ticker_update", "color":"#7e55c3" } } } }To learn more, see theHTTP v1reference page for more detail on the keys available in platform-specific blocks in themessage body.
Notification message with a custom image
Keep in mind:
- Images for notifications are limited to 1MB in size, and otherwise arerestricted by built-in Androidimagesupport.
- To be able to receive and handle notification images in an Apple app,you must add aNotification ServiceExtension.The notification service extension allows your app to handle the imagedelivered in the FCM payload before displaying the notification to theend user, seeSet up the notification serviceextensionfor code sample.
- Images uploaded using the Notifications composer are limited to 300KB in size.
- Images stored or served fromCloud Storage are subject to standardquota limits.
In your notification send request, set the following options to enable thereceiving client to handle the image delivered in the payload:
- For Android, set the followingAndroidConfig option:
notification.imagecontaining the image URL
- For iOS, set the followingApnsConfig options:
fcm_options.imagecontaining the image URL. Apple requires that theimage URL includes a valid file extension to correctly identify theresource type.headers({ "mutable-content": 1})
The following send request sends a common notification title to all platforms,but it also sends an image. Here's an example of the visual effect on a user'sdevice:

Node.js
consttopicName='industry-tech';constmessage={notification:{title:'Sparky says hello!'},android:{notification:{imageUrl:'https://foo.bar.pizza-monster.png'}},apns:{payload:{aps:{'mutable-content':1}},fcm_options:{image:'https://foo.bar.pizza-monster.png'}},webpush:{headers:{image:'https://foo.bar.pizza-monster.png'}},topic:topicName,};getMessaging().send(message).then((response)=>{// Response is a message ID string.console.log('Successfully sent message:',response);}).catch((error)=>{console.log('Error sending message:',error);});REST
POST https://fcm.googleapis.com/v1/projects/myproject-b5ae1/messages:send HTTP/1.1Content-Type: application/jsonAuthorization: Bearer ya29.ElqKBGN2Ri_Uz...HnS_uNreA{ "message":{ "topic":"industry-tech", "notification":{ "title":"Sparky says hello!", }, "android":{ "notification":{ "image":"https://foo.bar/pizza-monster.png" } }, "apns":{ "payload":{ "aps":{ "mutable-content":1 } }, "fcm_options": { "image":"https://foo.bar/pizza-monster.png" } }, "webpush":{ "headers":{ "image":"https://foo.bar/pizza-monster.png" } } } }To learn more, see theHTTP v1reference page for more detail on the keys available in platform-specific blocks in themessage body.
Notification message with an associated click action
The following send request sends a common notification title to all platforms,but it also sends an action for the app to perform in response to the userinteracting with the notification. Here's an example of the visual effecton a user's device:

Node.js
consttopicName='industry-tech';constmessage={notification:{title:'Breaking News....'},android:{notification:{clickAction:'news_intent'}},apns:{payload:{aps:{'category':'INVITE_CATEGORY'}}},webpush:{fcmOptions:{link:'breakingnews.html'}},topic:topicName,};getMessaging().send(message).then((response)=>{// Response is a message ID string.console.log('Successfully sent message:',response);}).catch((error)=>{console.log('Error sending message:',error);});REST
POST https://fcm.googleapis.com/v1/projects/myproject-b5ae1/messages:send HTTP/1.1Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-02-18 UTC.