<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Dan Downey on Medium]]></title>
        <description><![CDATA[Stories by Dan Downey on Medium]]></description>
        <link>https://medium.com/@dan.downey?source=rss-10c7a97a4a7d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*uHD3dPH6wmx9i3yECSRVVg.jpeg</url>
            <title>Stories by Dan Downey on Medium</title>
            <link>https://medium.com/@dan.downey?source=rss-10c7a97a4a7d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 07:54:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dan.downey/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Firebase Payloads and Android Application States]]></title>
            <link>https://medium.com/@dan.downey/firebase-payloads-and-android-application-states-97b6b9187a1b?source=rss-10c7a97a4a7d------2</link>
            <guid isPermaLink="false">https://medium.com/p/97b6b9187a1b</guid>
            <category><![CDATA[notifications]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[app-development]]></category>
            <category><![CDATA[push-notification]]></category>
            <dc:creator><![CDATA[Dan Downey]]></dc:creator>
            <pubDate>Thu, 13 Jun 2019 09:55:45 GMT</pubDate>
            <atom:updated>2019-08-13T07:26:00.325Z</atom:updated>
            <content:encoded><![CDATA[<h3>Firebase Cloud Messaging Payloads and Android Application States</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bzvkyQYVRtYITvB9OMN3iA.jpeg" /></figure><p>The documentation for Firebase Cloud Messaging (FCM) can be unclear as to what exactly happens when a device receives a push message based on Android application state and FCM payload format. This post is an attempt to clear up each situation so we can understand what is possible for us to provide and what format is preferred for receiving notifications on Android.</p><p>There are 3 main app states to examine:</p><ul><li>App in foreground (end user has the app open)</li><li>App alive in background (app is closed but its process is still running)</li><li>App killed (app is closed and its process has been killed by Android or the user)</li></ul><p>Apps being killed can be caused by a few different things. Android can be recycling resources, the user can “Force Stop” the app in settings, and some manufacturers will kill the process when the app is swiped away in “Recents”.</p><p>There are also a number of payload formats to consider:</p><ul><li><strong>notification </strong>and <strong>data</strong> blocks</li><li><strong>notification </strong>block only</li><li><strong>data</strong> block only</li><li>All required keys filled</li><li>Missing/empty keys</li></ul><h3>Basic Payload Format</h3><p>Firebase notifications follow this format (they can contain more information but we’ll keep it simple for now):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/32ccd898d85b8dd27f4c389f4f88ad19/href">https://medium.com/media/32ccd898d85b8dd27f4c389f4f88ad19/href</a></iframe><p>Let’s explain some of the pieces of the payload before moving forward:</p><h4><strong>to</strong></h4><ul><li>Expects an FCM device token to target a specific device with the push</li></ul><h4><strong>notification</strong></h4><ul><li>Contains info required by Firebase to automatically display the push when necessary</li><li><strong>title</strong> and <strong>body </strong>are required</li></ul><h4><strong>data</strong></h4><ul><li>Optional block for passing custom data</li></ul><h3>Notification and Data Blocks</h3><p>So first, let’s consider the situation where you send a notification via FCM that has both a notification and a data block:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2ef33ee29a44e72dcc0931b73a086497/href">https://medium.com/media/2ef33ee29a44e72dcc0931b73a086497/href</a></iframe><h4>App in foreground</h4><p>App is given complete control of the notification. It is possible to access data from either block in the payload.</p><h4>App in background (Alive)</h4><p>Firebase automatically displays a notification using the contents of the <strong>notification </strong>block. When tapped, the <strong>data</strong> block is passed along to the app to allow access to the custom payload.</p><h4>App in background (Killed)</h4><p>Nothing will be received until the app is reopened. Timing and order of delivery are not guaranteed.</p><h3>Notification &amp; Data With Empty Strings</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/81a7894fd3830d49b7cb3761523d7dcc/href">https://medium.com/media/81a7894fd3830d49b7cb3761523d7dcc/href</a></iframe><h4>App in foreground</h4><p>App is given complete control of the notification</p><h4>App in background (Alive)</h4><p>Notification is automatically displayed using the app name as the title, and with no body text</p><h4>App in background (Killed)</h4><p>Nothing will be received until the app is reopened. Timing and order of delivery are not guaranteed.</p><h3>Notification Block Only</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/04ce0bda131bb793d14224920bb49018/href">https://medium.com/media/04ce0bda131bb793d14224920bb49018/href</a></iframe><h4>App in foreground</h4><p>The application is given complete control of the notification. The only things available for use will be the <strong>title </strong>and <strong>body </strong>as there is no custom data sent.</p><h4>App in background (Alive)</h4><p>Notification will display in the system tray. Tapping the notification will open the launch activity but nothing will be passed to the app to handle the notification.</p><h4>App in background (Killed)</h4><p>Nothing will be received until the app is reopened. Timing and order of delivery are not guaranteed.</p><h3>Notification Only With Empty Strings</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3522e5ba5a6c6f5b0a4739b752b9dd79/href">https://medium.com/media/3522e5ba5a6c6f5b0a4739b752b9dd79/href</a></iframe><h4>App in foreground</h4><p>The application is given complete control of the notification.</p><h4>App in background (Alive)</h4><p>The notification is automatically displayed using the application name as the title, and with no body text.</p><h4>App in background (Killed)</h4><p>Nothing will be received until the app is reopened. Timing and order of delivery are not guaranteed.</p><h3>Data Block Only</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/682d7adf6f6a9cb29201f619d1e09d90/href">https://medium.com/media/682d7adf6f6a9cb29201f619d1e09d90/href</a></iframe><h4>App in foreground</h4><p>App is given complete control of the notification. In this case, all of the details necessary to perform the desired actions (e.g. display a notification or track some metrics) must be included in the <strong>data </strong>block.</p><h4>App in background (Alive)</h4><p>App is given complete control of the notification. Same as if it was in the foreground in this case.</p><h4>App in background (Killed)</h4><p>Nothing will be received until the app is reopened. Timing and order of delivery are not guaranteed.</p><h3>Summarised Results</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/80af56a48d1938c390c5d93d65982565/href">https://medium.com/media/80af56a48d1938c390c5d93d65982565/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=97b6b9187a1b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>