<?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 Rodrigo Haus Bacellar on Medium]]></title>
        <description><![CDATA[Stories by Rodrigo Haus Bacellar on Medium]]></description>
        <link>https://medium.com/@rodrigohsb?source=rss-e2821973af67------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*uemIZuLFGLRCqRnrEPNFug.png</url>
            <title>Stories by Rodrigo Haus Bacellar on Medium</title>
            <link>https://medium.com/@rodrigohsb?source=rss-e2821973af67------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 07:34:02 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rodrigohsb/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[Automatic sms authentication without asking permission — SMS Retriever API]]></title>
            <link>https://medium.com/@rodrigohsb/automatic-sms-authentication-without-asking-permission-sms-retriever-api-47eb5026b9a3?source=rss-e2821973af67------2</link>
            <guid isPermaLink="false">https://medium.com/p/47eb5026b9a3</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[sms-verification-service]]></category>
            <category><![CDATA[sms]]></category>
            <category><![CDATA[authentication]]></category>
            <dc:creator><![CDATA[Rodrigo Haus Bacellar]]></dc:creator>
            <pubDate>Thu, 15 Mar 2018 17:14:14 GMT</pubDate>
            <atom:updated>2018-03-22T19:28:00.683Z</atom:updated>
            <content:encoded><![CDATA[<h4>Android</h4><p>Since we want to use all the latest features in the Android framework, we always need to use the latest version. As Android is advancing to restrict sensitive user data that forces applications to request permissions, the downside is that it&#39;s not reliable because users can deny and our features, that depends on permission, can never be reached until they allow the application to do something even if we explain it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_-71CaJ8Vp3MrGvYtd04uA.png" /><figcaption><em>SMS runtime permission dialog</em></figcaption></figure><p>An example is when the app asks for permission in order to read sms, after the user filled out the phone number, to automatically pick up the sms pin code to log he in. If the user denies the permission and he can not see the entire content of the sms by pulling down the notification, he&#39;ll have to get out from your app just to memorize the code and come back to write it. Besides being annoying, he may not come back any more.</p><p>Therefore, Google created an API called <strong>SMS Retriever</strong> that handle this flow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/957/1*lQr2zB_fw257uHOb1bpsMg.png" /><figcaption><em>SMS Retriever API</em></figcaption></figure><h4>Those are the requirements:</h4><ul><li>Android devices with Play services version 10.2+</li><li>BroadcastReceiver</li><li>Google auth dependency</li><li>Google gcm dependency</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fdd4f1326db5c9c44f05e72adcd1e899/href">https://medium.com/media/fdd4f1326db5c9c44f05e72adcd1e899/href</a></iframe><ul><li>SMS pattern (prefix and app hash suffix)</li></ul><pre><strong>&lt;#&gt;</strong> ExampleApp: Your code is 123ABC78<br><strong>FA+9qCX9VSu</strong></pre><p>As you saw above, the sms has need to have the <strong>predetermined prefix</strong> &quot;<strong>&lt;#&gt;</strong>&quot; and a <strong>app</strong> <strong>hash suffix</strong>.</p><h4><strong>Let&#39;s code!</strong></h4><p>To generate the hash of you app, you have two options:</p><ul><li><strong>Command line:</strong></li></ul><pre>keytool -exportcert -alias <strong>YOUR_KEYSTORE_ALIAS</strong> -keystore <strong>YOUR_KEYSTORE_FILE</strong> | xxd -p | tr -d &quot;[:space:]&quot; | echo -n com.example.myapp `cat` | sha256sum | tr -d &quot;[:space:]-&quot; | xxd -r -p | base64 | cut -c1-11</pre><ul><li><strong>Code:</strong></li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/acdc023919ebf694d74c1521762a551e/href">https://medium.com/media/acdc023919ebf694d74c1521762a551e/href</a></iframe><p>Now we need to create the broadcastReceiver to receive the SMS (Here is where the app will get the sms content):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cde93c4b6a5a0ef4cb07c19ea2c0d8c6/href">https://medium.com/media/cde93c4b6a5a0ef4cb07c19ea2c0d8c6/href</a></iframe><p>Then, we need to inform this broadcast to android. We do this adding the receive<strong> </strong>tag inside the manifest.xml:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/82b6ce596d1af010d3f89c4f72b56a99/href">https://medium.com/media/82b6ce596d1af010d3f89c4f72b56a99/href</a></iframe><p>Now, you get the sms retriever client and then start it and declare its callbacks (<strong>addOnSuccessListener </strong>and<strong> addOnFailureListener</strong>):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a7b935281e2ee3195231f33e6400631e/href">https://medium.com/media/a7b935281e2ee3195231f33e6400631e/href</a></iframe><p>Now users can log in through sms pin code without permission!! =)</p><p>The example project can be found on <a href="https://github.com/rodrigohsb/sms-retriever">Github</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=47eb5026b9a3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>