<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Masimo Orbanic</title>
    <description>The latest articles on Forem by Masimo Orbanic (@orbamas).</description>
    <link>https://forem.com/orbamas</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F376676%2Fb74e90d8-5575-42dd-855b-2accec9734a0.jpg</url>
      <title>Forem: Masimo Orbanic</title>
      <link>https://forem.com/orbamas</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/orbamas"/>
    <language>en</language>
    <item>
      <title>9 tricks to make your React Native development easier</title>
      <dc:creator>Masimo Orbanic</dc:creator>
      <pubDate>Mon, 28 Feb 2022 08:58:36 +0000</pubDate>
      <link>https://forem.com/lloyds-digital/9-tricks-to-make-your-react-native-development-easier-39i1</link>
      <guid>https://forem.com/lloyds-digital/9-tricks-to-make-your-react-native-development-easier-39i1</guid>
      <description>&lt;p&gt;We all agree that React Native is a great way to develop mobile apps. But in the process of making a mobile app, besides the endless hours spent reading the documentation and debugging some badly implemented package, you come across a situation that makes you think “hmm, I wonder if there is an easier way to do this”. So I bring you some tricks that I’ve learned over the years developing React Native apps and wish that somebody told them to me years ago. Hope you find something useful for yourself, let’s start!&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Open a new terminal in the same folder - from the terminal (Mac only)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  UPDATE
&lt;/h3&gt;

&lt;p&gt;You can open new terminal in the same folder with a  setting in the preferences. Go to the Terminal preferences, General settings, and under &lt;em&gt;New windows&lt;/em&gt; open with select &lt;em&gt;Same Working Directory&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8vf7m2bko4wfjy0j2ro9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8vf7m2bko4wfjy0j2ro9.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Your work day probably starts with opening a Terminal, navigating to the project folder and running &lt;code&gt;yarn android&lt;/code&gt; or/and &lt;code&gt;yarn start&lt;/code&gt; . But after some time you need to install some React Native package or run some tricky git command, and wish to have another Terminal window in the same folder. So you press cmd + N to open new Terminal window and navigate in the terminal to the project folder. To make this thing easier you can run &lt;code&gt;open -a Terminal \$(pwd)&lt;/code&gt; in the terminal, which basically opens the Terminal app in the desired folder, which in our case can be obtained with the &lt;code&gt;pwd&lt;/code&gt; command.  But that command is too long to write and remember, so you can add it in your &lt;em&gt;.zshrc&lt;/em&gt; file as alias &lt;code&gt;alias nt="open -a Terminal \$(pwd)"&lt;/code&gt; . After you restart the Terminal app, if you run &lt;code&gt;nt&lt;/code&gt; command (I’ve named the alias &lt;em&gt;nt&lt;/em&gt; for &lt;strong&gt;n&lt;/strong&gt;ew &lt;strong&gt;t&lt;/strong&gt;erminal, you can call it whatever you want), you will get a new Terminal window in the same directory from which you ran the &lt;code&gt;nt&lt;/code&gt; command.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Simulate push notifications on iOS
&lt;/h2&gt;

&lt;p&gt;Let’s say that you are doing some push notification suff and you want to quickly test how your app reacts when a push notification is received. Instead of manually triggering a push notification by doing some in-app action or sending one from a dashboard, you can create a &lt;em&gt;noti&lt;/em&gt;&lt;em&gt;fication.apns&lt;/em&gt; file and drag ‘n drop it in the Simulator window! And what exactly is in the &lt;em&gt;notification.apns&lt;/em&gt; file? Well, it looks like this:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
 "Simulator Target Bundle": "com.example.simpush",
 "aps": {
   "alert": {
     "title": "New notification!",
     "subtitle": "notification.apns triggered notification",
     "body": "Hello there!"
   },
   "sound": "default"
 },
 "custom": {
   "test": "something",
 }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The first information is &lt;em&gt;"Simulator Target Bundle": "com.example.simpush"&lt;/em&gt;, and it tells which application to run, in our case it is the application with bundle id &lt;code&gt;com.example.simpush&lt;/code&gt; . Next comes the &lt;em&gt;"&lt;/em&gt;&lt;em&gt;aps&lt;/em&gt;&lt;em&gt;"&lt;/em&gt; section, and as you can see it has an alert section where you define the &lt;em&gt;title&lt;/em&gt;, &lt;em&gt;subtitle&lt;/em&gt; and &lt;em&gt;body&lt;/em&gt; of the notification. Also in the “&lt;em&gt;a&lt;/em&gt;&lt;em&gt;ps&lt;/em&gt;” section you can define the sound and vibration settings. In the “&lt;em&gt;custom&lt;/em&gt;” you can define custom information that is sent with the push notification.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fop1gmlkm67nnfr26gfwn.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fop1gmlkm67nnfr26gfwn.gif" alt="Simulation of push notification on iOS"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Depending on your app push notification setup, the &lt;em&gt;notification.apns&lt;/em&gt; file can be different. But once you’ve configured in Xcode that your app can receive push notifications, and you granted permission to receive push notifications, you should be able to make it work.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Share Android device screen on your desktop
