<?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 Alexander Borodin on Medium]]></title>
        <description><![CDATA[Stories by Alexander Borodin on Medium]]></description>
        <link>https://medium.com/@borodin32?source=rss-bd8a94a57b62------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*8wGwebSuAcmiZ7efta6Usg.jpeg</url>
            <title>Stories by Alexander Borodin on Medium</title>
            <link>https://medium.com/@borodin32?source=rss-bd8a94a57b62------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 12:16:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@borodin32/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[Managing push notifications in a clean way]]></title>
            <link>https://medium.com/@borodin32/managing-push-notifications-in-a-clean-way-62a10501461?source=rss-bd8a94a57b62------2</link>
            <guid isPermaLink="false">https://medium.com/p/62a10501461</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[push-notification]]></category>
            <dc:creator><![CDATA[Alexander Borodin]]></dc:creator>
            <pubDate>Wed, 11 Apr 2018 14:28:27 GMT</pubDate>
            <atom:updated>2018-04-11T14:28:27.657Z</atom:updated>
            <content:encoded><![CDATA[<h4>Way round trip</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R7lF7iIWfACW-CHwWUk3Uw.jpeg" /></figure><p>Push notifications are a great thing, which returns thousands and even millions of users in mobile applications everyday. With the increase of the application code base, the number of different notification types also grows and it leads to a bad-smelling code.</p><p>Imagine that in the data dictionary we get some <em>type, id </em>and <em>message </em>fields. Fieldtype allows you to determine the type of notification that we need to show, id is the ID of the page, person, etc. in general, what we will open by clicking on the notification, and message is the message that we will show in the notification. In this case, the data processing will look something like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8799d980946dbd28186959f8764b91f6/href">https://medium.com/media/8799d980946dbd28186959f8764b91f6/href</a></iframe><p>When you are developing the application, new notifications will be added, the old ones will change, some business logic will be added and the code above will turn into a huge canvas with if and when. But if you think about it, you can come to the conclusion that every notification is a conditional object that “comes” to the device — thanks to long polling, and the developer shows it.</p><p>Let’s create some abstract class describing the notification:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/382cf964fd7997418f3b6b20866bd0f8/href">https://medium.com/media/382cf964fd7997418f3b6b20866bd0f8/href</a></iframe><p>Thus, our CustomNotifications knows nothing about the type of notification and its parameters. After that, adding a new notification could be done in a few steps:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fa68f850e2b97d2432b10165b867c85c/href">https://medium.com/media/fa68f850e2b97d2432b10165b867c85c/href</a></iframe><p>To link the code above and the GCM service, we will create an abstract helper class, which have to be redefined in the application and its specific implementation:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d1e43318e6b892aac166ed68118d39ea/href">https://medium.com/media/d1e43318e6b892aac166ed68118d39ea/href</a></iframe><p>Its implementation:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/56feb6d0a64008f7ae22111b20405a28/href">https://medium.com/media/56feb6d0a64008f7ae22111b20405a28/href</a></iframe><p>Well, the final snippet for inserting notifications into our application:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/02236042068687d76bab403922ca09e5/href">https://medium.com/media/02236042068687d76bab403922ca09e5/href</a></iframe><p>To sum up, we have got an implementation of the service that processes push notifications with the ability to quickly add a new notification to the application or change the old one, keeping the code clean and consistent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vpojkvQcEy07xTQ7mXj-Yg.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=62a10501461" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>