<?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 Orji Ace on Medium]]></title>
        <description><![CDATA[Stories by Orji Ace on Medium]]></description>
        <link>https://medium.com/@orjiace?source=rss-5dfeb23d4d9a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*1SZ8IyfQIVveuelEf7LH6g.jpeg</url>
            <title>Stories by Orji Ace on Medium</title>
            <link>https://medium.com/@orjiace?source=rss-5dfeb23d4d9a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 13:51:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@orjiace/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[Before the Bloom EP1: How this started]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://orjiace.medium.com/before-the-bloom-ep1-how-this-started-425d33cbc02c?source=rss-5dfeb23d4d9a------2"><img src="https://cdn-images-1.medium.com/max/2600/1*5Rb1agfT-F0F4VBk33W3iA.png" width="3022"></a></p><p class="medium-feed-snippet">Hi, I&#x2019;m Ace. Founder of ZOWIS, a womenswear house in Abuja.</p><p class="medium-feed-link"><a href="https://orjiace.medium.com/before-the-bloom-ep1-how-this-started-425d33cbc02c?source=rss-5dfeb23d4d9a------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://orjiace.medium.com/before-the-bloom-ep1-how-this-started-425d33cbc02c?source=rss-5dfeb23d4d9a------2</link>
            <guid isPermaLink="false">https://medium.com/p/425d33cbc02c</guid>
            <dc:creator><![CDATA[Orji Ace]]></dc:creator>
            <pubDate>Mon, 17 Aug 2026 17:31:55 GMT</pubDate>
            <atom:updated>2026-08-17T17:37:10.132Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[5 Translation APIs Compared: Speed, Price, and Language Coverage]]></title>
            <link>https://orjiace.medium.com/5-translation-apis-compared-speed-price-and-language-coverage-c3bc4f66c2fa?source=rss-5dfeb23d4d9a------2</link>
            <guid isPermaLink="false">https://medium.com/p/c3bc4f66c2fa</guid>
            <category><![CDATA[text-to-speech]]></category>
            <category><![CDATA[translation]]></category>
            <category><![CDATA[best-translation-api]]></category>
            <category><![CDATA[language-translation]]></category>
            <category><![CDATA[text-to-speech-software]]></category>
            <dc:creator><![CDATA[Orji Ace]]></dc:creator>
            <pubDate>Wed, 10 Jun 2026 12:05:32 GMT</pubDate>
            <atom:updated>2026-06-10T12:05:32.672Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*EDzaDCdj6QBkHbQjqTN3dQ.avif" /></figure><p>If you have ever shipped a feature that needs translation, you know the choice of API matters more than it should. The wrong pick costs you twice. First on your monthly bill. Then again, when you realize the language you actually need is not supported.</p><p>I have used five of the most common translation APIs across side projects and production work. This is what I would tell a friend who is about to pick one.</p><h3>How I tested</h3><p>I ran the same set of requests through each API. Short strings (under 50 characters), medium paragraphs (200 to 500 characters), and long blocks of around 2,000 characters. I tracked three things:</p><ol><li>Latency from a Lagos server to the closest endpoint</li><li>Total cost to translate one million characters</li><li>Which languages are supported, and how well the less common ones perform</li></ol><p>I also looked at what it takes to actually start using the thing. Some of these APIs are easy to get running. Others want you to set up a billing account, link a credit card, and wait for verification before you can send a single request.</p><h3>1. <a href="https://cloud.google.com/translate">Google Cloud Translation</a></h3><p>The default choice for most developers. It supports more than 130 languages and handles common pairs very well. Latency is consistent, usually under 250ms from most regions.</p><p>Where Google hurts is the cost and the friction. The base API charges around $20 per million characters. Their newer LLM-powered tier costs more. To use it at all you need a Google Cloud project, a billing account linked to a verified card, and the patience to read through their auth setup.</p><p>For African languages, quality is acceptable for Swahili and Amharic. Yoruba and Igbo are weaker. The tonal marks on Yoruba are often missing or wrong.</p><p>Best for: teams already deep in Google Cloud who do not care about cost.</p><h3>2. <a href="https://www.deepl.com/pro-api">DeepL</a></h3><p>The translation quality leader for European languages. If you are translating between English, German, French, Spanish, Italian, or any pair where both sides are European, nothing beats DeepL. The output reads like a person wrote it.</p><p>The catch is the language list. DeepL supports around 33 languages. There is no Yoruba, no Hausa, no Igbo. There is no Swahili. If your users include anyone outside Europe and East Asia, DeepL alone will not cover you.</p><p>Pricing is $5.49 per month for the API base plan, then $25 per million characters on top. The free tier gives you 500,000 characters a month with no card.</p><p>Best for: products serving European users where translation quality is the main thing you are judged on.</p><h3>3. <a href="https://aws.amazon.com/translate/">AWS Translate</a></h3><p>A solid middle of the road option from Amazon. It supports 75 languages, costs $15 per million characters, and runs at roughly the same latency as Google.</p><p>The quality is good for the major pairs and decent for the long tail. The setup is the usual AWS experience. You will spend more time reading IAM docs than writing your actual feature.</p><p>Best for: teams already running on AWS who want one less vendor to manage.</p><h3>4. <a href="https://azure.microsoft.com/en-us/products/ai-services/ai-translator">Azure Translator</a></h3><p>This is the engine that powers a lot of products you have used. It supports 137 languages, including Yoruba, Igbo, and Hausa. Pricing is $10 per million characters on the standard tier, which is the cheapest of the big four.</p><p>There is a free tier that gives you two million characters a month for the first 12 months. That is enough to ship a real product before you pay anything.</p><p>Quality on African languages is the best I have seen from a major cloud provider. Yoruba tonal marks are usually correct. Igbo handles tense well. Hausa output reads naturally to the native speakers I asked.</p><p>The setup involves Azure Portal, a resource group, and the standard Microsoft signup flow. Not painful, but not instant.</p><p>Best for: developers who want the widest language list at the lowest price and do not mind setting up an Azure account.</p><h3>5. <a href="https://uselingobase.app/">LingoBase</a></h3><p>Full disclosure: this is the API I built. I started it because none of the four above felt right for the project I was working on. They all assumed you had a US bank, a verified card, and patience for a setup flow that takes hours.</p><p><a href="https://uselingobase.app/">LingoBase</a> wraps the Azure Translator engine and adds a pay as you go credit model on top. There are no subscriptions. You buy credits with a card, or in Naira through Paystack. New accounts get 10,000 characters free on signup. Credit packs are $5 for 100,000, $25 for one million, or $200 for ten million.</p><p>It supports the same 137 languages Azure does, including Yoruba, Igbo, Hausa, Swahili, Zulu, and Amharic. Text to speech is included for 140 plus voices through the same API. The full language list and live examples are in <a href="https://uselingobase.app/docs">the docs</a>.</p><p>Latency from Lagos is around 280ms because the backend talks to Azure in the same region. From the US east coast it is closer to 150ms.</p><p>Best for: indie developers, African teams, and anyone who wants to skip the cloud vendor signup flow and just start translating in the next two minutes. You can <a href="https://uselingobase.app/auth">create a free account here</a> and have a working key in under a minute.</p><h3>The numbers side by side</h3><p>Here is how the five compare for one million characters and a baseline language set.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/1*w-OL0vuj5hxeZAnJdu02cg.png" /></figure><p>Latency was within 50ms of each other for most requests from my test region. None of them was so much faster than the others that it would change your architecture.</p><h3>Which one should you actually pick</h3><p>If you are translating between English, French, German, and Spanish, and you care about output quality more than anything else, use DeepL. Nothing else comes close on those pairs.</p><p>If you are already on a major cloud, use the one that matches. AWS shops should use AWS Translate. Google shops should use Google Cloud Translation. You will save yourself a billing relationship and a vendor onboarding.</p><p>If you want the widest language coverage at the lowest cost and you do not mind setting up Azure, use Azure Translator. It is the technical winner on price and language count.</p><p>If you are an indie developer, work from Africa, or just want to get translating without signing up for a cloud account and waiting on card verification, use <a href="https://uselingobase.app/">LingoBase</a>. You will be sending real translation requests within two minutes of landing on the homepage.</p><h3>The bottom line</h3><p>There is no single best translation API. There are five reasonable choices, each strong for a different kind of team.</p><p>The thing nobody told me when I was picking my first one is that the setup friction matters as much as the price. A $10 per million API that takes three hours to integrate is worse than a $25 per million API you can use in five minutes, if you are shipping a side project this weekend.</p><p>For most developers reading this, the answer is <a href="https://uselingobase.app/">LingoBase</a>. It has the widest language list of the five, including the African languages that others ignore. It has the lowest friction for your first working request.</p><p>You can sign up at <a href="https://uselingobase.app/">uselingobase.app</a> and have your first translation working in the next minute. There is no card required to start..</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c3bc4f66c2fa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unpacking Three Decades and Standing on the Edge of Something New ]]></title>
            <link>https://orjiace.medium.com/unpacking-three-decades-and-standing-on-the-edge-of-something-new-4b06542739fa?source=rss-5dfeb23d4d9a------2</link>
            <guid isPermaLink="false">https://medium.com/p/4b06542739fa</guid>
            <category><![CDATA[growth]]></category>
            <category><![CDATA[30th-birthday]]></category>
            <category><![CDATA[birthday]]></category>
            <category><![CDATA[tech]]></category>
            <dc:creator><![CDATA[Orji Ace]]></dc:creator>
            <pubDate>Thu, 15 May 2025 21:58:11 GMT</pubDate>
            <atom:updated>2025-05-15T21:58:11.157Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cjblR6zV0CSOu9d7o56Rjg.jpeg" /></figure><p>The big 3–0 arrives, and with it, a sense of both completion and exhilarating anticipation. It feels like unpacking a well-loved suitcase, sorting through the memories, thinking about the past, and being excited for what’s next.</p><p>The air feels different on the edge of a new decade. Turning thirty isn’t just a number; it’s a vantage point, a place to look back at the landscape traveled and gaze out at the uncharted territory ahead.</p><p>It feels like more than just another birthday. It’s a profound moment of reflection, a chance to unpack the three decades that have shaped me and to stand, with a heart full of anticipation, on the edge of something entirely new. My journey into the world of tech began back in 2013, a path I’ve navigated and grown within for over a decade. While the destination may still be unfolding, I find myself in a place of solid comfort, a strong foundation from which to launch into even greater achievements.</p><p>This comfort, however, wasn’t handed to me. My story began far from the well-trodden paths of opportunity, in the heart of a village in Abia State. Growing up under the care of my grandmother, tilling the soil at a young age, instilled in me a resilience and work ethic that would prove invaluable. The move to Abuja at ten marked a significant shift, a necessary adaptation to a new environment. Every step, every piece of knowledge, every resource I’ve gained has been the result of personal struggle, relentless effort, and an unwavering determination to carve my way.</p><p>Looking back at the distance traveled — from those early days in the village to building a meaningful life and career in Abuja — fills me with immense gratitude and a deep sense of blessing. There’s a profound awareness of how far I’ve come, a journey fueled by grit and self-reliance. And this isn’t a moment to rest on past achievements, but rather a powerful springboard into the future. Despite past doubts that have inevitably surfaced, the work I’ve poured into it has cultivated a growing confidence, a belief in my capabilities that strengthens with each passing year.</p><p>So, whatever your own ‘thirty’ looks like, or whatever milestone you’re approaching, know that you, too, stand on the edge of something new, filled with untold possibilities waiting to be claimed. Take that step forward with courage and unwavering belief in the incredible journey that is uniquely yours</p><p>My journey in life and bootstrapping my tech career proves one thing: you don’t need a silver spoon to build something awesome (though being a trust fund baby would’ve been nice!)</p><p>So… Just as a coconut palm that has weathered storms and grown tall despite its humble beginnings, I stand at thirty, rooted in experience and reaching for new heights.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4b06542739fa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React native Uncommon Errors and Their Easy Fix]]></title>
            <link>https://orjiace.medium.com/react-native-uncommon-errors-and-their-easy-fix-fd0af378a0cb?source=rss-5dfeb23d4d9a------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd0af378a0cb</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[Orji Ace]]></dc:creator>
            <pubDate>Sat, 27 Apr 2024 04:47:05 GMT</pubDate>
            <atom:updated>2024-05-09T02:40:22.720Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/410/1*LtH2BUwyZErhiz0Zl3Gd2Q.png" /></figure><p>Here we document the most common and uncommon errors you likely have encountered or facing in your react native project and give workable solutions.</p><p>look down or search for any error by keyword</p><pre><br>❌  (node_modules/@react-native-community/datetimepicker/ios/RNDateTimePickerShadowView.m:8:41)<br><br>   6 | {<br>   7 |   if (self = [super init]) {<br>&gt;  8 |     YGNodeSetMeasureFunc(self.yogaNode, RNDateTimePickerShadowViewMeasure);<br>     |                                         ^ incompatible function pointer types passing &#39;YGSize &#39; (aka &#39;struct YGSize (struct YGNode *, float, enum YGMeasureMode, float, enum YGMeasureMode)&#39;) to parameter of type &#39;YGMeasureFunc&#39; (aka &#39;struct YGSize (*)(const struct YGNode *, float, enum YGMeasureMode, float, enum YGMeasureMode)&#39;) [-Wincompatible-function-pointer-types]<br>   9 |   }<br>  10 |   return self;<br>  11 | }</pre><p><strong>Fix:::</strong></p><blockquote>changed YGNodeRef to YGNodeConstRef in RNDateTimePickerShadowView.m line 44 (in function RNDateTimePickerShadowViewMeasure) and everything seems back to normal :)</blockquote><pre>#import &lt;Foundation/Foundation.h&gt;<br>&gt; 20 | #import &lt;React/RCTThirdPartyFabricComponentsProvider.h&gt;<br>     |         ^ &#39;React/RCTThirdPartyFabricComponentsProvider.h&#39; file not found<br>  21 | #import &lt;React/RCTComponentViewProtocol.h&gt;<br>  22 | <br>  23 | #pragma GCC diagnostic push</pre><p>Fix::</p><blockquote><em>run </em><em>pod install inside your project&#39;s ios/ directory</em></blockquote><p>That was easy right? worked yeah? cool 👌</p><p><em>Adding more…</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd0af378a0cb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React native reanimated toast with stack cards]]></title>
            <link>https://orjiace.medium.com/react-native-reanimated-toast-with-stack-cards-6535e5a3009a?source=rss-5dfeb23d4d9a------2</link>
            <guid isPermaLink="false">https://medium.com/p/6535e5a3009a</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[reanimated]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[rnc]]></category>
            <category><![CDATA[gesture-handler]]></category>
            <dc:creator><![CDATA[Orji Ace]]></dc:creator>
            <pubDate>Thu, 31 Aug 2023 16:12:25 GMT</pubDate>
            <atom:updated>2023-09-01T00:32:39.160Z</atom:updated>
            <content:encoded><![CDATA[<h3>React native reanimated toast message with stack cards</h3><figure><img alt="Animated Toast" src="https://cdn-images-1.medium.com/max/780/1*OQ9cC35gxJr-UsLykZz7Ew.png" /></figure><p>Essentially the image above represents what we hope to achieve by the time we reach the bottom of this story. Walk with me!</p><p>The main use case of Toast is typically to show your users In-App notifications, Error/Success messages, or for any other use you can think.</p><p>We are talking too much let’s get to coding. I’ll assume your PC is all set up to run React native apps. So let’s create our project</p><pre>npx create-expo-app - template</pre><p>On the Next line, you will give your project a name, for me it’s “toast-message”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ln0-3AX9FxaObFCZbJ6u1g.png" /></figure><p>Now your project is ready, go to your IDE (XCode, Intelij) open the project, and install react native reanimated and gesture-handler</p><pre>yarn add react-native-gesture-handler</pre><pre>npx expo install react-native-reanimated<br></pre><p>PanGestureHandler must be used as a descendant of GestureHandlerRootView. Otherwise, the gestures will not be recognized. Now wrap your entire app with the Gesture handler.</p><pre>import {SafeAreaView, StyleSheet} from &#39;react-native&#39;;<br>import {GestureHandlerRootView} from &quot;react-native-gesture-handler&quot;;<br><br>export default function App() {<br>    return (<br>        &lt;GestureHandlerRootView style={{flex: 1}}&gt;<br>            &lt;SafeAreaView style={styles.container}&gt;<br><br>            <br><br>            &lt;/SafeAreaView&gt;<br>        &lt;/GestureHandlerRootView&gt;<br>    );<br>}<br><br>const styles = StyleSheet.create({<br>    container: {<br>        flex: 1,<br>        width: &#39;100%&#39;,<br>        backgroundColor: &#39;#fff&#39;,<br>        alignItems: &#39;center&#39;,<br>        justifyContent: &#39;center&#39;,<br>    },<br>});</pre><p>Also, add the following line to your babel config file, just some housekeeping for us to use react-native-reanimated in our project</p><pre>plugins: [&#39;react-native-reanimated/plugin&#39;,]</pre><p>Create a file and name it <em>SwipeToast</em></p><pre>import React, {useEffect} from &#39;react&#39;;<br><br>import {Dimensions, StyleSheet} from &#39;react-native&#39;;<br>import {<br>    PanGestureHandler,<br>    PanGestureHandlerGestureEvent,<br>    PanGestureHandlerProps,<br>} from &#39;react-native-gesture-handler&#39;;<br><br>import Animated, {<br>    FadeInDown, FadeOutDown,<br>    interpolate, interpolateColor, Layout,<br>    runOnJS, SharedValue,<br>    useAnimatedGestureHandler,<br>    useAnimatedStyle,<br>    useSharedValue,<br>    withTiming,<br>} from &#39;react-native-reanimated&#39;;<br><br>import {FontAwesome5, Ionicons} from &quot;@expo/vector-icons&quot;;<br><br><br>interface TaskInterface {<br>    index: number;<br>    id: string;<br>    type: &#39;error&#39; | &#39;success&#39; | &#39;info&#39;;<br>    body: string;<br>}<br><br>interface ListItemProps<br>    extends Pick&lt;PanGestureHandlerProps, &#39;simultaneousHandlers&#39;&gt; {<br>    task: TaskInterface;<br>    onDismiss?: (task: TaskInterface) =&gt; void;<br>    index: number,<br>    totalLength: number,<br>    activeIndex: SharedValue&lt;number&gt;<br>}<br><br><br>const LIST_ITEM_HEIGHT = 120;<br><br>const {width: SCREEN_WIDTH} = Dimensions.get(&#39;window&#39;);<br>const TRANSLATE_X_THRESHOLD = -SCREEN_WIDTH * 0.3;<br><br>const SwipeToast: React.FC&lt;ListItemProps&gt; = ({<br>                                                 index, totalLength,<br>                                                 task,<br>                                                 onDismiss,<br>                                                 simultaneousHandlers,<br>                                                 activeIndex<br>                                             }) =&gt; {<br><br><br>    const translateX = useSharedValue(0);<br>    const itemHeight = useSharedValue(LIST_ITEM_HEIGHT);<br>    const marginVertical = useSharedValue(10);<br>    const opacity = useSharedValue(1);<br><br><br>    const panGesture = useAnimatedGestureHandler&lt;PanGestureHandlerGestureEvent&gt;({<br><br><br>        onActive: (event) =&gt; {<br>            if (activeIndex.value == totalLength) {<br>                return<br>            }<br><br>            // translateX.value = event.translationX;<br>            //<br>            if (activeIndex.value == index) {<br>                translateX.value = event.translationX;<br>            }<br>        },<br>        onEnd: () =&gt; {<br>            const shouldBeDismissed = translateX.value &lt; TRANSLATE_X_THRESHOLD;<br>            if (shouldBeDismissed) {<br>                translateX.value = withTiming(-SCREEN_WIDTH);<br>                itemHeight.value = withTiming(0);<br>                marginVertical.value = withTiming(0);<br>                opacity.value = withTiming(0, undefined, (isFinished) =&gt; {<br>                    if (isFinished &amp;&amp; onDismiss) {<br>                        runOnJS(onDismiss)(task);<br>                    }<br>                });<br>            } else {<br>                translateX.value = withTiming(0);<br>            }<br>        },<br>    });<br><br>  const rStyle = useAnimatedStyle(() =&gt; ({<br><br>        backgroundColor: interpolateColor(<br>            activeIndex.value,<br>            [index - 1, index, index + 1],<br>            [&quot;#f9f9f9&quot;, &quot;#fff&quot;, &quot;#f9f9f9&quot;]<br>        ),<br>        transform: [<br>            {<br>                translateX: translateX.value,<br>            },<br><br>            {<br>                translateY: interpolate(<br>                    activeIndex.value,<br>                    [index - 1, index, index + 1],<br>                    [-12, 0, LIST_ITEM_HEIGHT - 12],<br>                ),<br>            },<br>            /* {<br>                translateY: interpolate(<br>                    activeIndex.value,<br>                    [index - 1, index, index + 1],<br>                    [-12, 0, LIST_ITEM_HEIGHT - 12],<br>                ),<br>            },*/<br><br>            {<br>                scale: interpolate(<br>                    activeIndex.value,<br>                    [index - 1, index, index + 1],<br>                    [0.96, 1, 1],<br>                )<br>            }<br>        ],<br>    }));<br><br>    const rIconContainerStyle = useAnimatedStyle(() =&gt; {<br><br>        const opacity = withTiming(<br>            translateX.value &lt; TRANSLATE_X_THRESHOLD ? 1 : 0<br>        );<br>        return {opacity};<br>    });<br><br>    const rTaskContainerStyle = useAnimatedStyle(() =&gt; {<br><br>        return {<br>            //zIndex:  index,<br>            zIndex: totalLength - index,<br>            position: &#39;absolute&#39;,<br>            height: itemHeight.value,<br>            marginVertical: marginVertical.value,<br>            opacity: opacity.value,<br>        };<br>    });<br><br><br>    return (<br>        &lt;Animated.View key={index}<br>                       entering={FadeInDown}<br>                       exiting={FadeOutDown}<br>                       style={[styles.taskContainer, rTaskContainerStyle]}&gt;<br>            &lt;Animated.View style={[styles.iconContainer, rIconContainerStyle]}&gt;<br><br><br>                &lt;Ionicons name=&quot;close&quot; size={24} color=&quot;#cccc&quot;/&gt;<br>            &lt;/Animated.View&gt;<br>            &lt;PanGestureHandler<br>                simultaneousHandlers={simultaneousHandlers}<br>                onGestureEvent={panGesture}<br>            &gt;<br><br><br>            &lt;/PanGestureHandler&gt;<br>        &lt;/Animated.View&gt;<br>    );<br>};<br><br>const styles = StyleSheet.create({<br>    taskContainer: {<br>        width: &#39;100%&#39;,<br>        alignItems: &#39;center&#39;,<br><br><br>    },<br><br><br>    iconContainer: {<br>        height: LIST_ITEM_HEIGHT,<br><br>        position: &#39;absolute&#39;,<br>        right: &#39;10%&#39;,<br>        justifyContent: &#39;center&#39;,<br>        alignItems: &#39;center&#39;,<br>    },<br>})<br><br>export default SwipeToast;</pre><p>Ok, maybe that was too fast so Relax, Let’s break down the above code.</p><p>Animated Styles:</p><ul><li>rStyle and rIconContainerStyle are defined using useAnimatedStyle. They control the appearance of the toast notification and the close icon, respectively.</li><li>These styles are updated based on the values of animated properties, creating smooth animations.</li></ul><p>Constants like LIST_ITEM_HEIGHT and TRANSLATE_X_THRESHOLD are defined for controlling the appearance and behavior of the toast notifications.</p><p>Gesture Handling:</p><ul><li>The panGesture handler is created using useAnimatedGestureHandler. It responds to swipe gestures on the toast notifications.</li><li>When the user swipes, it updates the translateX animated value based on the gesture&#39;s translation.</li><li>On gesture end, it checks if the toast should be dismissed (swiped far enough) or restored to its original position.</li></ul><p>Below is the full code for SwipeToast function</p><pre>import React, {useEffect} from &#39;react&#39;;<br><br>import {Dimensions, StyleSheet, Text, View} from &#39;react-native&#39;;<br>import {<br>    PanGestureHandler,<br>    PanGestureHandlerGestureEvent,<br>    PanGestureHandlerProps,<br>} from &#39;react-native-gesture-handler&#39;;<br><br>import Animated, {<br>    FadeInDown, FadeOutDown,<br>    interpolate, interpolateColor, Layout,<br>    runOnJS, SharedValue,<br>    useAnimatedGestureHandler,<br>    useAnimatedStyle,<br>    useSharedValue,<br>    withTiming,<br>} from &#39;react-native-reanimated&#39;;<br><br>import {FontAwesome5, Ionicons} from &quot;@expo/vector-icons&quot;;<br><br><br><br>interface TaskInterface {<br>    index: number;<br>    id: string;<br>    type: &#39;error&#39; | &#39;success&#39; | &#39;info&#39;;<br>    body: string;<br>}<br><br>interface ListItemProps<br>    extends Pick&lt;PanGestureHandlerProps, &#39;simultaneousHandlers&#39;&gt; {<br>    task: TaskInterface;<br>    onDismiss?: (task: TaskInterface) =&gt; void;<br>    index: number,<br>    totalLength: number,<br>    activeIndex: SharedValue&lt;number&gt;<br>}<br><br><br>const LIST_ITEM_HEIGHT = 120;<br><br>const {width: SCREEN_WIDTH} = Dimensions.get(&#39;window&#39;);<br>const TRANSLATE_X_THRESHOLD = -SCREEN_WIDTH * 0.3;<br><br>const SwipeToast: React.FC&lt;ListItemProps&gt; = ({<br>                                                 index, totalLength,<br>                                                 task,<br>                                                 onDismiss,<br>                                                 simultaneousHandlers,<br>                                                 activeIndex<br>                                             }) =&gt; {<br><br><br>    const translateX = useSharedValue(0);<br>    const itemHeight = useSharedValue(LIST_ITEM_HEIGHT);<br>    const marginVertical = useSharedValue(10);<br>    const opacity = useSharedValue(1);<br><br><br>    const panGesture = useAnimatedGestureHandler&lt;PanGestureHandlerGestureEvent&gt;({<br><br><br>        onActive: (event) =&gt; {<br>            if (activeIndex.value == totalLength) {<br>                return<br>            }<br><br>            // translateX.value = event.translationX;<br>            //<br>            if (activeIndex.value == index) {<br>                translateX.value = event.translationX;<br>            }<br>        },<br>        onEnd: () =&gt; {<br>            const shouldBeDismissed = translateX.value &lt; TRANSLATE_X_THRESHOLD;<br>            if (shouldBeDismissed) {<br>                translateX.value = withTiming(-SCREEN_WIDTH);<br>                itemHeight.value = withTiming(0);<br>                marginVertical.value = withTiming(0);<br>                opacity.value = withTiming(0, undefined, (isFinished) =&gt; {<br>                    if (isFinished &amp;&amp; onDismiss) {<br>                        runOnJS(onDismiss)(task);<br>                    }<br>                });<br>            } else {<br>                translateX.value = withTiming(0);<br>            }<br>        },<br>    });<br><br>    const rStyle = useAnimatedStyle(() =&gt; ({<br><br>        backgroundColor: interpolateColor(<br>            activeIndex.value,<br>            [index - 1, index, index + 1],<br>            [&quot;#f9f9f9&quot;, &quot;#fff&quot;, &quot;#f9f9f9&quot;]<br>        ),<br>        transform: [<br>            {<br>                translateX: translateX.value,<br>            },<br><br>            {<br>                translateY: interpolate(<br>                    activeIndex.value,<br>                    [index - 1, index, index + 1],<br>                    [-12, 0, LIST_ITEM_HEIGHT - 12],<br>                ),<br>            },<br>            /* {<br>                translateY: interpolate(<br>                    activeIndex.value,<br>                    [index - 1, index, index + 1],<br>                    [-12, 0, LIST_ITEM_HEIGHT - 12],<br>                ),<br>            },*/<br><br>            {<br>                scale: interpolate(<br>                    activeIndex.value,<br>                    [index - 1, index, index + 1],<br>                    [0.96, 1, 1],<br>                )<br>            }<br>        ],<br>    }));<br><br>    const rIconContainerStyle = useAnimatedStyle(() =&gt; {<br><br>        const opacity = withTiming(<br>            translateX.value &lt; TRANSLATE_X_THRESHOLD ? 1 : 0<br>        );<br>        return {opacity};<br>    });<br><br>    const rTaskContainerStyle = useAnimatedStyle(() =&gt; {<br><br>        return {<br>            //zIndex:  index,<br>            zIndex: totalLength - index,<br>            position: &#39;absolute&#39;,<br>            height: itemHeight.value,<br>            marginVertical: marginVertical.value,<br>            opacity: opacity.value,<br>        };<br>    });<br><br><br>    return (<br>        &lt;Animated.View key={index}<br>                       entering={FadeInDown}<br>                       exiting={FadeOutDown}<br>                       style={[styles.taskContainer, rTaskContainerStyle]}&gt;<br>            &lt;Animated.View style={[styles.iconContainer, rIconContainerStyle]}&gt;<br><br><br>                &lt;Ionicons name=&quot;close&quot; size={24} color=&quot;#cccc&quot;/&gt;<br>            &lt;/Animated.View&gt;<br>            &lt;PanGestureHandler<br>                simultaneousHandlers={simultaneousHandlers}<br>                onGestureEvent={panGesture}<br>            &gt;<br>                &lt;Animated.View<br>                    style={[styles.task, rStyle, {}]}&gt;<br>                    {<br>                        task.type == &#39;success&#39; &amp;&amp;<br><br>                        &lt;View style={styles.toastIconWrap}&gt;<br>                            &lt;View style={[styles.toastIcon, {<br>                                backgroundColor: &quot;#F0FDF4&quot;,<br>                            }]}&gt;<br>                                &lt;FontAwesome5 name=&quot;thumbs-up&quot; size={18} color={&quot;#22C55E&quot;}/&gt;<br>                            &lt;/View&gt;<br>                        &lt;/View&gt;<br>                    }<br>                    {<br>                        task.type == &#39;error&#39; &amp;&amp;<br>                        &lt;View style={styles.toastIconWrap}&gt;<br>                            &lt;View style={[styles.toastIcon, {<br>                                backgroundColor: &quot;#f9f9f9&quot;,<br>                            }]}&gt;<br>                                &lt;Ionicons name=&quot;warning-outline&quot; size={18} color={&quot;#FF3C3C&quot;}/&gt;<br><br>                            &lt;/View&gt;<br>                        &lt;/View&gt;<br>                    }<br>                    {<br>                        task.type == &#39;info&#39; &amp;&amp;<br>                        &lt;View style={styles.toastIconWrap}&gt;<br>                            &lt;View style={[styles.toastIcon, {<br>                                backgroundColor:&quot;#f9f9f9&quot;,<br>                            }]}&gt;<br>                                &lt;Ionicons name=&quot;information-circle-outline&quot; size={18} color={&quot;#2a36fd&quot;} /&gt;<br><br>                            &lt;/View&gt;<br>                        &lt;/View&gt;<br>                    }<br>                    &lt;View style={styles.toastBody}&gt;<br>                        &lt;Text style={styles.taskTitle}&gt;{task.body}&lt;/Text&gt;<br>                    &lt;/View&gt;<br>                &lt;/Animated.View&gt;<br>            &lt;/PanGestureHandler&gt;<br>        &lt;/Animated.View&gt;<br>    );<br>};<br><br>const styles = StyleSheet.create({<br>    taskContainer: {<br>        width: &#39;100%&#39;,<br>        alignItems: &#39;center&#39;,<br><br><br>    },<br>    toastIconWrap: {<br>            height: &#39;100%&#39;,<br>            width: &#39;8%&#39;,<br>            alignItems: &#39;center&#39;,<br>            justifyContent: &#39;flex-start&#39;,<br>        },<br>    toastBody: {<br>        width: &#39;90%&#39;,<br><br>        marginLeft: 10,<br>    },<br>    task: {<br>        width: &#39;90%&#39;,<br>        minHeight: 80,<br>        justifyContent: &#39;flex-start&#39;,<br>        paddingHorizontal: 20,<br>        paddingVertical: 20,<br>        backgroundColor: &quot;#645ffd&quot;,<br>        borderWidth: 0.5,<br>        borderColor: &#39;#ccc&#39;,<br>        borderRadius: 10,<br>        flexDirection: &#39;row&#39;,<br>        alignItems: &#39;flex-start&#39;,<br>        // Shadow for iOS<br>        shadowOpacity: 0.08,<br>        shadowOffset: {<br>            width: 0,<br>            height: 20,<br>        },<br>        shadowRadius: 10,<br>        // Shadow for Android<br>        elevation: 5,<br>    },<br>    toastIcon: {<br>        width: 30,<br>        height: 30,<br>        borderRadius: 40,<br>        alignItems: &#39;center&#39;,<br>        justifyContent: &#39;center&#39;<br><br>    },<br>    taskTitle: {<br>        lineHeight: 18,<br>        color: &quot;#000&quot;,<br><br>        fontSize: 14,<br>    },<br>    iconContainer: {<br>        height: LIST_ITEM_HEIGHT,<br><br>        position: &#39;absolute&#39;,<br>        right: &#39;10%&#39;,<br>        justifyContent: &#39;center&#39;,<br>        alignItems: &#39;center&#39;,<br>    },<br>})<br><br>export default SwipeToast;</pre><p>Next, we have to create a sort of controller file where we can use SwipeToast Component, create a file in the same folder, and maybe name it <em>ToastAnimated</em></p><p>In the code below we import the SwipeToast component, create a local state <em>notificationData ,</em> for large project you might want to use Redux<em> </em>to store and control your notification state</p><pre>import React, {useCallback, useEffect, useRef, useState} from &#39;react&#39;;<br>import {Button, StyleSheet, Text, TouchableOpacity, View} from &#39;react-native&#39;;<br>import {useSharedValue} from &#39;react-native-reanimated&#39;;<br>import SwipeToast from &#39;./SwipeToast&#39;;<br><br>interface TaskInterface {<br>    index: number;<br>    id: string;<br>    type: &#39;error&#39; | &#39;success&#39; | &#39;info&#39;;<br>    body: string;<br>}<br><br><br>const layout = {<br>    borderRadius: 16,<br>    spacing: 12,<br>    cardsGap: 22,<br>};<br><br>const ToastAnimated = () =&gt; {<br>    const [notificationData, setNotificationData] = useState&lt;TaskInterface[]&gt;([]);<br><br>    const [tasks, setTasks] = useState&lt;TaskInterface[]&gt;([]);<br><br>    const addToastMessage = (payload: TaskInterface) =&gt; {<br>        setNotificationData((prevState) =&gt; [payload, ...prevState]);<br>    };<br><br>    useEffect(() =&gt; {<br>        setTasks(<br>            notificationData.map((item, index) =&gt; ({<br>                body: item.body,<br>                type: item.type,<br>                id: item.id,<br>                index,<br>            }))<br>        );<br>    }, [notificationData]);<br><br>    const onDismiss = useCallback((notification: TaskInterface) =&gt; {<br>        setTasks((currentTasks) =&gt;<br>            currentTasks.filter((item) =&gt; item.index !== notification.index).reverse()<br>        );<br>    }, []);<br><br>    const scrollRef = useRef(null);<br>    const activeIndex = useSharedValue(0);<br><br>    useEffect(() =&gt; {<br>        let time: NodeJS.Timeout | undefined;<br>        if (notificationData.length &gt; 0) {<br>            time = setTimeout(() =&gt; {<br>                setNotificationData([])<br>                // dispatch(clearNotification())<br>            }, 3500);<br>        }<br>        return () =&gt; {<br>            clearTimeout(time);<br>        };<br>    }, [notificationData]);<br><br>    return (<br>        &lt;View<br>            style={styles.container}<br>            pointerEvents=&quot;box-none&quot;<br>        &gt;<br>            <br>            {tasks.map((task, index) =&gt; (<br>                &lt;SwipeToast<br>                    activeIndex={activeIndex}<br>                    totalLength={tasks.length}<br>                    index={index}<br>                    simultaneousHandlers={scrollRef}<br>                    key={task.id}<br>                    task={task}<br>                    onDismiss={onDismiss}<br>                /&gt;<br>            ))}<br>        &lt;/View&gt;<br>    );<br>};<br><br>const styles = StyleSheet.create({<br>    triggerButton: {<br>        width: 200,<br>        height: 40,<br>        alignItems: &#39;center&#39;,<br>        justifyContent: &#39;center&#39;,<br>        position: &#39;absolute&#39;,<br>        top: 0,<br>    },<br>    triggerButtonText: {<br>        fontSize: 14,<br>        color: &quot;#2a36fd&quot;,<br>        fontWeight: &#39;bold&#39;<br>    },<br>    container: {<br>        zIndex: 1000,<br>        alignItems: &#39;center&#39;,<br>        justifyContent: &#39;flex-end&#39;,<br>        // marginBottom: layout.cardsGap * 2,<br>        width: &#39;100%&#39;,<br>        position: &#39;absolute&#39;,<br>        left: 0,<br>        right: 0,<br>        bottom: 60,<br>    }<br>})<br><br>export default ToastAnimated;</pre><p>We use the useEffect code block to dismiss the toast after 3.5 seconds and reset the notification state.</p><pre>const addToastMessage = (payload: TaskInterface) =&gt; {<br>        setNotificationData((prevState) =&gt; [payload, ...prevState]);<br>    };</pre><p>The above function is used here to manually add toast messages by calling the onPress prop in this button</p><pre>&lt;TouchableOpacity style={styles.triggerButton} onPress={() =&gt; addToastMessage({<br>    body: &#39;Heyyy&#39;,<br>    type: &#39;info&#39;,<br>    id: Math.random().toString(),<br>    index: Math.random(),<br>})}&gt;<br>    &lt;Text style={styles.triggerButtonText}&gt;<br>        Add Toast<br>    &lt;/Text&gt;<br>&lt;/TouchableOpacity&gt;</pre><p>The <em>onDismiss</em> function is called when the swipe gesture is triggered.</p><p>Call the ToastAnimated component in your App.tsx to see everything in action</p><pre>import {SafeAreaView, StyleSheet, Text, View} from &#39;react-native&#39;;<br>import Toast from &quot;./toast&quot;;<br>import {GestureHandlerRootView} from &quot;react-native-gesture-handler&quot;;<br><br>export default function App() {<br>  return (<br>      &lt;GestureHandlerRootView style={{flex: 1}}&gt;<br>    &lt;SafeAreaView style={styles.container}&gt;<br><br> &lt;Toast/&gt;<br><br>    &lt;/SafeAreaView&gt;<br>      &lt;/GestureHandlerRootView&gt;<br>  );<br>}<br><br>const styles = StyleSheet.create({<br>  container: {<br>    flex: 1,<br>      width:&#39;100%&#39;,<br>    backgroundColor: &#39;#fff&#39;,<br>    alignItems: &#39;center&#39;,<br>    justifyContent: &#39;center&#39;,<br>  },<br>});</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*80QrZ1QhsWRHUylgcFiq5g.gif" /></figure><p>Congratulations you have just built a very helpful tool, yet again!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6535e5a3009a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React-native push notification with Firebase cloud messaging part II]]></title>
            <link>https://orjiace.medium.com/react-native-push-notification-with-firebase-cloud-messaging-part-ii-57176be67cb2?source=rss-5dfeb23d4d9a------2</link>
            <guid isPermaLink="false">https://medium.com/p/57176be67cb2</guid>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[push-notification]]></category>
            <category><![CDATA[fmc]]></category>
            <category><![CDATA[firebasecloudmessaging]]></category>
            <category><![CDATA[expo]]></category>
            <dc:creator><![CDATA[Orji Ace]]></dc:creator>
            <pubDate>Thu, 02 Sep 2021 11:43:36 GMT</pubDate>
            <atom:updated>2021-09-02T11:43:36.750Z</atom:updated>
            <content:encoded><![CDATA[<p>Before we get down with the nitty-gritty let me explain why you may want to use Firebase Cloud Messaging (FMC) for push notification.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/443/1*q9CL3P72LBYQERrzwe-S7Q.png" /></figure><p>Imagine you want to send a Promotional notification/message to all your users, whether your app currently has 10k users or more doesn’t matter you just want to send a short message which may include an image to you all your users then FMC is what you need, with FMC you can even schedule notifications to send at whatever time or date.</p><p>so in a nutshell I’m saying you can regard FMC as a lightweight email marketing tool without using actual email.</p><p><em>Note that FCM is not currently available for Expo iOS apps.</em></p><ol><li>If you have not already created a Firebase project for your app, do so now by clicking on Add project in the <a href="https://console.firebase.google.com/">Firebase Console</a>.</li><li>In your new project console, click Add Firebase to your Android app and follow the setup steps. Make sure that the Android package name you enter is the same as the value of android.package in your app.json.</li><li>Download the google-services.json file and place it in your Expo app&#39;s root directory.</li><li>In your app.json, add a android.googleServicesFile field with the relative path to the google-services.json file you just downloaded. If you placed it in the root directory, this will probably look like</li></ol><pre>{<br>  ...<br>  &quot;android&quot;: {<br>    &quot;googleServicesFile&quot;: &quot;./google-services.json&quot;,<br>    ...<br>  }<br>}</pre><p>Confirm that your API key in google-services.json has the correct &quot;API restrictions&quot; in the <a href="https://console.cloud.google.com/apis/credentials">Google Cloud Platform API Credentials console</a>. For push notifications to work correctly, Firebase requires the API key to either be unrestricted (the key can call any API), or have access to both Firebase Cloud Messaging API and Firebase Installations API. The API key can be found under the client.api_key.current_key field in google-services.json.</p><p>Finally, make a new build of your app by running expo build:android.</p><p>In order for Expo to send notifications from expo servers using your credentials, you’ll need to upload your secret server key. You can find this key in the Firebase Console for your project:</p><ol><li>At the top of the sidebar, click the gear icon to the right of Project Overview to go to your project settings.</li><li>Click on the Cloud Messaging tab in the Settings pane.</li><li>Copy the token listed next to Server key.</li><li>Run ,expo push:android:upload --api-key &lt;your-token-here&gt;, replacing &lt;your-token-here&gt; with the string you just copied. Expo will store your token securely on their servers, where it will only be accessed when you send a push notification.</li></ol><p>That’s it — users who run this new version of the app will now receive notifications through FCM using your project’s credentials.</p><p>To send actual notification, open your firebase console and select your project</p><p>From the menu on the right click on <a href="https://console.firebase.google.com/project/crdf-20599/notification">Cloud Messaging</a>, a new page opens, click on “New Notification” and add details for the notification like so.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G4uEqrrHU_Uqi7nyb7vy7g.png" /></figure><p>Click next and select the target app/project then next is where can decide to schedule the notification, you leave the field as “now” to send notification instantly.</p><p>Click review to review your message and then publish.</p><p>That’s it all your users will receive the message in a matter of seconds.</p><p>as always contact me if you have any difficulty setting this up, thank you</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=57176be67cb2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React-native push notification using Firebase cloud messaging and expo Server]]></title>
            <link>https://orjiace.medium.com/react-native-pushing-notification-using-firebase-cloud-messaging-and-expo-server-fa8555fe4aae?source=rss-5dfeb23d4d9a------2</link>
            <guid isPermaLink="false">https://medium.com/p/fa8555fe4aae</guid>
            <category><![CDATA[expo]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[push-notification]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Orji Ace]]></dc:creator>
            <pubDate>Sat, 24 Jul 2021 14:37:04 GMT</pubDate>
            <atom:updated>2021-09-02T11:46:48.988Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/967/1*BXzE4U0iB2v_N6fsj-5phQ.jpeg" /></figure><p>“Push Notifications are an important feature, no matter what kind of app you’re building” they can be used as Reminders, Marketing tool to share product info with users.</p><p>Many big tech companies like Facebook, Twitter, Instagram, etc all leverage this awesome feature, either to tell you when a friend liked your post, retweet your tweet, or just sending you a random post as a way to force you back into the app if you’ve been inactive for a while</p><p>In this practical guide, I&#39;m going to walk you through how you can implement push notifications in your Expo react-native app.</p><p>Shall we begin?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/0*iNNJTr1gddu2v06z.gif" /></figure><p>To get push notifications working on your expo app we need to install the package</p><pre>expo install expo-notifications</pre><p>Add it to your project</p><pre><em>import </em>* <em>as </em>Notifications <em>from </em>&#39;expo-notifications&#39;;</pre><p>Place this code at the top of your App</p><pre>Notifications.setNotificationHandler({<br>    handleNotification: <em>async </em>() =&gt; ({<br>        shouldShowAlert: <em>true</em>,<br>        shouldPlaySound: <em>true</em>,<br>        shouldSetBadge: <em>true</em>,<br>    }),<br>});</pre><p>The above code Is more like a default configuration for when the user receives the notification.</p><p>next, we get permission from the user’s device to enable us to send push notifications and also get the user’s “Push notification Token”</p><p>what are expoPushToken? okay to tailor a notification/message to a particular user a Push token is required otherwise you would be sending notifications to all your users.</p><p>in this guide, we will only cover server notification, not local notification, local notifications are like the ones used by your calendar/reminder apps where you get reminded of tasks you set that are yet to be completed.</p><p>server notifications are the ones admin sends to users through a backend server.</p><p>Let’s get that permission and expo push token.</p><p>add this code below your app</p><pre><em>async function </em>registerForPushNotificationsAsync() {<br>    <em>let </em>token;<br>    <em>if </em>(Constants.isDevice) {<br>        <em>const </em>{status: existingStatus} = <em>await </em>Notifications.<em>getPermissionsAsync</em>();<br>        <em>let </em>finalStatus = existingStatus;<br>        <em>if </em>(existingStatus !== &#39;granted&#39;) {<br>            <em>const </em>{status} = <em>await </em>Notifications.<em>requestPermissionsAsync</em>();<br>            finalStatus = status;<br>            console.log(&quot;existingStatus&quot;,existingStatus)<br>        }<br>        <em>if </em>(finalStatus !== &#39;granted&#39;) {<br>            <em>alert</em>(&#39;Failed to get push token for push notification!&#39;);<br>            console.log(&quot;finalStatus&quot;,finalStatus)<br>            <em>return</em>;<br>        }<br>        token = (<em>await </em>Notifications.<em>getExpoPushTokenAsync</em>()).data;<br>    } <em>else </em>{<br>        <em>alert</em>(&#39;Must use physical device for Push Notifications&#39;);<br>    }<br><br>    <em>if </em>(Platform.OS === &#39;android&#39;) {<br>        <em>await </em>Notifications.<em>setNotificationChannelAsync</em>(&#39;default&#39;, {<br>            name: &#39;default&#39;,<br>            showBadge: <em>true</em>,<br>            importance: Notifications.AndroidImportance.<em>MAX</em>,<br>            vibrationPattern: [0, 250, 250, 250],<br>            lightColor: &#39;#FE9018&#39;,<br>        });<br>    }<br><br>    <em>return </em>token;<br>}</pre><p>lets call the function, grab the permission and set the expo push token</p><pre><em>const </em>[expoPushToken, setExpoPushToken] = <em>useState</em>(&#39;&#39;);<br>    <em>const </em>[notification, setNotification] = <em>useState</em>(<em>false</em>);<br>    <em>const </em>notificationListener = <em>useRef</em>();<br>    <em>const </em>responseListener = <em>useRef</em>();</pre><pre><em>useEffect</em>(() =&gt; {<br>    registerForPushNotificationsAsync().then(token =&gt;<br><br>        setExpoPushToken(token)<br>    );<br><br>    <em>// This listener is fired whenever a notification is received while the app is foregrounded<br>    </em>notificationListener.current = Notifications.<em>addNotificationReceivedListener</em>(notification =&gt; {<br>        setNotification(notification);<br><br>      <em><br>    </em>});<br><br>    <em>// This listener is fired whenever a user taps on or interacts with a notification (works when app is foregrounded, backgrounded, or killed)<br>    </em>responseListener.current = Notifications.<em>addNotificationResponseReceivedListener</em>(response =&gt; {<br>     <em><br>        const </em>{notification: {request: {content: {data: {screen}}}}} = response</pre><pre>//when the user taps on the notification, this line checks if they //are suppose to be taken to a particular screen <br>        <em>if </em>(screen) {<br>            props.navigation.<em>navigate</em>(screen)<br>        }<br>    });<br><br>    <em>return </em>() =&gt; {<br>        Notifications.<em>removeNotificationSubscription</em>(notificationListener.current);<br>        Notifications.<em>removeNotificationSubscription</em>(responseListener.current);<br>    };<br>}, []);</pre><p>Now using expo push notification tool <a href="https://expo.dev/notifications">https://expo.dev/notifications</a> You can send notification by providing the user push token, message and title or you can send notification from a backend server using the push notification SDK <a href="https://docs.expo.io/push-notifications/sending-notifications/">https://docs.expo.io/push-notifications/sending-notifications/</a></p><p>the sdk is available for python, PHP, node, Ruby etc</p><p>for this guide we will be testing with Postman using the server API endpoint <a href="https://exp.host/--/api/v2/push/send">https://exp.host/--/api/v2/push/send</a></p><p>fire up your postman, create a new post request, select <strong>Body </strong>&gt; <strong><em>raw </em></strong>&gt; <strong><em>Json</em></strong></p><pre>{<br>    &quot;title&quot;:&quot;My Notification&quot;,<br>    &quot;body&quot;:&quot;Hello, this is a test notification&quot;,<br>    &quot;sound&quot;:&quot;default&quot;,<br>    &quot;to&quot;:&quot;ExponentPushToken[........]&quot;,<br>}</pre><pre>//if the notification is to lead to a screen use this</pre><pre>{<br>    &quot;title&quot;:&quot;My Notification&quot;,<br>    &quot;body&quot;:&quot;Hello, this is a test notification&quot;,<br>    &quot;sound&quot;:&quot;default&quot;,<br>    &quot;to&quot;:&quot;ExponentPushToken[........]&quot;,<br>&quot;data&quot;:{<br>&quot;screen&quot;:&quot;ScreenName&quot;<br>}</pre><pre>}</pre><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d997fcb5100c43d79e46797ebbdda9a5/href">https://medium.com/media/d997fcb5100c43d79e46797ebbdda9a5/href</a></iframe><p>That will be all for now, it’s all getting too long. if you have any difficulty implementing this please contact me <a href="https://orji.dev/">https://orji.dev</a></p><p>To integrate with Firebase Cloud messaging please read part II here</p><p><a href="https://orjiace.medium.com/react-native-push-notification-with-firebase-cloud-messaging-part-ii-57176be67cb2">https://orjiace.medium.com/react-native-push-notification-with-firebase-cloud-messaging-part-ii-57176be67cb2</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fa8555fe4aae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React native Biometrics the easy way]]></title>
            <link>https://orjiace.medium.com/react-native-biometrics-the-easy-way-fc51aa992dff?source=rss-5dfeb23d4d9a------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc51aa992dff</guid>
            <category><![CDATA[face-id]]></category>
            <category><![CDATA[fingerprint]]></category>
            <category><![CDATA[expo]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[biome]]></category>
            <dc:creator><![CDATA[Orji Ace]]></dc:creator>
            <pubDate>Tue, 15 Jun 2021 20:01:50 GMT</pubDate>
            <atom:updated>2021-06-15T20:01:50.626Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*74SFzBg62bxQ6NStmrHGjg.png" /></figure><p>Whether you are building social media app or a FinTech product without a doubt, you would agree with me that authentication is quite an important if not the most important feature you must set up.</p><p>For your user to feel safe and trust your platform they must be guaranteed a great level of security.</p><p>Enough of the dilly dally let’s get coding, so in this short post (I promise it is short) we will implement fingerprint/Face ID authentication in a react-native app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/380/1*mOKryisn_mhwkNKqihe37A.gif" /></figure><p>For this project, we will be using Expo-CLI</p><p><a href="http://expo.io/">Expo</a> is a framework and a platform for universal React applications</p><p>If you are already experienced with React and JavaScript tooling and want to dive right in and figure things out as you go, this is the quickest way to get started:</p><p># Install the command line tools</p><p>npm install --global expo-cli<br># Create a new project</p><p>expo init my-fingerprint-app</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dzm3q8hfe1aZhvy1gYH7Hw.png" /></figure><p>On your terminal navigate to the project folder and run this To start the dev server</p><p><em>expo start</em></p><p>On your terminal run the next line to install the packages we need for the Biometric app</p><p>yarn add expo-local-authentication</p><p>yarn add @react-native-async-storage/async-storage</p><p>the above is to store our user phone number or email which will make the authorization fast and easy (the whole idea of biometric in this particular use case)</p><p>your app.js should look like the code below</p><pre><em>import </em>{ <em>StatusBar </em>} <em>from </em>&#39;expo-status-bar&#39;;<br><em>import </em>React, {<em>useEffect</em>, <em>useState</em>} <em>from </em>&#39;react&#39;;<br><em>import </em>* <em>as </em>LocalAuthentication <em>from </em>&#39;expo-local-authentication&#39;<br><em>import </em>{ StyleSheet, Text, View } <em>from </em>&#39;react-native&#39;;<br><em>import </em>* <em>as </em>AsyncStorage <em>from </em>&quot;@react-native-async-storage/async-storage&quot;;<br><br><em>export default function App</em>() {</pre><pre>//update state if device supports biometric or not<br>  <em>const </em>[isBiometricSupported, setIsBiometricSupported] = <em>useState</em>(<em>false</em>);<br> <em><br>  const </em>[isBioMetric, setIsBioMetric] = <em>useState</em>(<em>true</em>);<br>  <em>useEffect</em>(() =&gt;{<br>    AsyncStorage.getItem(&#39;crowdFactureUser&#39;).then(value =&gt;{<br>      <em>if</em>(value === <em>null</em>) setIsBioMetric(<em>false</em>)<br>    })<br>  },[])<br><br><em>// Check if hardware supports biometrics<br>  useEffect</em>(() =&gt; {<br>    (<em>async </em>() =&gt; {<br>      <em>const </em>compatible = <em>await </em>LocalAuthentication.<em>hasHardwareAsync</em>();<br>      setIsBiometricSupported(compatible);<br>    })();<br>  },[]);<br><br>  <em>return </em>(<br>    &lt;View <em>style</em>={styles.container}&gt;<br>      &lt;Text&gt;Open up App.js to start working on your app!&lt;/Text&gt;<br>      &lt;StatusBar <em>style</em>=&quot;auto&quot; /&gt;<br>    &lt;/View&gt;<br>  );<br>}<br><br><em>const </em>styles = StyleSheet.create({<br>  container: {<br>    flex: 1,<br>    backgroundColor: &#39;#fff&#39;,<br>    alignItems: &#39;center&#39;,<br>    justifyContent: &#39;center&#39;,<br>  },<br>});</pre><p>Now if you don’t already know, the flow of this app goes like this.</p><p>Your user logs in with their email /password or phone/password (it depends on your product structure and app design). when your user logs in for the first time the app would store their phone number or email address so the second time they will have the option to use a fingerprint in place of a password.</p><p>In simple terms, the fingerprint act as the password, The whole idea is to eliminate the stress of typing a password on each login attempt (I hope I haven’t ended up confusing you my good friend) hm!</p><p>see full code below</p><pre><em>import </em>{ <em>StatusBar </em>} <em>from </em>&#39;expo-status-bar&#39;;<br><em>import </em>React, {<em>useEffect</em>, <em>useState</em>} <em>from </em>&#39;react&#39;;<br><em>import </em>* <em>as </em>LocalAuthentication <em>from </em>&#39;expo-local-authentication&#39;<br><em>import </em>{ StyleSheet, Text, View, Alert, Image,TouchableOpacity } <em>from </em>&#39;react-native&#39;;<br><br><em>import </em>AsyncStorage <em>from </em>&quot;@react-native-async-storage/async-storage&quot;;<br><br><br><br><em>export default function App</em>() {<br>  <em>const </em>[isBiometricSupported, setIsBiometricSupported] = <em>useState</em>(<em>false</em>);<br>  <em>// wherever the useState is located<br><br>  const </em>[isBioMetric, setIsBioMetric] = <em>useState</em>(<em>true</em>);<br>  <em>useEffect</em>(() =&gt;{<br>    AsyncStorage.getItem(&#39;crowdFactureUser&#39;).then(value =&gt;{<br>      <em>if</em>(value === <em>null</em>) setIsBioMetric(<em>false</em>)<br>    })<br>  },[])<br><br><em>// Check if hardware supports biometrics<br>  useEffect</em>(() =&gt; {<br>    (<em>async </em>() =&gt; {<br>      <em>const </em>compatible = <em>await </em>LocalAuthentication.<em>hasHardwareAsync</em>();<br>      setIsBiometricSupported(compatible);<br>    })();<br>  },[]);<br>  <br>  <em>const </em>logUserIn  = (userEmail, password) =&gt;{<br>    <em>//do all your password and user name auth<br>    //...<br>    //..<br>    //.<br>    //if yes the log user in and execute code the below (basically)<br>    </em>setAuthorization(userEmail)<br>  }<br><br><br>  <em>//this functions is called on each login<br>  const </em>setAuthorization = <em>async </em>(UserEmail) =&gt; {<br><br>    <em>try </em>{<br>      <br>      <em>// the app stores user email on the device storage<br>      //the device will use this email in combination with then fingerprint to authenticate the user<br>      </em>AsyncStorage.setItem(&#39;UserEmail&#39;, UserEmail)<br>    } <em>catch </em>(err) {<br>      console.log(&#39;Error UserEmail: &#39;, err);<br>    }<br>  }<br><br><br><br><em>//this function is called by your biometric button<br>  //where the user then registers his/her biometric<br><br>  const </em>onFaceId = <em>async </em>() =&gt; {<br>    <em>try </em>{<br>      <em>// Checking if device is compatible<br>      const </em>isCompatible = <em>await </em>LocalAuthentication.<em>hasHardwareAsync</em>();<br><br>      <em>if </em>(!isCompatible) {<br>        <em>throw new </em>Error(&#39;Your device isn\&#39;t compatible.&#39;)<br>      }<br><br>      <em>// Checking if device has biometrics records<br>      const </em>isEnrolled = <em>await </em>LocalAuthentication.<em>isEnrolledAsync</em>();<br><br>      <em>if </em>(!isEnrolled) {<br>        <em>throw new </em>Error(&#39;No Faces / Fingers found.&#39;)<br>      }<br><br>      <em>// Authenticate user<br><br><br>      const </em>auth =  <em>await </em>LocalAuthentication.<em>authenticateAsync</em>();<br>      <em>if</em>(auth.success){<br><br>        AsyncStorage.getItem(&#39;crowdFactureUser&#39;).then(value =&gt;{<br>          logUserIn(value)<br>          <em>//Alert.alert(&#39;Authenticated&#39;, `Welcome back ! ${value}`)<br>        </em>})<br>      }<em>else</em>{<br>        Alert.<em>alert</em>(<br>            &#39;Biometric record not found&#39;,<br>            &#39;Please verify your identity with your password&#39;)<br>      }<br><br><br><br><br>    } <em>catch </em>(error) {<br>      Alert.<em>alert</em>(&#39;An error as occured&#39;, error?.message);<br>    }<br>  };<br><br>  <em>return </em>(<br>    &lt;View <em>style</em>={styles.container}&gt;<br>      &lt;Text&gt;Open up App.js to start working on your app!&lt;/Text&gt;<br><br>      <br>      <br>      {<br>        isBioMetric &amp;&amp;  <br>        &lt;TouchableOpacity <em>style</em>={styles.smBtn}<br>                                           <em>onPress</em>={onFaceId}&gt;<br><br>          &lt;Image <em>source</em>={require(&#39;../assets/fingerprint.png&#39;)} <em>style</em>={styles.btnImage}/&gt;<br>        &lt;/TouchableOpacity&gt;<br>      }<br><br>    &lt;/View&gt;<br>  );<br>}<br><br><em>const </em>styles = StyleSheet.create({<br>  container: {<br>    flex: 1,<br>    backgroundColor: &#39;#fff&#39;,<br>    alignItems: &#39;center&#39;,<br>    justifyContent: &#39;center&#39;,<br>  },<br>  smBtn: {<br>    marginLeft: 20,<br>    width: 60,<br>    height: 60,<br>    justifyContent: &#39;center&#39;,<br>    alignItems: &#39;center&#39;,<br>    flexDirection: &#39;row&#39;,<br>    borderRadius: 10,<br>    borderColor: &quot;#ccc&quot;,<br>    borderWidth: 2<br><br>  },<br>  btnImage: {<br>    width: 40,<br>    height: 40,<br>  },<br>});</pre><p>Good luck, contact me if you have any difficulty implementing this awesome feature I’d be more than willing to help.</p><p>Thank you</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc51aa992dff" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>