&lt;/h2&gt;

&lt;p&gt;You will probably need to share your phone’s screen to your desktop. Either you don’t want to stay leaned above your phone all day, or you have something to present to your client/colleague over a video conference. There are some solutions like Vysor or Screen stream over HTTP, but the picture quality is not that great and there could be some ads playing during usage. But there is an app called &lt;a href="https://github.com/Genymobile/scrcpy" rel="noopener noreferrer"&gt;&lt;em&gt;scrcpy&lt;/em&gt;&lt;/a&gt; , that provides display and control of Android devices connected with USB (or over TCP/IP, covered in tip number 8). It does not require any root access, and it works on Linux, Windows and macOS. I’ve been using it for some time and it works great. Also the setup is very easy. You can learn how to install it and use &lt;a href="https://github.com/Genymobile/scrcpy" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Generate app icons
&lt;/h2&gt;

&lt;p&gt;When you have an app that is ready to go the stores, you must have an app icon. And you have one because your design team did a great job on creating one! But you must have them in a couple of specific dimensions, with square and rounded corners, for both iOS and Android. To spare yourself and designers from this time consuming and boring task, there are some web applications that can do that for you, and the best one we have been using in Lloyds digital so far is &lt;a href="https://appiconmaker.co/" rel="noopener noreferrer"&gt;appiconmaker.co&lt;/a&gt; for iOS, and for Android &lt;a href="http://romannurik.github.io/AndroidAssetStudio/icons-launcher.html" rel="noopener noreferrer"&gt;AndroidAssetStudio&lt;/a&gt;. They is free and easy to use, no watermarks or limitations. &lt;/p&gt;

&lt;h2&gt;
  
  
  5. Open Xcode project from the Terminal
&lt;/h2&gt;

&lt;p&gt;The longest way to open an Xcode project of your app is to &lt;em&gt;open Finder&lt;/em&gt; &amp;gt; &lt;em&gt;find your React Native project folder&lt;/em&gt; &amp;gt; &lt;em&gt;open ios folder&lt;/em&gt; &amp;gt; &lt;em&gt;open .xcworkspace&lt;/em&gt; &lt;em&gt;file&lt;/em&gt;. The shortest way is to put &lt;code&gt;"xc": "xed -b ios"&lt;/code&gt; in your projects &lt;em&gt;package.json&lt;/em&gt; under “scripts”, and just run &lt;code&gt;yarn xc&lt;/code&gt; from project folder to open Xcode project of your React Native app. You can find out more about &lt;code&gt;xed&lt;/code&gt; in this &lt;a href="https://medium.com/xcblog/xed-the-lightweight-text-editor-for-xcode-269aae5b2a77#:~:text=The%20xed%20is%20Xcode%20Text,files%20or%20creating%20new%20files." rel="noopener noreferrer"&gt;Medium&lt;/a&gt; &lt;a href="https://medium.com/xcblog/xed-the-lightweight-text-editor-for-xcode-269aae5b2a77" rel="noopener noreferrer"&gt;post&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Use transform.tools
&lt;/h2&gt;

&lt;p&gt;Transforming code or data from one format to other can be time consuming and boring, and you could miss some piece of information if the structure is too confusing and big. To help you with that, there is an online app &lt;a href="https://transform.tools" rel="noopener noreferrer"&gt;transform.tools&lt;/a&gt; which offers many kinds of transformations. I will mention just some of them, mostly used in React Native:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SVG to React Native (JSX)&lt;/li&gt;
&lt;li&gt;JSON to JSDoc&lt;/li&gt;
&lt;li&gt;JSON to Typescript&lt;/li&gt;
&lt;li&gt;JSON to MobX-State-Tree Model&lt;/li&gt;
&lt;li&gt;GraphQL to Typescript&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Visit &lt;a href="https://transform.tools/" rel="noopener noreferrer"&gt;transform.tools&lt;/a&gt; and make transformations of your code or data with ease. &lt;/p&gt;

&lt;h2&gt;
  
  
  7. Consider implementing Code Push for faster feedback loop from developer to the testers and clients
&lt;/h2&gt;

&lt;p&gt;As the project timeline comes to an end, communication and feedback loop between testers/client and developer must be the fastest possible. You will probably come to a situation where you made a test release of the app with some small bug that breaks the app and the testing can not continue. And the fix for the bug is very simple, one or two lines of JS code. In order to deliver that fixed version you need to increase build numbers, create a new release, and upload it to the TestFlight or Google Play store testing track, which we all can agree is at least 1 hour of work. To make the feedback loop shorter you can use &lt;a href="https://github.com/microsoft/react-native-code-push" rel="noopener noreferrer"&gt;Code push&lt;/a&gt;. Code Push is a cloud service from Microsoft Visual Studio App Center, that acts as a central repository where developers can publish certain updates. These updates are then queried by apps using the client Code Push SDK. Since Code Push is in semi-violation of the Google and Apple store guidelines, I won’t encourage you to implement it in the production version of the app, but for test and development purpose you can find it very helpful. I’ve covered Code Push in the &lt;a href="https://dev.to/lloyds-digital/implementing-code-push-in-react-native-applications-25nj"&gt;Implementing Code Push in React Native applications&lt;/a&gt; article. In the article you can find more information on what Code Push is and how to implement it.&lt;/p&gt;

&lt;h2&gt;
  
  
  8.  ADB over WiFi
&lt;/h2&gt;

&lt;p&gt;Your computer communicates with your Android device using Android Debug Bridge (&lt;em&gt;adb&lt;/em&gt;). Maybe you remember &lt;em&gt;adb&lt;/em&gt; from the &lt;a href="https://reactnative.dev/docs/running-on-device" rel="noopener noreferrer"&gt;running on device tutorial&lt;/a&gt;, and in the tutorial you are guided to use USB to make everything work. But there is an option to have &lt;em&gt;adb&lt;/em&gt; over WiFi! Here is how to setup &lt;em&gt;adb&lt;/em&gt; over WiFi:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Make sure that your Android device and &lt;em&gt;adb&lt;/em&gt; host computer are connected to a common Wi-Fi network accessible to both&lt;/li&gt;
&lt;li&gt;Connect the device to the host computer with a USB cable&lt;/li&gt;
&lt;li&gt;Set the target device to listen for a TCP/IP connection on port 5555 by running &lt;code&gt;adb tcpip 5555&lt;/code&gt; in your Terminal&lt;/li&gt;
&lt;li&gt;Disconnect the USB cable from your device&lt;/li&gt;
&lt;li&gt;Find the IP address of your Android device. You can usually find the IP address at &lt;strong&gt;Settings&lt;/strong&gt; &amp;gt; &lt;strong&gt;About phone&lt;/strong&gt; &amp;gt; &lt;strong&gt;Status&lt;/strong&gt; &amp;gt; &lt;strong&gt;IP address&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Connect to the device by its IP address using &lt;code&gt;adb connect &amp;lt;&amp;lt;device_ip_address&amp;gt;&amp;gt;:5555&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Confirm that your host computer is connected to the target device by running &lt;code&gt;adb devices&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;From that point you can do everything on your Android device as if you were connected with USB, like run &lt;code&gt;adb reverse tcp:8081 tcp:8081&lt;/code&gt; , or use scrcpy from the #3 tip in this article!&lt;/p&gt;

&lt;p&gt;Android devices running Android 11+ have a method to wirelessly use &lt;em&gt;adb&lt;/em&gt; using Wireless debugging feature.  You can find out goodies about &lt;em&gt;adb&lt;/em&gt; &lt;a href="https://developer.android.com/studio/command-line/adb" rel="noopener noreferrer"&gt;here&lt;/a&gt;. &lt;/p&gt;

&lt;h2&gt;
  
  
  9. r - Terminal command (Mac)
&lt;/h2&gt;

&lt;p&gt;This is a trick that can be widely used. Basically when you run &lt;em&gt;r&lt;/em&gt; in your Terminal, the last command that you executed will be executed again, just like it would if you pressed up key and hit enter. But the trick is that it has options for start and end command that will be ran from your history. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fakvhndv9qehlyscoe6qs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fakvhndv9qehlyscoe6qs.png" alt="Presentation of r command"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The first option, -4 from the screenshot, is the start, and it runs the fourth command from your terminal history, and the second option -2 is the end and it runs every command between fourth and second one in your terminal history. You can find it useful if you have same the set of commands that you need to run multiple times, like running some test script, or for example pushing a fix to git. &lt;br&gt;
If you once ran &lt;code&gt;git add -Av&lt;/code&gt; , &lt;code&gt;git commit -m "small fix"&lt;/code&gt; and &lt;code&gt;git push&lt;/code&gt; , you can re-run all of them by running &lt;code&gt;r -3 -1&lt;/code&gt; in your Terminal.&lt;/p&gt;

&lt;p&gt;Lloyds is available for partnerships and open for new projects. If you want to know more about us, click &lt;a href="https://lloyds-digital.com/" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;br&gt;
Also, don’t forget to follow us on &lt;a href="https://www.instagram.com/lloyds.digital/" rel="noopener noreferrer"&gt;Instagram&lt;/a&gt; and &lt;a href="https://www.facebook.com/lloydsdigital/" rel="noopener noreferrer"&gt;Facebook&lt;/a&gt;!&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>javascript</category>
      <category>tips</category>
      <category>dev</category>
    </item>
    <item>
      <title>Stripe in-app payments in React Native</title>
      <dc:creator>Masimo Orbanic</dc:creator>
      <pubDate>Tue, 08 Dec 2020 11:05:29 +0000</pubDate>
      <link>https://forem.com/lloyds-digital/stripe-in-app-payments-in-react-native-27jg</link>
      <guid>https://forem.com/lloyds-digital/stripe-in-app-payments-in-react-native-27jg</guid>
      <description>&lt;p&gt;Stripe is currently one of the best payment services that you can use in your web and mobile applications. It offers many features like subscriptions, the option to collect payments from customers and pay them out to sellers or service providers, invoicing, and many other good things. It is also very developer-friendly, it has support for popular programming languages, Webhooks for all types of events and the developer documentation is well written.&lt;/p&gt;

&lt;p&gt;🚨 Important 🚨&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Since May 2021 Stripe has an official package to support React Native platform called &lt;a href="https://github.com/stripe/stripe-react-native"&gt;stripe-react-native&lt;/a&gt; . It's recommended to use the official package for long term support and stability. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Stripe does not have an official package for React Native, but the community has some libraries to offer. One of them is &lt;a href="https://github.com/tipsi/tipsi-stripe"&gt;tipsi-stripe&lt;/a&gt;. The stable release of tipsi-stripe is not currently supported (December 2020) because the last stable release is from August 2019, and since then the EU Strong Customer Authentication (SCA) came into power. It requires a major update of the package because the native part of the package has been updated. The version of tipsi-stripe that supports SCA &lt;a href="https://github.com/tipsi/tipsi-stripe/tree/8.0.0-beta.11"&gt;8.0.0-beta.11&lt;/a&gt; is still being developed.&lt;/p&gt;

&lt;p&gt;Another package is react-native-stripe-payments, it has a stable release that supports SCA, but accepts only payments with credit cards. Other methods are not supported. We in &lt;a href="https://lloyds-design.com/"&gt;Lloyds&lt;/a&gt; are using react-native-stripe-payments and so far it is working well.&lt;/p&gt;

&lt;h1&gt;
  
  
  What do you need in order to implement Stripe?
&lt;/h1&gt;

&lt;p&gt;The first thing you will need is, of course, a &lt;a href="https://dashboard.stripe.com/register"&gt;Stripe account&lt;/a&gt;. After you create one, you are free to jump into testing mode by turning on the test mode ("View test data" switch in the sidebar). To switch Stripe to production environment, you must enter a bunch of company data and bank account information to receive payments. Also, you must be sure that Stripe is &lt;a href="https://stripe.com/global"&gt;available in the country&lt;/a&gt; where the company is registered.&lt;/p&gt;

&lt;p&gt;In order to have Stripe in your React Native app, you must have a backend where the majority of the checkout process is defined. The official Stripe package is available for Node, Ruby, Python, PHP, .NET, Java and Go. In &lt;a href="https://lloyds-design.com/"&gt;Lloyds&lt;/a&gt; we are using Laravel, a PHP framework.&lt;/p&gt;

&lt;h1&gt;
  
  
  How it works?
&lt;/h1&gt;

&lt;p&gt;Everything is revolving around &lt;a href="https://stripe.com/docs/payments/payment-intents"&gt;Payment intents&lt;/a&gt;. Payment intents track a payment, from initial creation through the entire checkout process, and triggers additional authentication steps when required. In order for react-native-stripe-payments to work, you must have &lt;em&gt;&lt;a href="https://stripe.com/docs/payments/payment-intents#passing-to-client"&gt;client_secret&lt;/a&gt;&lt;/em&gt; which is retrieved from the backend where the payment intent is created. &lt;/p&gt;

&lt;p&gt;The flow is:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;user presses the BUY button,&lt;/li&gt;
&lt;li&gt;a request containing items to buy is sent to the backend,&lt;/li&gt;
&lt;li&gt;payment intent is created on the backend and &lt;em&gt;client_secret&lt;/em&gt; is returned in the response,&lt;/li&gt;
&lt;li&gt;user is prompted to enter credit card details,&lt;/li&gt;
&lt;li&gt;payment is confirmed on the client-side using &lt;em&gt;client_secret&lt;/em&gt; and credit card details,&lt;/li&gt;
&lt;li&gt;payment confirmation is recorded in the backend using Stripe Webhooks&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Since the items to buy and &lt;em&gt;client_secret&lt;/em&gt; are the only two thing shared between client and server, this process is very secure, there is very little room for the corruption of the payment process.&lt;/p&gt;

&lt;h1&gt;
  
  
  Backend
&lt;/h1&gt;

&lt;p&gt;Backend is used to create Payment intent and to store information about the transactions that occurred.&lt;/p&gt;

&lt;p&gt;First, we add the &lt;a href="https://stripe.com/docs/api"&gt;Stripe package&lt;/a&gt; to our framework so our backend can communicate with Stripe.&lt;/p&gt;

&lt;p&gt;In total, the basic implementation of Stripe requires two API endpoints to be created:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;to create payment intent and return &lt;em&gt;client_secret&lt;/em&gt; to client&lt;/li&gt;
&lt;li&gt;Webhook URL to receive information from Stripe about a successful payment&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The endpoint to create payment intent is used to create payment intent and to bind created payment intent to order in the database. The order in the database must have stored information about payment intent because the payment is not confirmed yet, the confirmation of the payment is done through the Webhook endpoint. The response must contain &lt;em&gt;client_secret&lt;/em&gt;, which can be found in the created Payment intent object. &lt;/p&gt;

&lt;p&gt;The request from Stripe to our backend (Webhook) contains data about the payment intent, so we can find an order which is bound to payment intent in the database and mark that order as completed. Webhook can be configured on &lt;a href="https://dashboard.stripe.com/webhooks"&gt;Stripe dashboard&lt;/a&gt;. The event that you want to trigger is &lt;code&gt;payment_intent.succeeded&lt;/code&gt;. That is just the basic setup, but with Stripe Webhooks you can configure Webhook for many types of events, in other words, notify your backend about the change that occurred.&lt;/p&gt;

&lt;h1&gt;
  
  
  React Native
&lt;/h1&gt;

&lt;p&gt;As mentioned earlier, we will use the &lt;a href="https://github.com/Fitpassu/react-native-stripe-payments"&gt;react-native-stripe-payments&lt;/a&gt; package. Installation of the package does not require any linking process, everything is handled with autolinking. &lt;/p&gt;

&lt;p&gt;The package is very simple and does not require a lot of configuration. The first thing we must do is to call &lt;code&gt;setOptions&lt;/code&gt; method and pass the &lt;a href="https://stripe.com/docs/keys"&gt;Stripe publishing key&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;stripe&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react-native-stripe-payments&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;stripe&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setOptions&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;publishingKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;STRIPE_PUBLISHING_KEY&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next thing, as we described in the "How it works" section, we'll send a request to your backend on route to create payment intent. In the request, you can pass the cart_id, or array of cart items that are being bought, as long as you can calculate the total price, you are good.&lt;br&gt;
If the request was successful, the backend should return you the &lt;em&gt;client_secret&lt;/em&gt;, and you can prompt the user to enter his credit card details. You can create your own design of the credit card input, or you can use &lt;a href="https://github.com/sbycrosz/react-native-credit-card-input"&gt;react-native-credit-card-input&lt;/a&gt; or some other credit card input package. You can check if the credit card is valid using the stripes &lt;code&gt;isCardValid&lt;/code&gt; &lt;a href="https://github.com/Fitpassu/react-native-stripe-payments#validate-the-given-card-details"&gt;method&lt;/a&gt;. For testing you can find the test credit cards &lt;a href="https://stripe.com/docs/testing"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;When you have &lt;em&gt;client_secret&lt;/em&gt; and valid credit card, you can run the &lt;code&gt;confirmPayment&lt;/code&gt; method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;stripe&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;confirmPayment&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;client_secret_from_backend&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;cardDetails&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// payment was successful&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
    &lt;span class="c1"&gt;// error occurred&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the payment was successful, Stripe will fire a Webhook request to the backend, and the backend will make a record that the transaction occurred and store data relevant to the transaction so the transaction can be back-traced if needed. You can also check the received payments on the &lt;a href="https://dashboard.stripe.com/test/dashboard"&gt;Stripe dashboard&lt;/a&gt; and make sure that the transaction was successful. &lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;The process of payment on the web and in mobile apps is evolving and is being made secure every day. It is on the developer to create flexible solutions and quickly respond to the changes that need to be made. Also, don't forget to check if you are viewing the test data or live data on the Stripe dashboard 🙂&lt;/p&gt;

&lt;p&gt;Thank you for reading this! If you've found this interesting, consider leaving a ❤️, 🦄, and of course, share and comment your thoughts!&lt;/p&gt;

&lt;p&gt;Lloyds is available for partnerships and open for new projects. If you want to know more about us, click &lt;a href="https://lloyds-design.com/"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Also, don’t forget to follow us on &lt;a href="https://www.instagram.com/lloyds.design/"&gt;Instagram&lt;/a&gt; and &lt;a href="https://www.facebook.com/lloydsgn/"&gt;Facebook&lt;/a&gt;!&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>stripe</category>
      <category>payment</category>
      <category>checkout</category>
    </item>
    <item>
      <title>Implementing Code Push in React Native applications</title>
      <dc:creator>Masimo Orbanic</dc:creator>
      <pubDate>Tue, 23 Jun 2020 06:23:54 +0000</pubDate>
      <link>https://forem.com/lloyds-digital/implementing-code-push-in-react-native-applications-25nj</link>
      <guid>https://forem.com/lloyds-digital/implementing-code-push-in-react-native-applications-25nj</guid>
      <description>&lt;p&gt;Let me start by saying that this is an article for those who've never tried to implement Code Push or just want to find out more about it. I've heard about Code Push services many times before and it is one of the biggest features of Expo, but I've never tried to get one on &lt;code&gt;react-native init app&lt;/code&gt;. I will talk about my motivation for implementing Code Push and the things that I found interesting and useful along the way.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why is Code Push good?
&lt;/h2&gt;

&lt;p&gt;I'm not a fan of production bugs. If a bug somehow manages to get into production (and it does), you are under pressure to fix it and to deploy a bugfix update across devices as soon as possible. The deployment part is a hassle, because you need to build iOS version, Android version, find and access developer accounts, make sure that version numbers are correct, wait for the app review from the stores, etc. and it is time-consuming.&lt;br&gt;
To make deploying part easier, a service called Code Push comes to help. It is a cloud service from &lt;a href="https://appcenter.ms/"&gt;Microsoft Visual Studio App Center&lt;/a&gt;, that acts as a central repository where developers can publish certain updates. These updates are then queried by apps using the client Code Push SDK. In other words, you create a JavaScript bundle, which is published to the Code Push service, and you configure your client app to load JavaScript builds from Code Push repository of builds.&lt;/p&gt;
&lt;h2&gt;
  
  
  How to setup Code Push
&lt;/h2&gt;
&lt;h4&gt;
  
  
  Create an account
&lt;/h4&gt;

&lt;p&gt;To start with Code Push you need to create an account on &lt;a href="https://appcenter.ms"&gt;Visual Studio App Center&lt;/a&gt;.&lt;br&gt;
Along with Code Push, Visual Studio App Center offers creation of app binary builds (apk, aab, ipa), crash and usage analytics, testing of app on real devices, and distribution management. You will see all these features on the App Center dashboard when you create an app in the App Center. Code Push is free for an unlimited number of builds and devices.&lt;/p&gt;
&lt;h4&gt;
  
  
  Create an app
&lt;/h4&gt;

&lt;p&gt;When you add a new app in App Center, it is recommended to create a new app for each platform, one app for Android, one app for iOS. While creating a new app you will be asked for the name of your new app, release type, OS, and Platform. OS is Android or iOS, and Platform is React Native, and release type is for the label only, I have named mine Production. After you have created an app, in a sidebar, go to Distribute &amp;gt; Code Push, there you will have a list of all Code Push releases you have created.&lt;/p&gt;
&lt;h4&gt;
  
  
  Setup Client SDK
&lt;/h4&gt;

&lt;p&gt;Before we create a release for Code Push, let's implement Code Push SDK to our React Native app. The package needed for Code Push in React Native apps is &lt;a href="https://github.com/Microsoft/react-native-code-push"&gt;react-native-code-push&lt;/a&gt;. Before you start implementing Code Push SDK, &lt;a href="https://docs.microsoft.com/en-gb/appcenter/distribution/codepush/rn-overview#supported-react-native-platforms"&gt;check the corresponding Code Push version&lt;/a&gt;, depending on your React Native version. My version of react native is 0.62.2 so I will use &lt;br&gt;
&lt;code&gt;react-native-code-push@v6.2&lt;/code&gt; .&lt;br&gt;
After installing the NPM package, you need to install the native module, so follow the &lt;a href="https://docs.microsoft.com/en-gb/appcenter/distribution/codepush/rn-get-started"&gt;iOS setup and Android setup&lt;/a&gt;. For Android the process is similar to others, adding some lines to &lt;code&gt;android/settings.gradle&lt;/code&gt; , &lt;code&gt;android/app/build.gradle&lt;/code&gt;, &lt;code&gt;MainApplication.java&lt;/code&gt; and &lt;code&gt;strings.xml&lt;/code&gt;. In the &lt;code&gt;MainApplication.java&lt;/code&gt; the most important change is&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="c1"&gt;/// MainApplication.java&lt;/span&gt;
&lt;span class="o"&gt;...&lt;/span&gt;
&lt;span class="nd"&gt;@Override&lt;/span&gt;
    &lt;span class="kd"&gt;protected&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="nf"&gt;getJSBundleFile&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;CodePush&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getJSBundleFile&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These line tells that the JS bundle is not provided by a local JS bundle that is in the app binary, but from Code Push.&lt;br&gt;
In &lt;code&gt;strings.xml&lt;/code&gt; the most important thing is &lt;em&gt;CodePushDeploymentKey&lt;/em&gt;. You can get it with Code Push CLI, but also you can find it in the App Center app dashboard, under Code Push section, click on the options icon which is next to deployment selection. This is the key that identifies the deployment, and with that key app knows from which deployment to look for updates. By default, there are two deployments, Staging and Production. This enables you to have testing, staging, production, and other versions of the app, so that you can send a Code Push update only to specific deployment of the app. The guide for Code Push has an entire section for managing &lt;a href="https://docs.microsoft.com/en-gb/appcenter/distribution/codepush/rn-deployment#multi-deployment-testing"&gt;multiple deployments&lt;/a&gt;. For trying-out purposes, my advice is that you don't define &lt;em&gt;CodePushDeploymentKey&lt;/em&gt; inside &lt;code&gt;strings.xml&lt;/code&gt;, but in &lt;code&gt;android/app/build.gradle&lt;/code&gt;, under &lt;em&gt;buildTypes&lt;/em&gt; section. By default there are two build types: &lt;em&gt;debug {}&lt;/em&gt; , and &lt;em&gt;release {}&lt;/em&gt;, and you can define the &lt;em&gt;CodePushDeploymentKey&lt;/em&gt; as &lt;br&gt;
&lt;code&gt;resValue "string", "CodePushDeploymentKey", '"&amp;lt;&amp;lt; your CodePushDeploymentKey &amp;gt;&amp;gt;"'&lt;/code&gt; , for each build type. My &lt;em&gt;buildTypes&lt;/em&gt; looks like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;android/app/build.gradle&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="err"&gt;buildTypes&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="err"&gt;debug&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="err"&gt;signingConfig&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;signingConfigs.debug&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="err"&gt;resValue&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"string"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"CodePushDeploymentKey"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;'&lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="err"&gt;'&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="err"&gt;release&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="err"&gt;signingConfig&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;signingConfigs.debug&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="err"&gt;minifyEnabled&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;enableProguardInReleaseBuilds&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="err"&gt;proguardFiles&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;getDefaultProguardFile(&lt;/span&gt;&lt;span class="s2"&gt;"proguard-android.txt"&lt;/span&gt;&lt;span class="err"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"proguard-rules.pro"&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="err"&gt;resValue&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"string"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"CodePushDeploymentKey"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;'&lt;/span&gt;&lt;span class="s2"&gt;"&amp;lt;&amp;lt; CodePushDeploymentKey &amp;gt;&amp;gt;"&lt;/span&gt;&lt;span class="err"&gt;'&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can see that for debug I left &lt;em&gt;CodePushDeploymentKey&lt;/em&gt; empty so that I don't get any interaction with Code Push in the debug/development mode. Also, if you have another build type, here you can add the deployment key for that build type. The good thing to know is that the deploymentKey can be defined by script, with &lt;a href="https://docs.microsoft.com/en-gb/appcenter/distribution/codepush/rn-api-ref#codepushoptions"&gt;codePush options&lt;/a&gt; .&lt;br&gt;
For iOS part, you need to add some lines to &lt;code&gt;AppDelegate.m&lt;/code&gt;, and change from where the app gets release JS bundle.&lt;br&gt;
My &lt;em&gt;sourceURLForBridge&lt;/em&gt; method looks like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight objective_c"&gt;&lt;code&gt;&lt;span class="c1"&gt;// AppDelegate.m&lt;/span&gt;

&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;NSURL&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="n"&gt;sourceURLForBridge&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;RCTBridge&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="n"&gt;bridge&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="cp"&gt;#if DEBUG
&lt;/span&gt;        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[[&lt;/span&gt;&lt;span class="n"&gt;RCTBundleURLProvider&lt;/span&gt; &lt;span class="nf"&gt;sharedSettings&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="nf"&gt;jsBundleURLForBundleRoot&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s"&gt;@"index"&lt;/span&gt; &lt;span class="nf"&gt;fallbackResource&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nb"&gt;nil&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
    &lt;span class="cp"&gt;#else
&lt;/span&gt;        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;CodePush&lt;/span&gt; &lt;span class="nf"&gt;bundleURL&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt; &lt;span class="c1"&gt;// this is important line&lt;/span&gt;
    &lt;span class="cp"&gt;#endif
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The deployment key goes to info.plist. To make different build types target different deployments, under Build settings you need to add user-defined setting, called &lt;code&gt;CODEPUSH_KEY&lt;/code&gt;. For debug, I've left it empty, and for release, I've added Production deployment key. With that, inside &lt;code&gt;info.plist&lt;/code&gt; configure that &lt;em&gt;CodePushDeploymentKey&lt;/em&gt; is looking at setting defined in Build settings.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2HEiLlHe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/1q3yxvq9b2irtvfv21x0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2HEiLlHe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/1q3yxvq9b2irtvfv21x0.png" alt="Alt Text" width="880" height="145"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;// info.plist

...
&lt;span class="nt"&gt;&amp;lt;key&amp;gt;&lt;/span&gt;CodePushDeploymentKey&lt;span class="nt"&gt;&amp;lt;/key&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;string&amp;gt;&lt;/span&gt;$(CODEPUSH_KEY)&lt;span class="nt"&gt;&amp;lt;/string&amp;gt;&lt;/span&gt;
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There is a part for &lt;a href="https://docs.microsoft.com/en-gb/appcenter/distribution/codepush/rn-get-started#http-exception-domains-configuration-ios"&gt;HTTP exception domains configuration&lt;/a&gt; for iOS apps, and code signing setup for &lt;a href="https://docs.microsoft.com/en-gb/appcenter/distribution/codepush/rn-get-started#code-signing-setup-android"&gt;Android&lt;/a&gt; and &lt;a href="https://docs.microsoft.com/en-gb/appcenter/distribution/codepush/rn-get-started#code-signing-setup-ios"&gt;iOS&lt;/a&gt;, but for trying out purposes I did not setup it, but it is definitely something to look up and setup.&lt;/p&gt;

&lt;p&gt;Now we go to Javascript part of the setup. The first thing we do is that we wrap our App entry to Code Push higher order component (HOC), and add Code Push options&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;codePush&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react-native-code-push&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;codePushOptions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
    &lt;span class="na"&gt;checkFrequency&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;codePush&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;CheckFrequency&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ON_APP_RESUME&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
    &lt;span class="na"&gt;updateDialog&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;appendReleaseDescription&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;MyApp&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;Component&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="p"&gt;..&lt;/span&gt;
        &lt;span class="p"&gt;..&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;codePush&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;codePushOptions&lt;/span&gt;&lt;span class="p"&gt;)(&lt;/span&gt;&lt;span class="nx"&gt;MyApp&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can check the list of &lt;code&gt;codePushOptions&lt;/code&gt; &lt;a href="https://docs.microsoft.com/en-gb/appcenter/distribution/codepush/rn-api-ref#codepushoptions"&gt;here&lt;/a&gt; . The option &lt;code&gt;updateDialog: { appendReleaseDescription: true }&lt;/code&gt; means that the user gets update dialog when an update is available.&lt;/p&gt;

&lt;p&gt;And that is all the setup needed. There are many options and things to look after in every step of the setup so far, but this setup so far is good enough to get you started. &lt;/p&gt;

&lt;p&gt;You can find a lot of valuable information on &lt;a href="https://docs.microsoft.com/en-gb/appcenter/distribution/codepush/rn-overview"&gt;React Native Client SDK guide&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Releasing of the Code Push updates
&lt;/h2&gt;

&lt;p&gt;Releasing of updates is done only through Terminal, and to access App Center the from terminal you need to install &lt;a href="https://github.com/microsoft/appcenter-cli"&gt;App Center CLI&lt;/a&gt; . For more details on App Center CLI and how to set it up check &lt;a href="https://docs.microsoft.com/en-gb/appcenter/distribution/codepush/cli"&gt;the guide&lt;/a&gt;&lt;br&gt;
To release an update of current code you run &lt;/p&gt;

&lt;p&gt;&lt;code&gt;appcenter codepush release-react -a &amp;lt;your username&amp;gt;/&amp;lt;your app name&amp;gt; -d &amp;lt;your deployment&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This will create a new React Native bundle, and upload it to Code Push. &lt;br&gt;
Next time you launch the release version of the app, you will get a prompt that the update is available.&lt;/p&gt;

&lt;p&gt;There is an App Center CLI option to pass a token as an argument, so you can publish new build without logging in to App Center. This is very helpful for DevOps when you want to automatically publish an update when you git push on the production branch.&lt;/p&gt;

&lt;h2&gt;
  
  
  Stores guide
&lt;/h2&gt;

&lt;p&gt;Even though this is an "abstract" way to apply updates across devices, Android does not have a specific guideline for this, but Apple does (as usual). You can find more info in the &lt;a href="https://github.com/Microsoft/react-native-code-push#store-guideline-compliance"&gt;Store guideline compliance&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Example apps
&lt;/h2&gt;

&lt;p&gt;I've created a simple TODO app with Code Push implemented, you can check it out here on &lt;a href="https://github.com/masimo-orbanic-llds/todocp"&gt;github.com/BugBlaster5000/todocp&lt;/a&gt;. It's a simple app that has navigation, Redux for state management and Async storage.&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>react</category>
      <category>codepush</category>
      <category>devops</category>
    </item>
  </channel>
</rss>
