<?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: Abhijeet Rathore</title>
    <description>The latest articles on Forem by Abhijeet Rathore (@abhijeetrathor2).</description>
    <link>https://forem.com/abhijeetrathor2</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%2F193775%2F43fe8d9e-82c3-441f-acd9-c07e15ea99a6.jpg</url>
      <title>Forem: Abhijeet Rathore</title>
      <link>https://forem.com/abhijeetrathor2</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/abhijeetrathor2"/>
    <language>en</language>
    <item>
      <title>How to Generate and download PDF in Ionic 5 apps</title>
      <dc:creator>Abhijeet Rathore</dc:creator>
      <pubDate>Tue, 24 Aug 2021 16:50:37 +0000</pubDate>
      <link>https://forem.com/enappd/how-to-generate-and-download-pdf-in-ionic-5-apps-2pa</link>
      <guid>https://forem.com/enappd/how-to-generate-and-download-pdf-in-ionic-5-apps-2pa</guid>
      <description>
&lt;p&gt;In this tutorial we will learn how we can generate PDF in an Ionic app, and download it to the device. You might have ordered food or any item from some e-commerce application and after ordering you must have downloaded the invoice/bill for it as a proof. Similarly there are several other scenarios where your app might need a PDF generation and download facility.&lt;/p&gt;
&lt;p&gt;We will understand this feature through Enappd’s &lt;a href="https://store.enappd.com/product/grocery-complete-platform-user-delivery-and-admin-app/" rel="noopener"&gt;Grocery Application&lt;/a&gt; workflow, where &lt;strong&gt;we order some items, then generate an invoice/bill and download it in the form of PDF. &lt;/strong&gt;You can follow the same steps to create the PDF generation feature in your own Ionic app.&lt;/p&gt;
&lt;p&gt;To know more about Grocery Shopping Platform you can read Enappd’s &lt;a href="https://enappd.com/blog/ionic-5-grocery-shopping-user-delivery-and-admin-apps/171" rel="noopener"&gt;&lt;strong&gt;Grocery Shopping Platform Blog&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt; &lt;/strong&gt;or check the &lt;a href="https://www.youtube.com/watch?v=OC0crxN_31M" rel="noopener"&gt;feature video&lt;/a&gt;. Before moving on, we will understand ordering flow of Grocery Application, so it will be easy for us to implement our Invoice task.&lt;/p&gt;
&lt;h3&gt;Ionic —&amp;amp;hairsp;Introduction&lt;/h3&gt;
&lt;p&gt;If you are reading this blog, you are probably already aware of &lt;a href="https://ionicframework.com/" rel="noopener nofollow noopener"&gt;Ionic&lt;/a&gt;, &lt;a href="https://cordova.apache.org/" rel="noopener nofollow noopener"&gt;Cordova&lt;/a&gt; and &lt;a href="https://capacitorjs.com/" rel="noopener nofollow noopener noopener"&gt;Capacitor&lt;/a&gt; frameworks. While Ionic is the front-end wrapper framework for mobile UI, Cordova is the build framework that converts Ionic code into a device (Android /iOS) compatible code.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://capacitorjs.com/" rel="noopener nofollow noopener"&gt;Capacitor&lt;/a&gt; is another option in place of Cordova to build apps using Ionic. While Capacitor is born couple of years ago, Cordova has been around for a decade. That’s the reason Cordova has more community made plugins for various unique features, but Capacitor is quickly catching up as well.&lt;/p&gt;
&lt;h3&gt;Item Ordering Flow&amp;amp;hairsp;—&amp;amp;hairsp;Grocery Platform&lt;/h3&gt;
&lt;p&gt;The flow is same as what you might have encountered while ordering items in any other app. We simply add items to the Cart and Checkout with selected Address (&lt;a href="https://www.youtube.com/watch?v=OC0crxN_31M" rel="noopener"&gt;Here’s a video&lt;/a&gt; of the flow). In the &lt;a href="https://store.enappd.com/product/grocery-complete-platform-user-delivery-and-admin-app/" rel="noopener"&gt;Grocery Platform&lt;/a&gt;, the items are then automatically added to the ‘My orders’ tab and from there you can download the Invoice/Bill for our ordered Items, as shown below.&lt;/p&gt;
&lt;img alt="Enappd’s Grocery shopping platform PDF generation" src="https://res.cloudinary.com/practicaldev/image/fetch/s--qYLHWxw1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AyMp7wlBoXmYbYh6GZ5e7jg.jpeg"&gt;Enappd’s Grocery shopping platform PDF generation&lt;br&gt;&lt;p&gt;In above screens you can see items in &lt;strong&gt;My Order&lt;/strong&gt; Tab which we have ordered. From this we can generate Invoice and later download it as PDF, as shown below.&lt;/p&gt;
&lt;img alt="Downloaded PDF in Enappd’s Grocery shopping platform" src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ag9_yTsr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AYbbSzGwbWmm6azpIu3icuw.jpeg"&gt;Downloaded PDF in Enappd’s Grocery shopping platform&lt;br&gt;&lt;p&gt;You can see the Invoice contains the delivery address, ordered products with price, grand total and many other information. The information in the PDF corresponds to the logged in user, and can be easily changed as you wish.&lt;/p&gt;
&lt;p&gt;Now let’s start the flow to implement PDF generation in our Application. &lt;strong&gt;We will create a blank Ionic app with dummy item list and related item details, and ‘My Order’ page UI from where we’ll download the invoice.&lt;/strong&gt;&lt;/p&gt;
&lt;h3&gt;Structure of the post&lt;/h3&gt;
&lt;p&gt;We’ll follow these steps to implement the feature&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Create a blank Ionic app&lt;/li&gt;
&lt;li&gt;Create the required UI and dummy data for demo purpose&lt;/li&gt;
&lt;li&gt;Setup PDF generation plugin&lt;/li&gt;
&lt;li&gt;Setup PDF content and styling&lt;/li&gt;
&lt;li&gt;Test on device&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Step 1&amp;amp;hairsp;—&amp;amp;hairsp;Create a blank Ionic app&lt;/h3&gt;
&lt;p&gt;Generally in all our blogs, we start with creating blank Ionic app, so a new comer or beginner can also try the feature. To create an &lt;strong&gt;Ionic Angular&lt;/strong&gt; Project you just have to run one command and that’s it ! Rest of the things are handled by the Ionic-CLI. Run the below command in you terminal.&lt;/p&gt;
&lt;pre&gt;$ ionic start pdfgen blank --type=angular --cordova&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;--type=angular&lt;/code&gt; told the CLI to create an &lt;strong&gt;Angular&lt;/strong&gt; app. And &lt;code&gt;--cordova&lt;/code&gt; tells the CLI to integrate Cordova support.&lt;/p&gt;
&lt;p&gt;( My environment for this blog is&amp;amp;hairsp;—&amp;amp;hairsp;Node 14.x, Ionic 5.5, Angular 11.x, NPM 7.x, Cordova 10.0 )&lt;/p&gt;
&lt;p&gt;This will create an empty ionic project in the working directory of your pc. For more details on creating a new Ionic app from scratch, check out our blog on Ionic Apps&lt;a href="https://enappd.com/blog/how-to-create-an-ionic-app-for-beginners/144/" rel="noopener nofollow noopener"&gt; here&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;Step 2&amp;amp;hairsp;—&amp;amp;hairsp;Create the required UI and dummy data&lt;/h3&gt;
&lt;p&gt;You can create the required UI as shown in the images for Enappd’ &lt;a href="https://store.enappd.com/product/grocery-complete-platform-user-delivery-and-admin-app/" rel="noopener"&gt;Grocery Platform&lt;/a&gt;, though it’s not mandatory. For demo, you can implement the PDF generation feature just on a simple button, using the dummy data same as a genuine full scale Grocery app.&lt;/p&gt;
&lt;p&gt;We’ll use a JSON of dummy order data, which will populate our HTML like the actual app. This JSON can be added and accessed from &lt;code&gt;environment.ts&lt;/code&gt; , but in the actual app you’ll have this data coming from server anyway.&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
Dummy order data for PDF generation
&lt;br&gt;&lt;p&gt;With this dummy data populated in our UI, here’s how my UI looks&lt;/p&gt;
&lt;img alt="UI for My Orders page- PDF generation in Ionic apps" src="https://res.cloudinary.com/practicaldev/image/fetch/s--otH8tNey--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2A18YEoqCDjNc4sxheWnlF3A.png"&gt;UI for My Orders page— PDF generation in Ionic apps&lt;br&gt;&lt;p&gt;Here’s the HTML and CSS for the UI if you want&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;p&gt;We can see in above html code we have mapped through array of products using &lt;code&gt;&lt;strong&gt;*ngFor=”let product of order.products”&lt;/strong&gt;&lt;/code&gt;. Note, the dummy data is coming from &lt;code&gt;environment.ts&lt;/code&gt; for this demo, but for your actual app it should come from the server.&lt;/p&gt;
&lt;h3&gt;Step 3&amp;amp;hairsp;—&amp;amp;hairsp;Setup PDF generation plugin&lt;/h3&gt;
&lt;p&gt;Let’s install the PDF generation plugin and the npm packages in our application. &lt;strong&gt;We will use Cordova PDFGenerator Plugin to implement this feature&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;$ ionic cordova plugin add cordova-pdf-generator&lt;br&gt;$ npm install @ionic-native/pdf-generator&lt;/pre&gt;
&lt;p&gt;This above command will add the PDFGenerator to the plugins folder. Once the plugins are installed, add the PDFGenerator Module to &lt;code&gt;&lt;strong&gt;app.module.ts&lt;/strong&gt;&lt;/code&gt; like below&lt;/p&gt;
&lt;pre&gt;...&lt;br&gt;&lt;strong&gt;import { PDFGenerator } from '@ionic-native/pdf-generator/ngx';&lt;/strong&gt;&lt;/pre&gt;
&lt;pre&gt;@NgModule({&lt;br&gt;... ,&lt;/pre&gt;
&lt;pre&gt;providers: [&lt;strong&gt;PDFGenerator&lt;/strong&gt;, { provide: RouteReuseStrategy, useClass: IonicRouteStrategy }],&lt;/pre&gt;
&lt;pre&gt;...&lt;br&gt;})&lt;br&gt;export class AppModule { }&lt;/pre&gt;
&lt;p&gt;This will provide the PDFGenerator instance available to the complete application and we can use the Plugin in any of the app pages.&lt;/p&gt;
&lt;h3&gt;Step 4&amp;amp;hairsp;—&amp;amp;hairsp;Setup PDF content and styling&lt;/h3&gt;
&lt;p&gt;Generating a PDF starts from a properly styled HTML. You can either&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Have same HTML show in the app’s page, AND be printed as PDF, or&lt;/li&gt;
&lt;li&gt;Use a different HTML to show in app, and different to print in PDF&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Here’s how we’ll generate PDF (Method 1) —&lt;/p&gt;
&lt;p&gt;Click on &lt;code&gt;INVOICE&lt;/code&gt; button in &lt;strong&gt;My Orders&lt;/strong&gt; page → Opens a Modal where the order invoice will show up → If you see the details are correct, you can download the invoice using&lt;code&gt;DOWNLOAD&lt;/code&gt; button&lt;/p&gt;
&lt;h4&gt;Create PDF Download Modal&lt;/h4&gt;
&lt;p&gt;To create the Modal Component, you can run the below command :-&lt;/p&gt;
&lt;pre&gt;$ ionic generate component components/invoice&lt;/pre&gt;
&lt;p&gt;This above command will add a component in path “components/invoice” like in below folder structure :-&lt;/p&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3plbJZIq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AIGE7PGNsOia97DZBj4N6BA.png"&gt;&lt;p&gt;Add the Modal component to &lt;code&gt;app.module.ts&lt;/code&gt;&lt;/p&gt;
&lt;pre&gt;...&lt;br&gt;&lt;strong&gt;import { InvoiceComponent } from './components/invoice/invoice.component';&lt;/strong&gt;&lt;/pre&gt;
&lt;pre&gt;@NgModule({&lt;/pre&gt;
&lt;pre&gt;declarations: [AppComponent, &lt;strong&gt;InvoiceComponent&lt;/strong&gt;],&lt;/pre&gt;
&lt;pre&gt;...&lt;br&gt;})&lt;br&gt;export class AppModule { }&lt;/pre&gt;
&lt;p&gt;We will open this modal from &lt;code&gt;&lt;strong&gt;openInvoice&lt;/strong&gt;&lt;/code&gt; function of&lt;code&gt;home.page.ts&lt;/code&gt; , here’s how the code will look, including the dummy data inclusion from &lt;code&gt;environment.ts&lt;/code&gt;&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;h4&gt;PDF Download Modal UI&lt;/h4&gt;
&lt;p&gt;For PDFs, we have to work with traditional &lt;code&gt;table&lt;/code&gt; , &lt;code&gt;&amp;lt;tr&amp;gt;&lt;/code&gt; , &lt;code&gt;&amp;lt;td&amp;gt;&lt;/code&gt; etc elements. So we design our Invoice page with these tags, while using our Angular &lt;code&gt;*ngIf&lt;/code&gt; etc.&lt;/p&gt;
&lt;blockquote&gt;&lt;strong&gt;IMPORTANT: You need to add all CSS inline for PDF styling to work.&lt;/strong&gt;&lt;/blockquote&gt;
&lt;p&gt;Here’s how the HTML code looks for the modal + PDF&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;p&gt;In above snippet, we have the id named &lt;code&gt;&lt;strong&gt;PrintInvoice&lt;/strong&gt;&lt;/code&gt;&lt;strong&gt; &lt;/strong&gt;from where our PDF content will start (means complete element/div is content for PDF). We will click on Download Invoice button to run the &lt;code&gt;downloadInvoice()&lt;/code&gt; method defined in &lt;code&gt;invoice.component.ts&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Here’s how the Modal will look like with the order details&lt;/p&gt;
&lt;img alt="Download PDF modal&amp;amp;hairsp;—&amp;amp;hairsp;PDF generation in Ionic apps" src="https://res.cloudinary.com/practicaldev/image/fetch/s--XXfdrxRV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2ApBMmeBZ4LowmCIP-PmPuSw.png"&gt;Download PDF modal&amp;amp;hairsp;—&amp;amp;hairsp;PDF generation in Ionic apps&lt;br&gt;&lt;h4&gt;Download Logic&lt;/h4&gt;
&lt;p&gt;In &lt;code&gt;&lt;strong&gt;openInvoice&lt;/strong&gt;&lt;/code&gt;&lt;strong&gt; &lt;/strong&gt;method of &lt;code&gt;home.page.ts&lt;/code&gt;, we passed the &lt;code&gt;&lt;strong&gt;order&lt;/strong&gt;&lt;/code&gt; object through Modal Controller. We receive this value in &lt;code&gt;invoice.component.ts&lt;/code&gt; using &lt;strong&gt;@Input() order; &lt;/strong&gt;and we used this order object to show the complete Information in modal. Here’s the logic for &lt;code&gt;invoice.component.ts&lt;/code&gt;&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;p&gt;The &lt;code&gt;&lt;strong&gt;downloadInvoice&lt;/strong&gt;&lt;/code&gt;&lt;strong&gt; &lt;/strong&gt;method will be called once you click on the download Invoice button. The method contains the :-&lt;/p&gt;
&lt;pre&gt;this.content = document.getElementById('PrintInvoice').innerHTML;&lt;/pre&gt;
&lt;p&gt;This will capture the whole content of the Invoice/bill which have the Id of &lt;code&gt;PrintInvoice&lt;/code&gt; in our html page and save it to the content class variable. And further we can also specify the options for generating PDF like below&lt;/p&gt;
&lt;pre&gt;&lt;em&gt;let&lt;/em&gt; options = {&lt;br&gt;  documentSize: 'A4',&lt;br&gt;  type: 'share',&lt;br&gt;  fileName: 'Order-Invoice.pdf'&lt;br&gt;};&lt;/pre&gt;
&lt;p&gt;Here we can specify the file name by which it will be saved in your system/Mobile and specify the file size like ‘A4’ or ‘A3’ etc. After this the main code that generates PDF out of the HTML is :-&lt;/p&gt;
&lt;pre&gt;this.pdfGenerator.fromData(this.content, options).then((&lt;em&gt;base64&lt;/em&gt;) &lt;em&gt;=&amp;gt;&lt;/em&gt; {&lt;br&gt;   &lt;em&gt;console&lt;/em&gt;.log('OK', base64);&lt;br&gt;}).catch((&lt;em&gt;error&lt;/em&gt;) &lt;em&gt;=&amp;gt;&lt;/em&gt; {&lt;br&gt;   &lt;em&gt;console&lt;/em&gt;.log('error', error);&lt;br&gt;});&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;&lt;strong&gt;fromData&lt;/strong&gt;&lt;/code&gt;&lt;strong&gt; &lt;/strong&gt;is the method defined under PDFGenerator Plugin which will convert the HTML =&amp;gt; PDF, This method takes the HTML content and options as the argument and returns the base64 URL.&lt;/p&gt;
&lt;h3&gt;Step 5&amp;amp;hairsp;—&amp;amp;hairsp;Test on device&lt;/h3&gt;
&lt;p&gt;If you haven’t added any platform you can run below command to add Android platform and build app&lt;/p&gt;
&lt;pre&gt;$ ionic cordova platform add android&lt;br&gt;$ ionic cordova build android&lt;br&gt;$ ionic cordova run android // device should be attached&lt;/pre&gt;
&lt;p&gt;This will add the android platform and required plugin in project like below :-&lt;/p&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fyVFwi49--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AGx--_KRxZ8Ap3rphgHSPbg.jpeg"&gt;Added Android Platform and Plugin&lt;br&gt;&lt;p&gt;Clicking on &lt;code&gt;DOWNLOAD INVOICE&lt;/code&gt;button will lead to the following OS PDF handler, where you can download the PDF using that highlighted button.&lt;/p&gt;
&lt;img alt="OS PDF Handler&amp;amp;hairsp;—&amp;amp;hairsp;PDF generation in Ionic apps" src="https://res.cloudinary.com/practicaldev/image/fetch/s--9QMFrfL0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AME7VCJHj34afywlozKUqyw.jpeg"&gt;OS PDF Handler&amp;amp;hairsp;—&amp;amp;hairsp;PDF generation in Ionic apps&lt;br&gt;&lt;p&gt;Here’s the full flow of downloading your invoice in your own Grocery Shopping App in Ionic&lt;/p&gt;
&lt;img alt="PDF generation in Ionic apps" src="https://res.cloudinary.com/practicaldev/image/fetch/s--f9xqJtwx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AhdEt-s1mtyzifJpdt2nJsA.gif"&gt;PDF generation in Ionic apps&lt;br&gt;&lt;h3&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;In this tutorial we saw how we can generate a PDF for dynamic data, in Ionic apps. Also we learnt how we can design our own PDF and then download it. You can do a lot of designing to make your PDF look cool-er. The limitation being it has to stick to standard HTML tags like &lt;code&gt;&amp;lt;table&amp;gt;&lt;/code&gt; , &lt;code&gt;&amp;lt;tr&amp;gt;&lt;/code&gt; etc. and the CSS needs to be written inline.&lt;/p&gt;
&lt;p&gt;You can now add this amazing PDF generation feature to your Ionic e-commerce or shopping apps, wherever you need to generate invoices.&lt;/p&gt;
&lt;p&gt;Stay tuned for more awesome tutorials ! And get complete code for the tutorial by signing up below.&lt;/p&gt;

&lt;h3&gt;Next Steps&lt;/h3&gt;
&lt;p&gt;If you liked this blog, you will also find the following blogs interesting and helpful. Feel free to ask any questions in the comment section&lt;/p&gt;
&lt;h3&gt;Ionic Capacitor&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Basic&lt;/strong&gt;&amp;amp;hairsp;—&amp;amp;hairsp;&lt;a href="https://enappd.com/blog/use-geolocation-geocoding-and-reverse-geocoding-in-ionic-capacitor/131" rel="noopener nofollow noopener noopener noopener"&gt;Geolocation&lt;/a&gt; | &lt;a href="https://enappd.com/blog/qr-code-and-barcode-scanning-with-ionic-capacitor/127" rel="noopener nofollow noopener noopener noopener"&gt;Barcode &amp;amp; QR code&lt;/a&gt; | &lt;a href="https://enappd.com/blog/facebook-login-in-capacitor-apps-with-ionic-angular/128" rel="noopener nofollow noopener noopener noopener"&gt;Facebook Login&lt;/a&gt; (Angular) | &lt;a href="https://enappd.com/blog/facebook-login-in-ionic-react-capacitor-apps/118" rel="noopener nofollow noopener noopener noopener"&gt;Facebook Login (React)&lt;/a&gt; | &lt;a href="https://enappd.com/blog/icon-splash-in-ionic-react-capacitor-apps/114" rel="noopener nofollow noopener noopener noopener"&gt;Icon and Splash&lt;/a&gt; | &lt;a href="https://enappd.com/blog/camera-and-gallery-in-ionic-react-app-using-capacitor/110" rel="noopener nofollow noopener noopener noopener"&gt;Camera &amp;amp; Photo Gallery&lt;/a&gt; | &lt;a href="https://enappd.com/blog/debugging-ionic-apps-using-chrome-and-safari-developers-tools/167" rel="noopener"&gt;Debugging with browser&lt;/a&gt;|Theming in Ionic apps&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Advanced&lt;/strong&gt;&amp;amp;hairsp;—&amp;amp;hairsp;&lt;a href="https://enappd.com/blog/implement-admob-in-ionic-react-capacitor-apps/135" rel="noopener nofollow noopener noopener noopener"&gt;AdMob&lt;/a&gt; | &lt;a href="https://enappd.com/blog/local-notifications-in-ionic-5-capacitor/132" rel="noopener nofollow noopener noopener noopener"&gt;Local Notifications&lt;/a&gt; | &lt;a href="https://enappd.com/blog/google-login-in-ionic-react-capacitor-apps/122" rel="noopener nofollow noopener noopener noopener"&gt;Google Login&lt;/a&gt; | &lt;a href="https://enappd.com/blog/twitter-login-in-ionic-react-capacitor-app/121" rel="noopener nofollow noopener noopener noopener"&gt;Twitter Login&lt;/a&gt; | &lt;a href="https://enappd.com/blog/html5-games-in-ionic-capacitor-using-phaser/115" rel="noopener nofollow noopener noopener noopener"&gt;Games using Phaser&lt;/a&gt; | &lt;a href="https://enappd.com/blog/play-music-in-ionic-capacitor-apps/112" rel="noopener nofollow noopener noopener noopener"&gt;Play music&lt;/a&gt; | &lt;a href="https://enappd.com/blog/firebase-push-notification-in-ionic-react-capacitor/111" rel="noopener nofollow noopener noopener noopener"&gt;Push Notifications&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Ionic Cordova&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://enappd.com/blog/ionic-app-with-nodejs-express-mysql-sequelize-taxi-app/160" rel="noopener nofollow noopener noopener noopener"&gt;Taxi Booking App example with Ionic, Node, Express and MySQL&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Ionic Payment Gateways&amp;amp;hairsp;—&amp;amp;hairsp;&lt;a href="https://enappd.com/blog/integrate-stripe-payment-gateway-in-ionic-5-apps-and-pwa-using-firebase/158" rel="noopener nofollow noopener noopener noopener"&gt;Stripe with Firebase&lt;/a&gt; | &lt;a href="https://enappd.com/blog/ionic-5-stripe-payment-integration-firebase-cloud-functions-vs-node-express-based-server/159" rel="noopener nofollow noopener noopener noopener"&gt;Stripe with NodeJS&lt;/a&gt; | &lt;a href="https://enappd.com/blog/paypal-integration-in-ionic-apps-and-pwa/142" rel="noopener nofollow noopener noopener noopener"&gt;PayPal&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-integrate-apple-pay-in-ionic-4-apps/21" rel="noopener nofollow noopener noopener noopener"&gt;Apple Pay&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-integrate-razorpay-in-ionic-4-apps-and-pwa/20" rel="noopener nofollow noopener noopener noopener"&gt;RazorPay&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Ionic Charts with&amp;amp;hairsp;—&amp;amp;hairsp;&lt;a href="https://enappd.com/blog/ionic-4-charts-using-google-charts/66" rel="noopener nofollow noopener noopener noopener"&gt;Google Charts &lt;/a&gt;| &lt;a href="https://enappd.com/blog/adding-charts-in-ionic-4-apps-and-pwa-part-3/60" rel="noopener nofollow noopener noopener noopener"&gt;HighCharts&lt;/a&gt; | &lt;a href="https://enappd.com/blog/adding-charts-in-ionic-4-apps-and-pwa-part-2/54" rel="noopener nofollow noopener noopener noopener"&gt;d3.js&lt;/a&gt; | &lt;a href="https://enappd.com/blog/charts-in-ionic-4-apps-and-pwa-part-1/52" rel="noopener nofollow noopener noopener noopener"&gt;Chart.js&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Ionic Authentications&amp;amp;hairsp;—&amp;amp;hairsp;&lt;a href="https://enappd.com/blog/firebase-email-authentication-in-ionic-apps/153" rel="noopener nofollow noopener noopener noopener"&gt;Via Email&lt;/a&gt; | &lt;a href="https://enappd.com/blog/implement-anonymous-login-in-ionic-apps-with-firebase/154" rel="noopener nofollow noopener noopener noopener"&gt;Anonymous&lt;/a&gt; | &lt;a href="https://enappd.com/blog/facebook-login-in-ionic-apps-using-firebase/150" rel="noopener nofollow noopener noopener noopener"&gt;Facebook&lt;/a&gt; | &lt;a href="https://enappd.com/blog/implement-google-login-in-ionic-apps-using-firebase/147" rel="noopener nofollow noopener noopener noopener"&gt;Google&lt;/a&gt; | &lt;a href="https://enappd.com/blog/twitter-login-in-ionic-4-apps-using-firebase/24" rel="noopener nofollow noopener noopener noopener"&gt;Twitter&lt;/a&gt; | &lt;a href="https://enappd.com/blog/firebase-phone-authentication-in-ionic-5-apps/169" rel="noopener"&gt;Via Phone&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Ionic Features&amp;amp;hairsp;—&amp;amp;hairsp;&lt;a href="https://enappd.com/blog/ionic-5-complete-guide-on-geolocation/141" rel="noopener nofollow noopener noopener noopener"&gt;Geolocation&lt;/a&gt;| &lt;a href="https://enappd.com/blog/ionic-complete-guide-barcode-qrcode-scan/140" rel="noopener nofollow noopener noopener noopener"&gt;QR Code reader&lt;/a&gt; | &lt;a href="https://enappd.com/blog/best-fitness-plugins-for-ionic-4-how-to-use-pedometer/15" rel="noopener nofollow noopener noopener noopener"&gt;Pedometer&lt;/a&gt;| &lt;a href="https://enappd.com/blog/implement-signature-pad-in-ionic-apps/145" rel="noopener nofollow noopener noopener noopener"&gt;Signature&lt;/a&gt; &lt;a href="https://enappd.com/blog/implement-signature-pad-in-ionic-apps/145" rel="noopener"&gt;Pad&lt;/a&gt; | &lt;a href="https://enappd.com/blog/using-background-geolocation-in-ionic-angular-apps/165" rel="noopener nofollow noopener noopener noopener"&gt;Background Geolocation&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Media in Ionic&amp;amp;hairsp;—&amp;amp;hairsp;&lt;a href="https://enappd.com/blog/spotify-like-music-in-ionic-4-apps/48" rel="noopener nofollow noopener noopener noopener"&gt;Audio&lt;/a&gt; | &lt;a href="https://enappd.com/blog/adding-video-player-in-ionic-4-app/64" rel="noopener nofollow noopener noopener noopener"&gt;Video&lt;/a&gt; | &lt;a href="https://enappd.com/blog/camera-and-image-picker-in-ionic-apps/148" rel="noopener nofollow noopener noopener noopener"&gt;Image Picker&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-add-image-cropper-in-ionic-apps/149" rel="noopener nofollow noopener noopener noopener"&gt;Image Cropper&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Ionic Essentials&amp;amp;hairsp;—&amp;amp;hairsp;&lt;a href="https://enappd.com/blog/debugging-ionic-apps-using-chrome-and-safari-developers-tools/167" rel="noopener"&gt;Debugging with browser&lt;/a&gt;| &lt;a href="https://enappd.com/blog/ionic-4-save-and-retrieve-data-locally-on-device/59" rel="noopener nofollow noopener noopener noopener"&gt;Native Storage&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-translate-in-ionic-internationalization-and-localization/143" rel="noopener nofollow noopener noopener noopener"&gt;Translations&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-use-rtl-right-to-left-in-ionic-apps-pwa/152" rel="noopener nofollow noopener noopener noopener"&gt;RTL&lt;/a&gt; | &lt;a href="https://enappd.com/blog/using-sentry-error-monitoring-with-ionic-angular-applications/164" rel="noopener nofollow noopener noopener noopener"&gt;Sentry Error Monitoring&lt;/a&gt; | &lt;a href="https://enappd.com/blog/social-sharing-component-in-ionic-5-mobile-web-apps/168" rel="noopener"&gt;Social sharing&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Ionic messaging&amp;amp;hairsp;—&amp;amp;hairsp;&lt;a href="https://enappd.com/blog/how-to-implement-firebase-push-notifications-in-ionic-apps/157" rel="noopener nofollow noopener noopener noopener"&gt;Firebase Push&lt;/a&gt; | &lt;a href="https://enappd.com/blog/automatically-read-sms-in-ionic-4-apps/42" rel="noopener nofollow noopener noopener noopener"&gt;Reading SMS&lt;/a&gt; | &lt;a href="https://enappd.com/blog/local-notifications-in-ionic-5-capacitor/132" rel="noopener nofollow noopener noopener noopener"&gt;Local Notifications&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Ionic with Firebase&amp;amp;hairsp;—&amp;amp;hairsp;&lt;a href="https://enappd.com/blog/how-to-integrate-firebase-in-ionic-4-apps/23" rel="noopener nofollow noopener noopener noopener"&gt;Basics&lt;/a&gt; | &lt;a href="https://enappd.com/blog/firebase-with-ionic-4-hosting-auth-and-db-connection/58" rel="noopener nofollow noopener noopener noopener"&gt;Hosting and DB&lt;/a&gt; | &lt;a href="https://enappd.com/blog/firebase-cloud-functions-in-ionic-5-complete-guide/166" rel="noopener"&gt;Cloud functions&lt;/a&gt; | &lt;a href="https://enappd.com/blog/github-actions-deploying-ionic-angular-app-to-firebase-hosting/146" rel="noopener nofollow noopener noopener noopener"&gt;Deploy App to Firebase&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-use-firebase-emulators-with-ionic-angular-applications/163" rel="noopener nofollow noopener noopener noopener"&gt;Firebase simulator&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Unit Testing in Ionic&amp;amp;hairsp;—&amp;amp;hairsp;&lt;a href="https://enappd.com/blog/beginners-guide-to-ionic-angular-unit-testing-part-1/151" rel="noopener nofollow noopener noopener noopener"&gt;Part 1&lt;/a&gt; | &lt;a href="https://enappd.com/blog/beginners-guide-to-ionic-angular-unit-testing-part-2-mocks-and-spies/155" rel="noopener nofollow noopener noopener noopener"&gt;Mocks &amp;amp; Spies&lt;/a&gt;| &lt;a href="https://enappd.com/blog/beginners-guide-to-ionic-angular-unit-testing-async-testing/156" rel="noopener nofollow noopener noopener noopener"&gt;Async Testing&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Ionic React Full App with Capacitor&lt;/h3&gt;
&lt;p&gt;If you need a base to start your next Ionic 5 React Capacitor app, you can make your next awesome app using &lt;a href="https://store.enappd.com/product/ionic-react-full-app-capacitor/" rel="noopener"&gt;Ionic 5 React Full App in Capacitor&lt;/a&gt;&lt;/p&gt;
&lt;img alt="Ionic 5 React Full App in Capacitor from Enappd" src="https://res.cloudinary.com/practicaldev/image/fetch/s--Z0sRDsyI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AG3yOFVX4oABx9MhUy-3kng.png"&gt;Ionic 5 React Full App in Capacitor from Enappd&lt;br&gt;&lt;h3&gt;Ionic Capacitor Full App (Angular)&lt;/h3&gt;
&lt;p&gt;If you need a base to start your next Angular &lt;strong&gt;Capacitor app&lt;/strong&gt;, you can make your next awesome app using &lt;a href="https://store.enappd.com/product/capacitor-full-app-with-ionic-angular/" rel="noopener nofollow noopener noopener noopener"&gt;Capacitor Full App&lt;/a&gt;&lt;/p&gt;
&lt;img alt="Capacitor Full App with huge number of layouts and features" src="https://res.cloudinary.com/practicaldev/image/fetch/s--jbZt2zIJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/0%2AUwSHcofTMStMnzAX.png"&gt;Capacitor Full App with huge number of layouts and features&lt;br&gt;&lt;h3&gt;Ionic Full App (Angular and Cordova)&lt;/h3&gt;
&lt;p&gt;If you need a base to start your next Ionic 5 app, you can make your next awesome app using &lt;a href="https://store.enappd.com/product/ionic-full-app" rel="noopener"&gt;Ionic 5 Full App&lt;/a&gt;&lt;/p&gt;
&lt;img alt="Ionic Full App with huge number of layouts and features" src="https://res.cloudinary.com/practicaldev/image/fetch/s--V1pEO0Mo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/0%2A1ArpKyhiDHZnevwB.jpeg"&gt;Ionic Full App in Cordova, with huge number of layouts and features&lt;br&gt;

</description>
      <category>ionic</category>
      <category>javascript</category>
      <category>mobile</category>
      <category>angular</category>
    </item>
    <item>
      <title>PayPal Payment Integration using Braintree in Ionic 5 apps</title>
      <dc:creator>Abhijeet Rathore</dc:creator>
      <pubDate>Mon, 23 Aug 2021 18:12:46 +0000</pubDate>
      <link>https://forem.com/enappd/paypal-payment-integration-using-braintree-in-ionic-5-apps-2fe6</link>
      <guid>https://forem.com/enappd/paypal-payment-integration-using-braintree-in-ionic-5-apps-2fe6</guid>
      <description>
&lt;p&gt;In this tutorial, we will go through PayPal payment using Braintree in Ionic 5. Previously Paypal supported the &lt;a href="https://ionicframework.com/docs/native/paypal" rel="noopener noreferrer"&gt;Cordova PayPal Plugin&lt;/a&gt;, which is no more maintained by PayPal, hence it has issues while making payment using PayPal Login. PayPal now recommends using Braintree for mobile payments, while web payment still works fine with the generic PayPal JS script. You can read more about the web integration in our blog —&amp;amp;hairsp;&lt;a href="https://enappd.com/blog/paypal-integration-in-ionic-apps-and-pwa/142/" rel="noopener noreferrer"&gt;PayPal integration in Ionic PWA&lt;/a&gt;.&lt;/p&gt;
&lt;blockquote&gt;For ease of development, it is recommended to have same payment method i.e. Braintree for both mobile and web, instead of PayPal for web and Braintree for mobile.&lt;/blockquote&gt;
&lt;p&gt;This type of integration requires a Backend (server) to generate several tokens and final transaction is also done by the server. For this tutorial, we will be using a Node JS server and will be calling APIs from Ionic app using HTTP client.&lt;/p&gt;
&lt;p&gt;We will follow below steps to implement PayPal integration using Braintree.&lt;/p&gt;
&lt;h3&gt;Steps to Implement PayPal Integration Using Braintree :-&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Create Braintree sandbox account and get the required keys&lt;/li&gt;
&lt;li&gt;Setup Ionic 5 project&lt;/li&gt;
&lt;li&gt;Setup Node JS project&lt;/li&gt;
&lt;li&gt;Creating Node JS API’s for Braintree&lt;/li&gt;
&lt;li&gt;Braintree/PayPal integration in Ionic app using Node JS API’s&lt;/li&gt;
&lt;li&gt;Testing&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Before we proceed, a little bit about Ionic and Braintree&lt;/p&gt;
&lt;h3&gt;What is Braintree ?&lt;/h3&gt;
&lt;p&gt;Braintree offers a variety of products that make it easy for users to accept payments in their apps or website. Think of Braintree as the credit card terminal you swipe your card through at the grocery store. Braintree supports following major types of payment methods&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;ACH Direct Debit&lt;/li&gt;
&lt;li&gt;Apple Pay&lt;/li&gt;
&lt;li&gt;Google Pay&lt;/li&gt;
&lt;li&gt;PayPal&lt;/li&gt;
&lt;li&gt;Samsung Pay&lt;/li&gt;
&lt;li&gt;Credit / Debit cards&lt;/li&gt;
&lt;li&gt;Union Pay&lt;/li&gt;
&lt;li&gt;Venmo&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;What is Ionic ?&lt;/h3&gt;
&lt;p&gt;Ionic framework is a mobile app framework, which supports other front-end frameworks like Angular, React, Vue and Vanilla JS, and builds apps for both Android and iOS from same code.&lt;/p&gt;
&lt;p&gt;If you create Native apps in Android, you code in Java. If you create Native apps in iOS, you code in Obj-C or Swift. Both of these are powerful but complex languages. &lt;strong&gt;With Ionic you can write a single piece of code for your app that can run on both iOS and Android &lt;/strong&gt;and web (as PWA), that too with the simplicity of HTML, CSS, and JS.&lt;/p&gt;
&lt;p&gt;It is important to note the contribution of Cordova/Capacitor in this. Ionic is only a UI wrapper made up of HTML, CSS and JS. So, by default, Ionic cannot run as an app in an iOS or Android device. Cordova/Capacitor is the build environment that containerizes (sort of) this Ionic web app and converts it into a device installable app, along with providing this app access to native APIs like Camera, web access etc.&lt;/p&gt;
&lt;h3&gt;Ionic and Payment Gateways&lt;/h3&gt;
&lt;p&gt;Ionic can create a wide variety of apps, and hence a wide variety of payment gateways can be implemented in Ionic apps. The popular ones are PayPal, Stripe, Braintree, in-app purchase etc. For more details on payment gateways, you can read our blogs on &lt;a href="https://medium.com/enappd/payment-solutions-in-ionic-8c4bb28ce5cc" rel="noopener noreferrer"&gt;Payment Gateway Solutions in Ionic&lt;/a&gt;, &lt;a href="https://enappd.com/blog/ionic-5-stripe-payment-integration-firebase-cloud-functions-vs-node-express-based-server/159" rel="noopener noreferrer"&gt;Stripe integration in Ionic&lt;/a&gt;, &lt;a href="https://enappd.com/blog/how-to-integrate-apple-pay-in-ionic-4-apps/21" rel="noopener noreferrer"&gt;Apple pay in Ionic&lt;/a&gt; etc.&lt;/p&gt;
&lt;p&gt;Also, there are different types of Ionic Apps you can build for same functionality. Most popular ones are :&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Front-end: Angular | Build environment : Cordova&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Front-end: Angular | Build environment : Capacitor &lt;strong&gt;✅&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Front-end: React | Build environment : Capacitor&lt;/li&gt;
&lt;li&gt;Front-end: Vue | Build environment : Capacitor&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;PayPal can be integrated in websites as well as mobile apps. In this blog we’ll learn &lt;strong&gt;how to integrate PayPal payment gateway in Angular/Capacitor Ionic 5 apps using Braintree.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;OK, enough of talking, let’s start building our PayPal Braintree Payment System.&lt;/p&gt;
&lt;h3&gt;&lt;strong&gt;Step 1 :- Create Braintree sandbox account and get the required keys&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;This steps is required to proceed further, we will be needing several keys to integrate PayPal in Ionic 5 app as well as in Node JS script. To get these keys go to &lt;a href="https://sandbox.braintreegateway.com/login" rel="noopener noreferrer"&gt;Braintree Sandbox Account&lt;/a&gt;. Once you login, you can go to settings and select API.&lt;/p&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2A4Z_gnQyxm4qzSa1fszFVfA.png"&gt;Braintree Sandbox settings to get API keys&lt;br&gt;&lt;p&gt;In API section, scroll down and you will get the Required API key. We need three keys to initialize Braintree in Node JS scripts&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Merchant Id&lt;/li&gt;
&lt;li&gt;Public Key and&lt;/li&gt;
&lt;li&gt;Private Key&lt;/li&gt;
&lt;/ol&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AQSv8L8ofyjBN6l-voJ3WMQ.png"&gt;Public Key and Private Key in Braintree settings&lt;br&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2Ac3hzrZdf94LcBV4CRPSYsA.png"&gt;Braintree Merchat ID&lt;br&gt;&lt;p&gt;Save these IDs, we will use them in initializing the Braintree on server-side.&lt;/p&gt;
&lt;h3&gt;Step 2&amp;amp;hairsp;—&amp;amp;hairsp;&lt;strong&gt;Setup Ionic 5 project&lt;/strong&gt;
&lt;/h3&gt;
&lt;p&gt;In this part, we will create and configure Ionic 5 Project and also setup new Node JS Script.&lt;/p&gt;
&lt;h4&gt;Creating and configuring the Ionic 5 application.&lt;/h4&gt;
&lt;p&gt;To create new Ionic 5 project, run the below command :-&lt;/p&gt;
&lt;pre&gt;$ ionic start PayPal --blank --type=angular&lt;/pre&gt;
&lt;p&gt;This will create blank app in the working directory and if you want to know more about creating the Ionic 5 project, go to &lt;a href="https://enappd.com/blog/how-to-create-an-ionic-app-for-beginners/144/" rel="noopener noreferrer"&gt;Ionic 5 Beginners Blog&lt;/a&gt;. Now once we have created the Ionic app, we can configure the app for Braintree, to do that flow the below steps.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;a) Add CDN to &lt;/strong&gt;&lt;code&gt;&lt;strong&gt;index.html&lt;/strong&gt;&lt;/code&gt;&lt;strong&gt; file&lt;/strong&gt;&lt;br&gt;How will Ionic app know we want to use Braintree ? Currently there is no Cordova or Capacitor plugin for Braintree. Hence we will add the CDN to parent file i.e. index.html, below is the CDN for Braintree JavaScript SDK.&lt;/p&gt;
&lt;pre&gt;&amp;lt;script src="&lt;a href="https://js.braintreegateway.com/js/braintree-2.32.1.min.js%22&amp;gt;&amp;lt;/script" rel="noopener noreferrer"&gt;https://js.braintreegateway.com/js/braintree-2.32.1.min.js"&amp;amp;gt;&amp;amp;lt;/script&lt;/a&gt;&amp;gt;&lt;/pre&gt;
&lt;p&gt;By adding this SDK CDN, Braintree will be available throughout the application. We can simply use it in any of the pages in our Ionic app.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;b) Using Braintree variable in Ionic 5 application&lt;br&gt;&lt;/strong&gt;Once we import the SDK CDN, we can use the Braintree variable in any page by using below defined syntax&lt;/p&gt;
&lt;pre&gt;declare const braintree;&lt;/pre&gt;
&lt;p&gt;Now later in Payment-gateway page, we will use this variable to setup the Client side application for successful payment.&lt;/p&gt;
&lt;h3&gt;Step 3&amp;amp;hairsp;—&amp;amp;hairsp;Setup Node JS project&lt;/h3&gt;
&lt;p&gt;Create a separate folder for node server. To create Node JS script, we will run&lt;strong&gt; &lt;/strong&gt;&lt;code&gt;&lt;strong&gt;npm init&lt;/strong&gt;&lt;/code&gt; in the working directory .&lt;/p&gt;
&lt;pre&gt;$ npm init&lt;/pre&gt;
&lt;p&gt;Above command will ask few basic questions and creates the &lt;code&gt;package.json&lt;/code&gt; file in working directory. Now you can create the &lt;code&gt;index.js&lt;/code&gt; file (All logic will be contained in index file because we’re making a simple server).&lt;/p&gt;
&lt;p&gt;We have to install some of the libraries that will help in implementing node script. To install the libraries run the below command :-&lt;/p&gt;
&lt;pre&gt;$ npm install &lt;em&gt;cors express braintree body-parser&lt;/em&gt;&lt;/pre&gt;
&lt;p&gt;To know more about &lt;a href="https://www.npmjs.com/package/cors" rel="noopener noreferrer"&gt;&lt;em&gt;cors&lt;/em&gt;&lt;/a&gt;, &lt;a href="https://www.npmjs.com/package/express" rel="noopener noreferrer"&gt;&lt;em&gt;express&lt;/em&gt;&lt;/a&gt;, &lt;a href="https://www.npmjs.com/package/body-parser" rel="noopener noreferrer"&gt;&lt;em&gt;body-parser&lt;/em&gt;&lt;/a&gt; and &lt;a href="https://www.npmjs.com/package/braintree" rel="noopener noreferrer"&gt;&lt;em&gt;braintree&lt;/em&gt;&lt;/a&gt;&lt;em&gt; &lt;/em&gt;you can follow the links. You can also check official &lt;a href="https://ionicframework.com/docs/troubleshooting/cors" rel="noopener noreferrer"&gt;Ionic documentation on CORS&lt;/a&gt; which we believe is very good for understanding.&lt;/p&gt;
&lt;img alt="Project Structure" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2A1-_17l8nH7ybzjl8BD7RxA.jpeg"&gt;Project Structure&lt;br&gt;&lt;p&gt;Now we have all the basic requirements to start our node script.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;&amp;amp;hairsp;—&amp;amp;hairsp;Check your project’s &lt;code&gt;package.json&lt;/code&gt; file, it should contain the value stated below in scripts section. If it doesn’t, just add manually :-&lt;/p&gt;
&lt;img alt="package.json file" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AaueX2NUPIkFc-V1LCwNi7w.png"&gt;package.json file for node server&lt;br&gt;&lt;h3&gt;Step 4&amp;amp;hairsp;—&amp;amp;hairsp;&lt;strong&gt;Creating Node JS APIs for Braintree&lt;/strong&gt;
&lt;/h3&gt;
&lt;p&gt;Creating Braintree APIs will allow us to get the &lt;strong&gt;Client ID&lt;/strong&gt; requested from client side. We will use Braintree package to implement those APIs. First of all, import the Braintree using below command in &lt;code&gt;index.js&lt;/code&gt; file&lt;/p&gt;
&lt;pre&gt;&lt;em&gt;const&lt;/em&gt; braintree = require("braintree");&lt;/pre&gt;
&lt;p&gt;Now using Braintree object to initialize the Braintree Gateway. This initialization requires those keys (which we have saved in step 2) and environment value (i.e. for now we are using &lt;strong&gt;&lt;em&gt;Sandbox&lt;/em&gt;&lt;/strong&gt;, later you can use production value). Use the below command to initialize the Gateway.&lt;/p&gt;
&lt;pre&gt;&lt;em&gt;const&lt;/em&gt; gateway = new braintree.BraintreeGateway({&lt;br&gt;  environment: braintree.Environment.Sandbox,&lt;br&gt;  merchantId: "USE_YOUR_MERCHENT_ID",&lt;br&gt;  publicKey: "USE_YOUR_PUBLIC_KEY",&lt;br&gt;  privateKey: "USE_YOUR_PRIVATE_KEY"&lt;br&gt;});&lt;/pre&gt;
&lt;p&gt;This Gateway object will be used to get the &lt;strong&gt;Client ID&lt;/strong&gt; and used in doing transaction.&lt;/p&gt;
&lt;h4&gt;Payment Flow with Braintree&lt;/h4&gt;
&lt;p&gt;The following flowchart will get you up to speed with the payment flow. With this in mind, you’ll be able to better follow the code steps given further&lt;/p&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AkAd0KmHKlhYfMVmYrAxHPg.png"&gt;Braintree Payment flow with Ionic app and node server&lt;br&gt;&lt;p&gt;First our Ionic application will call the Node JS API that will return the CLIENT ID generated using API mentioned below :-&lt;/p&gt;
&lt;pre&gt;app.get("/brainTreeClientToken", (&lt;em&gt;req&lt;/em&gt;, &lt;em&gt;res&lt;/em&gt;) &lt;em&gt;=&amp;gt;&lt;/em&gt; {&lt;br&gt;  gateway.clientToken.generate({}).then((&lt;em&gt;response&lt;/em&gt;) &lt;em&gt;=&amp;gt;&lt;/em&gt; {&lt;br&gt;  &lt;em&gt;console&lt;/em&gt;.log('Token', response);&lt;br&gt;  res.send(response);&lt;br&gt; });&lt;br&gt;});&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;‘/brainTreeClientToken’&lt;/strong&gt; API will be called from Ionic app using &lt;strong&gt;HTTP Client&lt;/strong&gt; (later we will see in step 4). Once client side (Ionic app-side) gets the token it will setup the Braintree using setup call (will see in step 4). After setup, client will initiate payment using Pay with PayPal button. Clicking PayPal button will open In App Browser and sandbox will create a random user and provide info containing nonce (token string used in making transaction successful).&lt;/p&gt;
&lt;p&gt;For making transaction, we will create Node JS API that will checkout payment using amount and nonce. Below is the transaction API :-&lt;/p&gt;
&lt;pre&gt;app.post("/checkoutWithPayment", jsonParser, (&lt;em&gt;req&lt;/em&gt;, &lt;em&gt;res&lt;/em&gt;) &lt;em&gt;=&amp;gt;&lt;/em&gt; {&lt;br&gt;  &lt;em&gt;const&lt;/em&gt; nonceFromTheClient = req.body.nonceFromTheClient;&lt;br&gt;  &lt;em&gt;const&lt;/em&gt; payment = req.body.paymentAmount;&lt;br&gt;  gateway.transaction.sale({&lt;br&gt;    amount: payment,&lt;br&gt;    paymentMethodNonce: nonceFromTheClient,&lt;br&gt;    options: {&lt;br&gt;      submitForSettlement: true&lt;br&gt;    }&lt;br&gt;  }).then((&lt;em&gt;result&lt;/em&gt;) &lt;em&gt;=&amp;gt;&lt;/em&gt; {&lt;br&gt;      res.send(result);&lt;br&gt;  });&lt;br&gt;});&lt;/pre&gt;
&lt;p&gt;In above API &lt;strong&gt;nonceFromTheClient &lt;/strong&gt;and &lt;strong&gt;paymentAmount &lt;/strong&gt;will be passed through Ionic 5 app and using gateway object will make a transaction. This will return a transaction status containing complete info about customer, payment and also contains status of payment. This will complete the flow of payment using PayPal. Below is the complete script code :-&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;In the above script, you can replace &lt;code&gt;route&lt;/code&gt; in the &lt;code&gt;app.listen&lt;/code&gt; with the port &lt;code&gt;3000&lt;/code&gt; . So it becomes &lt;code&gt;app.listen(3000,()=&amp;gt;...&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;You can also create &lt;code&gt;.catch&lt;/code&gt; for the &lt;code&gt;.generate&lt;/code&gt; and &lt;code&gt;.sale&lt;/code&gt; methods in the server. This way, if you get any error from Braintree server, you will be able to see that in node server terminal&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Run the server using &lt;code&gt;npm start&lt;/code&gt; or if you want to deploy code to some cloud server you can do that as well. If you’re running the server in local system, the APIs will have a &lt;code&gt;localhost&lt;/code&gt; URL. You can test web payments directly in local system. For phone payments you might have to deploy the node server on a cloud.&lt;/p&gt;
&lt;h3&gt;Step 5&amp;amp;hairsp;—&amp;amp;hairsp;&lt;strong&gt;Braintree integration in Ionic App using Node JS APIs&lt;/strong&gt;
&lt;/h3&gt;
&lt;p&gt;In this part we will go through client side (Ionic app) integration, using which we can make the PayPal transaction. We have seen how to initialize Braintree in Ionic app (stated in step 2).&lt;/p&gt;
&lt;pre&gt;declare const braintree&lt;/pre&gt;
&lt;p&gt;Following method can be used to retrieve client ID from server. This method will be called during Braintree setup.&lt;/p&gt;
&lt;pre&gt;async getClientTokenForPaypal() {&lt;br&gt; return await&lt;br&gt;this.http.get('&lt;a href="http://localhost:3000/brainTreeClientToken').toPromise(" rel="noopener noreferrer"&gt;http://localhost:3000/brainTreeClientToken').toPromise(&lt;/a&gt;);&lt;br&gt;}&lt;/pre&gt;
&lt;p&gt;Now we can setup Braintree using below code. &lt;strong&gt;Notice that the &lt;/strong&gt;&lt;code&gt;&lt;strong&gt;.setup&lt;/strong&gt;&lt;/code&gt;&lt;strong&gt; is the function which defines for the first time that we are going to use PayPal as the payment gateway, using Braintree as the provider.&lt;/strong&gt;&lt;/p&gt;
&lt;blockquote&gt;Keep in mind this setup will require the CLIENT_ID that will be generated by server API (mentioned in Step 3). So first we will call the server API and then pass the CLIENT_ID to setup method. You can call this function when page loads ( i.e. in ngOnInit() or ionViewWillEnter() methods).&lt;/blockquote&gt;
&lt;pre&gt;initalizeBrainTree() {&lt;br&gt;  &lt;em&gt;const&lt;/em&gt; that = this;&lt;br&gt;  this.getClientTokenForPaypal().then((&lt;em&gt;res&lt;/em&gt;: &lt;em&gt;any&lt;/em&gt;) &lt;em&gt;=&amp;gt;&lt;/em&gt; {&lt;br&gt;    &lt;em&gt;let&lt;/em&gt; checkout;&lt;br&gt;    braintree.setup(res.clientToken, 'custom', {&lt;br&gt;      paypal: {&lt;br&gt;        container: 'paypal-container',&lt;br&gt;      },&lt;br&gt;      onReady: &lt;em&gt;function&lt;/em&gt; (&lt;em&gt;integration&lt;/em&gt;) {&lt;br&gt;        checkout = integration;&lt;br&gt;      },&lt;br&gt;      onCancelled: (&lt;em&gt;obj&lt;/em&gt;) &lt;em&gt;=&amp;gt;&lt;/em&gt; {&lt;br&gt;        &lt;em&gt;console&lt;/em&gt;.log('Cancelled', obj);&lt;br&gt;        checkout.teardown(() &lt;em&gt;=&amp;gt;&lt;/em&gt; { checkout = null });&lt;br&gt;      },&lt;br&gt;      onPaymentMethodReceived: (&lt;em&gt;obj&lt;/em&gt;) &lt;em&gt;=&amp;gt;&lt;/em&gt; {&lt;br&gt;        checkout.teardown(() &lt;em&gt;=&amp;gt;&lt;/em&gt; {&lt;br&gt;          checkout = null;&lt;br&gt;          that.handleBraintreePayment(obj.nonce);&lt;br&gt;        });&lt;br&gt;      }&lt;br&gt;   });&lt;br&gt;  });&lt;br&gt;}&lt;/pre&gt;
&lt;p&gt;In above method, first we call the &lt;code&gt;getClientTokenForPaypal()&lt;/code&gt; method that will call the Node JS server &lt;code&gt;brainTreeClientToken&lt;/code&gt; API and returns the token. Once we get client token, we can setup Braintree using it. This setup method will initialize the PayPal-container that will be used to render the PayPal button in HTML file.&lt;/p&gt;
&lt;p&gt;Once the client token is obtained, Paypal button will be automatically rendered in HTML file in this place. Make sure you have this in your HTML file&lt;/p&gt;
&lt;pre&gt;&amp;lt;ion-button class="paypalBtn" id="paypal-container"&amp;gt;&amp;lt;/ion-button&amp;gt;&lt;/pre&gt;
&lt;p&gt;This will render the Paypal button in Page view and will look like below screen :-&lt;/p&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AMvORSvPtD4H1XJWxH7aS-A.jpeg"&gt;Paypal button rendered in Ionic HTML view after client ID is obtained&lt;br&gt;&lt;p&gt;Now we have completed the setup and we can make payment using this button. When we click the button it will open the In-app Browser and sandbox will handle the payment and users info. This will return the nonce value in the callback defined in setup call.&lt;/p&gt;
&lt;p&gt;One more thing we have to keep in mind that sometimes, PayPal payment screen does not go off when we make a payment (due to some screen refresh angular issues). To remove it manually, we have to use &lt;strong&gt;teardown()&lt;/strong&gt; method defined in checkout variable (initialized on &lt;strong&gt;onReady()&lt;/strong&gt; callback).&lt;/p&gt;
&lt;pre&gt;onReady: &lt;em&gt;function&lt;/em&gt; (&lt;em&gt;integration&lt;/em&gt;) {&lt;br&gt;  checkout = integration;&lt;br&gt;},&lt;/pre&gt;
&lt;p&gt;Below is the callback that will handle the nonce token and pass on to other method that will handle the transaction.&lt;/p&gt;
&lt;pre&gt;onPaymentMethodReceived: (&lt;em&gt;obj&lt;/em&gt;) &lt;em&gt;=&amp;gt;&lt;/em&gt; {&lt;br&gt;   checkout.teardown(() &lt;em&gt;=&amp;gt;&lt;/em&gt; {&lt;br&gt;     checkout = null;&lt;br&gt;     that.handleBraintreePayment(obj.nonce);&lt;br&gt;   });&lt;br&gt;}&lt;/pre&gt;
&lt;p&gt;We will pass the nonce value to &lt;strong&gt;handleBraintreePayment()&lt;/strong&gt; method that will further call the transaction API defined in Node JS server. Here you can console the final response after payment.&lt;/p&gt;
&lt;pre&gt;async handleBraintreePayment(&lt;em&gt;nonce&lt;/em&gt;) {&lt;br&gt;  this.api.makePaymentRequest(this.payableAmount,    nonce).then((&lt;em&gt;transaction&lt;/em&gt;) &lt;em&gt;=&amp;gt;&lt;/em&gt; {&lt;br&gt;  &lt;em&gt;console&lt;/em&gt;.log('Transaction', transaction);&lt;br&gt;  })&lt;br&gt;}&lt;/pre&gt;
&lt;p&gt;Above &lt;strong&gt;makePaymentRequest()&lt;/strong&gt; method will call the transaction API defined in Node JS server, that will make the original payment using Braintree. Below is the function call :-&lt;/p&gt;
&lt;pre&gt;async makePaymentRequest(&lt;em&gt;amount&lt;/em&gt;, &lt;em&gt;nonce&lt;/em&gt;) {&lt;br&gt;  &lt;em&gt;const&lt;/em&gt; paymentDetails = {&lt;br&gt;    paymentAmount: amount,&lt;br&gt;    nonceFromTheClient: nonce&lt;br&gt;  }&lt;br&gt;  return await   this.http.post('&lt;a href="http://localhost:3000/checkoutWithPayment" rel="noopener noreferrer"&gt;http://localhost:3000/checkoutWithPayment&lt;/a&gt;', paymentDetails).toPromise();&lt;br&gt;}&lt;/pre&gt;
&lt;p&gt;Above function will contain the paymentAmount and nonce value and will passed them to the server API. That will return the transaction object and we can decide the client end logic according to the response that we get from server. This will complete the PayPal Braintree integration from both client side and server side.&lt;/p&gt;
&lt;h3&gt;Step 6&amp;amp;hairsp;—&amp;amp;hairsp;Testing&lt;/h3&gt;
&lt;p&gt;As mentioned earlier, it is easy to test this setup in a web domain, because the server can run on localhost, and the Ionic app can call the server while running with &lt;code&gt;ionic serve&lt;/code&gt; . Here how the payment flow looks&lt;/p&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2A-YE2LgNaTROcl-RbMYBNhg.gif"&gt;PayPal payment in Ionic app using Braintree&lt;br&gt;&lt;p&gt;To test it in your device, you will need to deploy the server on a cloud so you can call the APIs from the app. If there is a way you can call localhost APIs from your app (I don’t know any), that should work as well !&lt;/p&gt;
&lt;h3&gt;Troubleshooting&lt;/h3&gt;
&lt;h4&gt;&lt;strong&gt;&amp;gt;&amp;gt; braintree is not defined&lt;/strong&gt;&lt;/h4&gt;
&lt;p&gt;Check if you included the Braintree script in &lt;code&gt;index.html&lt;/code&gt;&lt;/p&gt;
&lt;h4&gt;&amp;gt;&amp;gt; Authentication error in API&lt;/h4&gt;
&lt;p&gt;Check if you have entered correct API keys and Merchant Id in node server. Also check if you are using Production keys in Sandbox, or vice versa&lt;/p&gt;
&lt;h3&gt;Conclusion :-&lt;/h3&gt;
&lt;p&gt;Congratulations !! 🎉 You just learnt how to integrate the awesome Braintree payment system to make payments using PayPal.&lt;/p&gt;
&lt;p&gt;You can make payments using both PayPal account and Debit / Credit Cards. This way of integration can work both in Web view and mobile apps. If you want to know more about any feature integration, you can check out our amazing tutorials at &lt;a href="https://enappd.com/blog/" rel="noopener noreferrer"&gt;Enappd Blogs&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Happy coding !&lt;/p&gt;

&lt;h3&gt;Next Steps&lt;/h3&gt;
&lt;p&gt;If you liked this blog, you will also find the following blogs interesting and helpful. Feel free to ask any questions in the comment section&lt;/p&gt;

&lt;h3&gt;Ionic Capacitor&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Basic&lt;/strong&gt;&amp;amp;hairsp;—&amp;amp;hairsp;&lt;a href="https://enappd.com/blog/use-geolocation-geocoding-and-reverse-geocoding-in-ionic-capacitor/131" rel="noopener nofollow noreferrer"&gt;Geolocation&lt;/a&gt; | &lt;a href="https://enappd.com/blog/qr-code-and-barcode-scanning-with-ionic-capacitor/127" rel="noopener nofollow noreferrer"&gt;Barcode &amp;amp; QR code&lt;/a&gt; | &lt;a href="https://enappd.com/blog/facebook-login-in-capacitor-apps-with-ionic-angular/128" rel="noopener nofollow noreferrer"&gt;Facebook Login&lt;/a&gt; (Angular) | &lt;a href="https://enappd.com/blog/facebook-login-in-ionic-react-capacitor-apps/118" rel="noopener nofollow noreferrer"&gt;Facebook Login (React)&lt;/a&gt; | &lt;a href="https://enappd.com/blog/icon-splash-in-ionic-react-capacitor-apps/114" rel="noopener nofollow noreferrer"&gt;Icon and Splash&lt;/a&gt; | &lt;a href="https://enappd.com/blog/camera-and-gallery-in-ionic-react-app-using-capacitor/110" rel="noopener nofollow noreferrer"&gt;Camera &amp;amp; Photo Gallery&lt;/a&gt; | &lt;a href="https://enappd.com/blog/debugging-ionic-apps-using-chrome-and-safari-developers-tools/167" rel="noopener noreferrer"&gt;Debugging with browser&lt;/a&gt;|&lt;a href="https://enappd.com/blog/make-awesome-theme-switcher-in-ionic-5/170" rel="noopener noreferrer"&gt;Theming in Ionic apps&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Advanced&lt;/strong&gt;&amp;amp;hairsp;—&amp;amp;hairsp;&lt;a href="https://enappd.com/blog/implement-admob-in-ionic-react-capacitor-apps/135" rel="noopener nofollow noreferrer"&gt;AdMob&lt;/a&gt; | &lt;a href="https://enappd.com/blog/local-notifications-in-ionic-5-capacitor/132" rel="noopener nofollow noreferrer"&gt;Local Notifications&lt;/a&gt; | &lt;a href="https://enappd.com/blog/google-login-in-ionic-react-capacitor-apps/122" rel="noopener nofollow noreferrer"&gt;Google Login&lt;/a&gt; | &lt;a href="https://enappd.com/blog/twitter-login-in-ionic-react-capacitor-app/121" rel="noopener nofollow noreferrer"&gt;Twitter Login&lt;/a&gt; | &lt;a href="https://enappd.com/blog/html5-games-in-ionic-capacitor-using-phaser/115" rel="noopener nofollow noreferrer"&gt;Games using Phaser&lt;/a&gt; | &lt;a href="https://enappd.com/blog/play-music-in-ionic-capacitor-apps/112" rel="noopener nofollow noreferrer"&gt;Play music&lt;/a&gt; | &lt;a href="https://enappd.com/blog/firebase-push-notification-in-ionic-react-capacitor/111" rel="noopener nofollow noreferrer"&gt;Push Notifications&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Ionic Cordova&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://enappd.com/blog/ionic-app-with-nodejs-express-mysql-sequelize-taxi-app/160" rel="noopener nofollow noreferrer"&gt;Taxi Booking App example with Ionic, Node, Express and MySQL&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Ionic Payment Gateways&amp;amp;hairsp;—&amp;amp;hairsp;&lt;a href="https://enappd.com/blog/integrate-stripe-payment-gateway-in-ionic-5-apps-and-pwa-using-firebase/158" rel="noopener nofollow noreferrer"&gt;Stripe with Firebase&lt;/a&gt; | &lt;a href="https://enappd.com/blog/ionic-5-stripe-payment-integration-firebase-cloud-functions-vs-node-express-based-server/159" rel="noopener nofollow noreferrer"&gt;Stripe with NodeJS&lt;/a&gt; | &lt;a href="https://enappd.com/blog/paypal-integration-in-ionic-apps-and-pwa/142" rel="noopener nofollow noreferrer"&gt;PayPal&lt;/a&gt; |&lt;a href="https://enappd.com/blog/paypal-payment-integration-using-braintree-in-ionic-5-apps/177/" rel="noopener noreferrer"&gt;PayPal with Braintree&lt;/a&gt;| &lt;a href="https://enappd.com/blog/how-to-integrate-apple-pay-in-ionic-4-apps/21" rel="noopener nofollow noreferrer"&gt;Apple Pay&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-integrate-razorpay-in-ionic-4-apps-and-pwa/20" rel="noopener nofollow noreferrer"&gt;RazorPay&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Ionic Charts with&amp;amp;hairsp;—&amp;amp;hairsp;&lt;a href="https://enappd.com/blog/ionic-4-charts-using-google-charts/66" rel="noopener nofollow noreferrer"&gt;Google Charts &lt;/a&gt;| &lt;a href="https://enappd.com/blog/adding-charts-in-ionic-4-apps-and-pwa-part-3/60" rel="noopener nofollow noreferrer"&gt;HighCharts&lt;/a&gt; | &lt;a href="https://enappd.com/blog/adding-charts-in-ionic-4-apps-and-pwa-part-2/54" rel="noopener nofollow noreferrer"&gt;d3.js&lt;/a&gt; | &lt;a href="https://enappd.com/blog/charts-in-ionic-4-apps-and-pwa-part-1/52" rel="noopener nofollow noreferrer"&gt;Chart.js&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Ionic Authentications&amp;amp;hairsp;—&amp;amp;hairsp;&lt;a href="https://enappd.com/blog/firebase-email-authentication-in-ionic-apps/153" rel="noopener nofollow noreferrer"&gt;Via Email&lt;/a&gt; | &lt;a href="https://enappd.com/blog/implement-anonymous-login-in-ionic-apps-with-firebase/154" rel="noopener nofollow noreferrer"&gt;Anonymous&lt;/a&gt; | &lt;a href="https://enappd.com/blog/facebook-login-in-ionic-apps-using-firebase/150" rel="noopener nofollow noreferrer"&gt;Facebook&lt;/a&gt; | &lt;a href="https://enappd.com/blog/implement-google-login-in-ionic-apps-using-firebase/147" rel="noopener nofollow noreferrer"&gt;Google&lt;/a&gt; | &lt;a href="https://enappd.com/blog/twitter-login-in-ionic-4-apps-using-firebase/24" rel="noopener nofollow noreferrer"&gt;Twitter&lt;/a&gt; | &lt;a href="https://enappd.com/blog/firebase-phone-authentication-in-ionic-5-apps/169" rel="noopener noreferrer"&gt;Via Phone&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Ionic Features&amp;amp;hairsp;—&amp;amp;hairsp;&lt;a href="https://enappd.com/blog/ionic-5-complete-guide-on-geolocation/141" rel="noopener nofollow noreferrer"&gt;Geolocation&lt;/a&gt;| &lt;a href="https://enappd.com/blog/ionic-complete-guide-barcode-qrcode-scan/140" rel="noopener nofollow noreferrer"&gt;QR Code reader&lt;/a&gt; | &lt;a href="https://enappd.com/blog/best-fitness-plugins-for-ionic-4-how-to-use-pedometer/15" rel="noopener nofollow noreferrer"&gt;Pedometer&lt;/a&gt;| &lt;a href="https://enappd.com/blog/implement-signature-pad-in-ionic-apps/145" rel="noopener nofollow noreferrer"&gt;Signature&lt;/a&gt; &lt;a href="https://enappd.com/blog/implement-signature-pad-in-ionic-apps/145" rel="noopener noreferrer"&gt;Pad&lt;/a&gt; | &lt;a href="https://enappd.com/blog/using-background-geolocation-in-ionic-angular-apps/165" rel="noopener nofollow noreferrer"&gt;Background Geolocation&lt;/a&gt; | &lt;a href="https://enappd.com/blog/detect-wifi-and-data-network-in-ionic-5-apps/173" rel="noopener noreferrer"&gt;Network Detection&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Media in Ionic&amp;amp;hairsp;—&amp;amp;hairsp;&lt;a href="https://enappd.com/blog/spotify-like-music-in-ionic-4-apps/48" rel="noopener nofollow noreferrer"&gt;Audio&lt;/a&gt; | &lt;a href="https://enappd.com/blog/adding-video-player-in-ionic-4-app/64" rel="noopener nofollow noreferrer"&gt;Video&lt;/a&gt; | &lt;a href="https://enappd.com/blog/camera-and-image-picker-in-ionic-apps/148" rel="noopener nofollow noreferrer"&gt;Image Picker&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-add-image-cropper-in-ionic-apps/149" rel="noopener nofollow noreferrer"&gt;Image Cropper&lt;/a&gt; | &lt;a href="https://enappd.com/blog/implement-sounds-and-vibration-in-ionic-apps/172" rel="noopener noreferrer"&gt;Sounds and Vibrations&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Ionic Essentials&amp;amp;hairsp;—&amp;amp;hairsp;&lt;a href="https://enappd.com/blog/debugging-ionic-apps-using-chrome-and-safari-developers-tools/167" rel="noopener noreferrer"&gt;Debugging with browser&lt;/a&gt;| &lt;a href="https://enappd.com/blog/ionic-4-save-and-retrieve-data-locally-on-device/59" rel="noopener nofollow noreferrer"&gt;Native Storage&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-translate-in-ionic-internationalization-and-localization/143" rel="noopener nofollow noreferrer"&gt;Translations&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-use-rtl-right-to-left-in-ionic-apps-pwa/152" rel="noopener nofollow noreferrer"&gt;RTL&lt;/a&gt; | &lt;a href="https://enappd.com/blog/using-sentry-error-monitoring-with-ionic-angular-applications/164" rel="noopener nofollow noreferrer"&gt;Sentry Error Monitoring&lt;/a&gt; | &lt;a href="https://enappd.com/blog/social-sharing-component-in-ionic-5-mobile-web-apps/168" rel="noopener noreferrer"&gt;Social sharing&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-generate-and-download-pdf-in-ionic-apps/174" rel="noopener noreferrer"&gt;PDF generation&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Ionic messaging&amp;amp;hairsp;—&amp;amp;hairsp;&lt;a href="https://enappd.com/blog/how-to-implement-firebase-push-notifications-in-ionic-apps/157" rel="noopener nofollow noreferrer"&gt;Firebase Push&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-automatically-read-sms-in-ionic-5-apps/175" rel="noopener noreferrer"&gt;Reading SMS&lt;/a&gt; | &lt;a href="https://enappd.com/blog/local-notifications-in-ionic-5-capacitor/132" rel="noopener nofollow noreferrer"&gt;Local Notifications&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Ionic with Firebase&amp;amp;hairsp;—&amp;amp;hairsp;&lt;a href="https://enappd.com/blog/how-to-integrate-firebase-in-ionic-4-apps/23" rel="noopener nofollow noreferrer"&gt;Basics&lt;/a&gt; | &lt;a href="https://enappd.com/blog/firebase-with-ionic-4-hosting-auth-and-db-connection/58" rel="noopener nofollow noreferrer"&gt;Hosting and DB&lt;/a&gt; | &lt;a href="https://enappd.com/blog/firebase-cloud-functions-in-ionic-5-complete-guide/166" rel="noopener noreferrer"&gt;Cloud functions&lt;/a&gt; | &lt;a href="https://enappd.com/blog/github-actions-deploying-ionic-angular-app-to-firebase-hosting/146" rel="noopener nofollow noreferrer"&gt;Deploy App to Firebase&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-use-firebase-emulators-with-ionic-angular-applications/163" rel="noopener nofollow noreferrer"&gt;Firebase simulator&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Unit Testing in Ionic&amp;amp;hairsp;—&amp;amp;hairsp;&lt;a href="https://enappd.com/blog/beginners-guide-to-ionic-angular-unit-testing-part-1/151" rel="noopener nofollow noreferrer"&gt;Part 1&lt;/a&gt; | &lt;a href="https://enappd.com/blog/beginners-guide-to-ionic-angular-unit-testing-part-2-mocks-and-spies/155" rel="noopener nofollow noreferrer"&gt;Mocks &amp;amp; Spies&lt;/a&gt;| &lt;a href="https://enappd.com/blog/beginners-guide-to-ionic-angular-unit-testing-async-testing/156" rel="noopener nofollow noreferrer"&gt;Async Testing&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Ionic React Full App with Capacitor&lt;/h3&gt;
&lt;p&gt;If you need a base to start your next Ionic 5 React Capacitor app, you can make your next awesome app using &lt;a href="https://store.enappd.com/product/ionic-react-full-app-capacitor/" rel="noopener noreferrer"&gt;Ionic 5 React Full App in Capacitor&lt;/a&gt;&lt;/p&gt;
&lt;img alt="Ionic 5 React Full App in Capacitor from Enappd" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AG3yOFVX4oABx9MhUy-3kng.png"&gt;Ionic 5 React Full App in Capacitor from Enappd&lt;br&gt;&lt;h3&gt;Ionic Capacitor Full App (Angular)&lt;/h3&gt;
&lt;p&gt;If you need a base to start your next Angular &lt;strong&gt;Capacitor app&lt;/strong&gt;, you can make your next awesome app using &lt;a href="https://store.enappd.com/product/capacitor-full-app-with-ionic-angular/" rel="noopener nofollow noreferrer"&gt;Capacitor Full App&lt;/a&gt;&lt;/p&gt;
&lt;img alt="Capacitor Full App with huge number of layouts and features" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AUwSHcofTMStMnzAX.png"&gt;Capacitor Full App with huge number of layouts and features&lt;br&gt;&lt;h3&gt;Ionic Full App (Angular and Cordova)&lt;/h3&gt;
&lt;p&gt;If you need a base to start your next Ionic 5 app, you can make your next awesome app using &lt;a href="https://store.enappd.com/product/ionic-full-app" rel="noopener noreferrer"&gt;Ionic 5 Full App&lt;/a&gt;&lt;/p&gt;
&lt;img alt="Ionic Full App with huge number of layouts and features" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2A1ArpKyhiDHZnevwB.jpeg"&gt;Ionic Full App in Cordova, with huge number of layouts and features&lt;br&gt;

</description>
      <category>ionic</category>
      <category>paypal</category>
      <category>braintree</category>
      <category>payment</category>
    </item>
    <item>
      <title>Google login in Ionic Capacitor app with Angular</title>
      <dc:creator>Abhijeet Rathore</dc:creator>
      <pubDate>Sun, 22 Aug 2021 16:32:19 +0000</pubDate>
      <link>https://forem.com/enappd/google-login-in-ionic-capacitor-app-with-angular-1igd</link>
      <guid>https://forem.com/enappd/google-login-in-ionic-capacitor-app-with-angular-1igd</guid>
      <description>
&lt;p&gt;In this post, you’ll learn how to implement &lt;strong&gt;Google login&lt;/strong&gt; in your Ionic Angular Capacitor apps. We will also retrieve user name and profile photo to show after login. &lt;strong&gt;We will test the authentication on Web, Android and iOS.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Since Google login is applicable in a lot of app frameworks, it is possible you landed here by (SEO) mistake. If you are looking for Google login in&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Ionic Angular (Cordova) apps —&amp;amp;hairsp;Please check &lt;a href="https://enappd.com/blog/google-login-in-ionic-4-apps-using-firebase/39" rel="noopener nofollow noopener"&gt;this post&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;React Native&amp;amp;hairsp;—&amp;amp;hairsp;Please check this for &lt;a href="https://enappd.com/blog/google-login-in-react-native-android-apps-with-firebase/90" rel="noopener nofollow noopener"&gt;Android&lt;/a&gt; and &lt;a href="https://enappd.com/blog/google-login-in-react-native-apps-with-firebase/88" rel="noopener nofollow noopener"&gt;iOS&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Ionic React Capacitor Apps —Check &lt;a href="https://enappd.com/blog/google-login-in-ionic-react-capacitor-apps/122" rel="noopener"&gt;this post&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Ionic Angular Capacitor Apps&amp;amp;hairsp;—&amp;amp;hairsp;Continue reading 🙂&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;As you can see from above, there are several options available for Hybrid app development these days, and it is easy to get confused between them. This post is focussed on &lt;strong&gt;Ionic framework&lt;/strong&gt; with &lt;strong&gt;Angular&lt;/strong&gt; as the front-end framework, and &lt;a href="https://capacitor.ionicframework.com/docs/" rel="noopener nofollow noopener"&gt;&lt;strong&gt;Capacitor&lt;/strong&gt;&lt;/a&gt; as runtime and build environment.&lt;/p&gt;
&lt;p&gt;Let’s see a brief intro to each of the included frameworks:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Ionic&lt;/li&gt;
&lt;li&gt;Capacitor&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;What is Ionic ?&lt;/h3&gt;
&lt;p&gt;In short&amp;amp;hairsp;—&amp;amp;hairsp;If you create Native apps in Android, you code in Java/Kotlin. If you create Native apps in iOS, you code in Obj-C or Swift. Both of these are powerful but complex languages. &lt;strong&gt;With Ionic and Capacitor you can write a single piece of code for your app that can run on both iOS and Android &lt;/strong&gt;(and web!), that too with the simplicity of HTML, CSS, and JS.&lt;/p&gt;
&lt;p&gt;It is important to note the contribution of Capacitor in this. Ionic is a UI + functionality wrapper made up of HTML, CSS and JS. So, by default, Ionic cannot run as an app in an iOS or Android device. Capacitor is the build environment that containerizes (sort of) this Ionic web app and converts it into a device installable app, along with providing this app access to native APIs like Camera etc.&lt;/p&gt;
&lt;h3&gt;Capacitor&amp;amp;hairsp;—&amp;amp;hairsp;How is it different from Cordova ?&lt;/h3&gt;
&lt;blockquote&gt;&lt;strong&gt;&lt;em&gt;Capacitor is very similar to Cordova, but with some key differences in the app workflow&lt;/em&gt;&lt;/strong&gt;&lt;/blockquote&gt;
&lt;p&gt;You might be familiar with the popular hybrid technology Cordova. So why are we using Capacitor? Cordova helps build Ionic web app into a device installable app. But there are some limitations of Cordova, which Capacitor tries to overcome with a new App workflow.&lt;/p&gt;
&lt;p&gt;Capacitor is a cross-platform app runtime that makes it easy to build web apps that run natively on iOS, Android, Electron, &lt;em&gt;and&lt;/em&gt; the web. Ionic people call these apps “Native Progressive Web Apps” and they represent the next evolution beyond Hybrid apps.&lt;/p&gt;
&lt;p&gt;Here are few differences between Cordova and Capacitor&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Capacitor considers each platform project a &lt;em&gt;source asset&lt;/em&gt; instead of a &lt;em&gt;build time asset&lt;/em&gt;. That means, Capacitor wants you to keep the platform source code in the repository, unlike Cordova which always assumes that you will generate the platform code on build time&lt;/li&gt;
&lt;li&gt;Since platform code is a &lt;em&gt;source asset, &lt;/em&gt;you can directly change the native code using Xcode or Android Studio. This give more flexibility to developers. We will do some similar changes for Google login as well.&lt;/li&gt;
&lt;li&gt;Capacitor has great PWA support in-built&lt;/li&gt;
&lt;li&gt;Capacitor CLI is locally installed, so different apps can have different Capacitor versions in your system&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;You can read more about Capacitor vs Cordova in &lt;a href="https://ionic.io/resources/articles/capacitor-vs-cordova-modern-hybrid-app-development" rel="noopener"&gt;this article by Ionic&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;Plugins&lt;/h3&gt;
&lt;p&gt;Capacitor has its own set of plugins available in the core itself, or with @capacitor-community, but it can also support Cordova plugins. For Google login functionality, we’ll use the &lt;a href="https://github.com/CodetrixStudio/CapacitorGoogleAuth" rel="noopener"&gt;CapacitorGoogleAuth&lt;/a&gt; plugin by &lt;a href="https://github.com/CodetrixStudio" rel="author noopener noopener"&gt;CodetrixStudio&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Capacitor plugins require a bit of configuration editing in Android and iOS files, but you don’t need any Android and iOS native expertise for that. Just follow along with the tutorial and you’ll find it very easy to implement Google login in Capacitor.&lt;/p&gt;
&lt;h3&gt;A word on Google authentication&lt;/h3&gt;
&lt;p&gt;We will use the &lt;a href="https://github.com/CodetrixStudio/CapacitorGoogleAuth" rel="noopener"&gt;CapacitorGoogleAuth&lt;/a&gt; plugin by &lt;a href="https://github.com/CodetrixStudio" rel="author noopener noopener noopener"&gt;CodetrixStudio&lt;/a&gt; to authenticate the user. Once the login is done, we receive user profile information in auth response itself. Hence, there is no need to fetch user’s profile information separately.&lt;/p&gt;
&lt;p&gt;This Google Auth plugin supports 2 functions, across web, Android and iOS&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Login&lt;/li&gt;
&lt;li&gt;Logout&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Also note that this plugin only helps you to login and logout using Google Auth. As you’ll see, the process of Google login involves creating a Firebase project etc. but this plugin does not connect your authenticated user directly to Firebase project.&lt;/p&gt;
&lt;p&gt;In other words, there are two ways you can use Google login&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Confirm user’s authenticity from Google login, and then save the user info in your own Database. This is true if you already have a server and DB defined for your project&lt;/li&gt;
&lt;li&gt;Confirm user’s authenticity from Google login, and then save user info in the same Firebase project itself. It is a convenient and faster way. More about this in &lt;strong&gt;Step 2 and further&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Structure of post&lt;/h3&gt;
&lt;p&gt;I always go step-by-step for readers of all experience level. If you know certain steps, feel free to skip them&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; Create a basic Ionic Angular Capacitor app&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 2&lt;/strong&gt;: Create a Google project for authentication&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 3: &lt;/strong&gt;Setup Google Login Plugin and functions&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 4&lt;/strong&gt;: Prepare and Test on Web&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 5: &lt;/strong&gt;Build and Test your app on Android&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 6: &lt;/strong&gt;Build and Test your app on iOS&lt;/p&gt;
&lt;p&gt;Let’s get started with Ionic Angular Capacitor Google login !&lt;/p&gt;
&lt;h3&gt;Step 1&amp;amp;hairsp;—&amp;amp;hairsp;Create a basic Ionic Angular Capacitor app&lt;/h3&gt;
&lt;p&gt;Here’s my environment&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Node 14.x+&lt;/li&gt;
&lt;li&gt;Capacitor 3.0+&lt;/li&gt;
&lt;li&gt;Angular 12+&lt;/li&gt;
&lt;li&gt;NPM 7+&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;First you need to make sure you have the latest Ionic CLI. This will ensure you are using everything latest. Ensure latest Ionic CLI installation using&lt;/p&gt;
&lt;pre&gt;$ npm install -g ionic@latest&lt;/pre&gt;
&lt;p&gt;Creating a basic Ionic-React app is not much different or difficult from creating a basic Ionic-Angular app. Start a basic &lt;code&gt;blank&lt;/code&gt; starter using&lt;/p&gt;
&lt;pre&gt;$ ionic start IonNgCapGoogleLogin blank --type=angular --capacitor&lt;/pre&gt;
&lt;p&gt;The CLI options are pretty self-explanatory.&lt;/p&gt;
&lt;p&gt;Run the app in browser using&lt;/p&gt;
&lt;pre&gt;$ ionic serve&lt;/pre&gt;
&lt;p&gt;You won’t see much in the homepage created in the blank starter. Let’s modify this page to include a button, icon and a title for login. Also, I have created a LandingPage, where the user is redirected after successful login. The user profile information in this page comes after login and single API call.&lt;/p&gt;
&lt;img alt="Login and Home page for Ionic Angular Capacitor Google Login demo app" src="https://res.cloudinary.com/practicaldev/image/fetch/s--uLDHA88m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2APYiW0eD5KiRZQoCeXwRUoA.png"&gt;Login and Home page for Ionic Angular Capacitor Google Login demo app&lt;br&gt;&lt;h4&gt;Attach Capacitor to existing app&lt;/h4&gt;
&lt;blockquote&gt;
&lt;strong&gt;Note&lt;/strong&gt;: Unlike earlier, now you don’t have to attach Capacitor separately to your Ionic apps. When you run the &lt;code&gt;&lt;em&gt;ionic start&lt;/em&gt;&lt;/code&gt; command with &lt;code&gt;&lt;em&gt;--Capacitor&lt;/em&gt;&lt;/code&gt; option, it attaches Capacitor to the app automatically.&lt;/blockquote&gt;
&lt;p&gt;If by change you forgot to attach Capacitor which creating the app, it can be attached to an existing Ionic app as well. To attach Capacitor to your existing Ionic app, run&lt;/p&gt;
&lt;pre&gt;$ ionic integrations enable capacitor&lt;/pre&gt;
&lt;p&gt;This will attach Capacitor to your Ionic app. After this, you have to &lt;code&gt;init&lt;/code&gt; the Capacitor app with&lt;/p&gt;
&lt;pre&gt;$ npx cap init&lt;/pre&gt;
&lt;p&gt;It will ask you the app name and ID. Give app name whatever you want. App ID is the domain identifier of your app (ex: &lt;code&gt;com.example.app&lt;/code&gt;). Note this ID as this will be required later when you create app in Google developer console. In my case, the ID is &lt;code&gt;com.enappd.IonNgCapGoogleLogin&lt;/code&gt; ( too long, I know)&lt;/p&gt;
&lt;h3&gt;Step 2&amp;amp;hairsp;—&amp;amp;hairsp;Create a Google project&lt;/h3&gt;
&lt;p&gt;To implement a Google login, you will need a Google app/project. A Google project can serve as a single point of control for your Google login, analytics, AdMob, push notifications, API keys for Map and several other services etc.&lt;/p&gt;
&lt;h4&gt;2.1 Create new project&lt;/h4&gt;
&lt;p&gt;Create a project in &lt;a href="https://console.cloud.google.com/" rel="noopener nofollow noopener"&gt;Google Developer console&lt;/a&gt; or create it in &lt;a href="https://console.firebase.google.com/" rel="noopener nofollow noopener"&gt;Firebase Console&lt;/a&gt; (recommended). Both consoles are essentially integrated with each other.&lt;br&gt;&lt;strong&gt;More details about creating a Firebase project can be found &lt;/strong&gt;&lt;a href="https://enappd.com/blog/how-to-integrate-firebase-in-ionic-4-apps/23" rel="noopener nofollow noopener"&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;.&lt;/strong&gt;&lt;/p&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pziXBWt0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/0%2AYQGvGRldPI-aamrK.png"&gt;Create a project in &lt;a href="https://console.cloud.google.com/" rel="noopener nofollow noopener noopener"&gt;Google Developer console&lt;/a&gt;&lt;br&gt;&lt;h4&gt;2.2 Requirements for different project types&lt;/h4&gt;
&lt;h4&gt;Web&lt;/h4&gt;
&lt;p&gt;As soon as you make a Google project in either Google Developer console or Firebase console, a &lt;code&gt;web-client-ID&lt;/code&gt; is automatically generated. For web-login, you only need this &lt;code&gt;web-client-ID&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;More in Step 2.4 and Step 4.&lt;/p&gt;
&lt;h4&gt;Android&lt;/h4&gt;
&lt;p&gt;To implement Google Login in Android, we will have to create an Android app inside our Google project. In this Android app’s settings, we’ll get &lt;code&gt;&lt;em&gt;google-services.json&lt;/em&gt;&lt;/code&gt; file. This files essentially contains the API keys and IDs for the project.&lt;/p&gt;
&lt;p&gt;We’ll also have to attach SHA-1 key from our build system in our Google project’s Android app.&lt;/p&gt;
&lt;p&gt;More in Step 5.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;iOS&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;To implement Google Login in iOS, we will have to create an iOS app inside our Google project. In this iOS app’s settings, we’ll get a&lt;code&gt;google-services.plist&lt;/code&gt; file . This file essentially contains the API keys and IDs for the project.&lt;/p&gt;
&lt;p&gt;For iOS we’ll also have to generate a URL scheme. More in Step 6.&lt;/p&gt;
&lt;h4&gt;2.3 Google-services.&lt;code&gt;plist&lt;/code&gt;
&lt;/h4&gt;
&lt;p&gt;In your Firebase console (of the same project), create a new iOS app. During creation process it will ask you the app bundle ID. Use the bundle ID you used to initialize Capacitor in section 2 (&lt;code&gt;com.enappd.IonNgCapGoogleLogin&lt;/code&gt;). In next step, download the &lt;code&gt;google-services.plist&lt;/code&gt; file.&lt;/p&gt;
&lt;p&gt;If you already have an existing project, download the &lt;code&gt;google-services.plist&lt;/code&gt; from the Project Settings page.&lt;/p&gt;
&lt;img alt="Download google-services.plist from your Firebase iOS project" src="https://res.cloudinary.com/practicaldev/image/fetch/s--6E7mwbik--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/0%2AlZ7fseWFMvnzLt-g.png"&gt;Download &lt;code&gt;google-services.plist from your Firebase iOS project&lt;/code&gt;&lt;br&gt;&lt;h4&gt;2.4 Web-client ID&lt;/h4&gt;
&lt;p&gt;When you create a Google project, a &lt;code&gt;web client ID&lt;/code&gt; is automatically created. You can find this web-client ID in Google Developer console. Note that the web client ID says (Auto created by Google Service). You DO NOT need to create an Android or iOS app in the Google Project to create this web client ID.&lt;/p&gt;
&lt;img alt="Client IDs in Google Developer Console." src="https://res.cloudinary.com/practicaldev/image/fetch/s--t0BjV7Hb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/0%2AYcVI_o1pQjG7fJWT.png"&gt;Client IDs in Google Developer Console.&lt;br&gt;&lt;blockquote&gt;
&lt;em&gt;If you create Android/iOS app in Firebase, you can get web-client ID from the downloaded &lt;/em&gt;&lt;code&gt;&lt;em&gt;google-services.json&lt;/em&gt;&lt;/code&gt;&lt;em&gt; or &lt;/em&gt;&lt;code&gt;google-services.plist&lt;/code&gt;&lt;em&gt;file.&lt;/em&gt;
&lt;/blockquote&gt;
&lt;p&gt;To use web-client ID on &lt;code&gt;ionic serve&lt;/code&gt; or on your website for web login, you need to make sure you include the origin URL in the Web Client ID’s settings&lt;/p&gt;
&lt;img alt="Add Javascript origins to this list to enable login on web platforms" src="https://res.cloudinary.com/practicaldev/image/fetch/s--TQDAUrAE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2A66SENLYhB5TVugyJ_c_ffg.png"&gt;Add Javascript origins to this list to enable login on web platforms&lt;br&gt;&lt;h4&gt;2.5 Web API Key&lt;/h4&gt;
&lt;p&gt;Required only for making a REST API call to get user profile info. Web API Key can be obtained from the Firebase console. It appears after you have at least once entered the Authentication module of Firebase console.&lt;/p&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1mFu9bT---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AVKMG9xnfzsWoWfgCOehnEw.png"&gt;Obtain Web API key from Firebase console&lt;br&gt;&lt;h4&gt;2.6 SHA-1 key&lt;/h4&gt;
&lt;p&gt;For web implementation of Google login, nothing is required in our Google project. But for Android implementation, we need to add Android app in the project. Also, make sure the app ID (com.something.something) you provide when making the Android app in Google project, is the same as your app ID. (Double check in &lt;code&gt;capacitor.config.json&lt;/code&gt; and &lt;code&gt;capacitor.config.ts&lt;/code&gt; )&lt;/p&gt;
&lt;img alt="Add an Android app in Google Project (Firebase Console)" src="https://res.cloudinary.com/practicaldev/image/fetch/s--z7NLOAL1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AUn2kJmK2J2K9eZef057BMQ.png"&gt;Add an Android app in Google Project (Firebase Console)&lt;br&gt;&lt;p&gt;Now create a SHA-1 key of your system. This key is specific to&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Your system (laptop/PC)&lt;/li&gt;
&lt;li&gt;Your app’s &lt;code&gt;.keystore&lt;/code&gt; file&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Use following commands to generate SHA-1 key&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ keytool -list -v -keystore &amp;lt;&amp;lt;YOUR_APP_KEYSTORE_PATH&amp;gt;&amp;gt; -alias &amp;lt;&amp;lt;KEYSTORE_ALIAS&amp;gt;&amp;gt; -storepass &amp;lt;&amp;lt;PASSWORD&amp;gt;&amp;gt; -keypass &amp;lt;&amp;lt;KEY_PASSWORD&amp;gt;&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;All the above info (alias, keystore, passwords) should be same as the one you used when creating the Keystore file.&lt;/p&gt;
&lt;p&gt;Add this SHA-1 key in Android App setting of your Google project&lt;/p&gt;
&lt;img alt="Add SHA-1 key in your Google Project’s Android App" src="https://res.cloudinary.com/practicaldev/image/fetch/s--7mGSmRLj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2APgR3knzGSAOp-0WROxVf4Q.png"&gt;Add SHA-1 key in your Google Project’s Android App&lt;br&gt;&lt;h3&gt;Step 3&amp;amp;hairsp;—&amp;amp;hairsp;Setup Google Login Plugin and functions&lt;/h3&gt;
&lt;p&gt;To setup Google login in the app, we’ll do following things&lt;/p&gt;
&lt;p&gt;4.1 Install &lt;a href="https://github.com/CodetrixStudio/CapacitorGoogleAuth" rel="noopener"&gt;CapacitorGoogleAuth&lt;/a&gt; plugin by &lt;a href="https://github.com/CodetrixStudio" rel="author noopener noopener noopener"&gt;CodetrixStudio&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;4.2 Setup plugin functions for login&lt;/p&gt;
&lt;p&gt;4.3 Navigate and Send data between two pages of the app&lt;/p&gt;
&lt;p&gt;4.4 Sign Out&lt;/p&gt;
&lt;p&gt;4.5 Detect already logged in users&lt;/p&gt;
&lt;h4&gt;4.1 Install Capacitor Google Auth plugin&lt;/h4&gt;
&lt;p&gt;Install the plugin using&lt;/p&gt;
&lt;pre&gt;$ npm i --save @codetrix-studio/capacitor-google-auth&lt;/pre&gt;
&lt;p&gt;Add the following info in your &lt;code&gt;capacitor.config.json&lt;/code&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;strong&gt;Note&lt;/strong&gt;: Capacitor 3.0+ uses &lt;code&gt;capacitor.config.ts&lt;/code&gt; by default. You’ll have to create the &lt;code&gt;capacitor.config.json&lt;/code&gt; in root folder, and copy the content from the &lt;code&gt;.ts&lt;/code&gt; filem and add the following info. This is plugin specific&lt;/blockquote&gt;
&lt;pre&gt;...&lt;br&gt;"plugins": {&lt;br&gt; "GoogleAuth": {&lt;br&gt;  "scopes": ["profile","email"],&lt;br&gt;  "serverClientId": "160012889513-qkxxxxxxxxxxxxxxxxxxxxxxxxkgubrp5ve.apps.googleusercontent.com"&lt;br&gt;}&lt;br&gt;}&lt;br&gt;...&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;serverClientId&lt;/code&gt; is basically the web-client ID itself. Import the plugin in app’s pages using&lt;/p&gt;
&lt;pre&gt;import { GoogleAuth } from '@codetrix-studio/capacitor-google-auth';&lt;/pre&gt;
&lt;h4&gt;4.2 Setup plugin functions for login&lt;/h4&gt;
&lt;p&gt;We have to setup few functions for Google Auth functionality&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;init&lt;/strong&gt;&amp;amp;hairsp;—&amp;amp;hairsp;GoogleAuth.init()&amp;amp;hairsp;—&amp;amp;hairsp;Initializes the plugin, required only in Web. This can be called at the page load. Avoid on device, or it will throw error.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;signIn&lt;/strong&gt;—GoogleAuth.signIn()&amp;amp;hairsp;—&amp;amp;hairsp;Signs you in with a popup on web, and native functionality in device. This should be called after init(). The success of this function will given user profile data as response. Based on this response you can navigate user in your app.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;signOut&lt;/strong&gt;&amp;amp;hairsp;—&amp;amp;hairsp;GoogleAuth.signOut()&amp;amp;hairsp;—&amp;amp;hairsp;Signs you out from Google. Based on success of this method, you can navigate user out of your app.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;refresh&lt;/strong&gt;&amp;amp;hairsp;—&amp;amp;hairsp;GoogleAuth.refresh()&amp;amp;hairsp;—&amp;amp;hairsp;At app start (or at any point), it can check if you are already logged in. This can be helpful if you want to auto-login users who have logged in once.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;I believe you can handle the HTML and CSS part of the pages yourself. The login code for &lt;code&gt;Home.page.ts&lt;/code&gt; looks like this&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;h4&gt;4.3 Enable routing between two pages of the app&lt;/h4&gt;
&lt;p&gt;The user data from Auth response can be sent to Landing Page using &lt;code&gt;NavigationExtras&lt;/code&gt; . Here’s what you need to add to &lt;code&gt;home.page.ts&lt;/code&gt; for navigating with data (where &lt;code&gt;user&lt;/code&gt; is the response object from &lt;code&gt;GoogleAuth.singIn&lt;/code&gt;)&lt;/p&gt;
&lt;pre&gt;import { Router, NavigationExtras } from '@angular/router';&lt;br&gt;.... &lt;/pre&gt;
&lt;pre&gt;export class HomePage {&lt;br&gt;  constructor(private router: Router) { }&lt;br&gt;  ...&lt;/pre&gt;
&lt;pre&gt;goToHome(user) {&lt;br&gt; let navigationExtras: NavigationExtras = { state: { user: user } };&lt;br&gt; this.router.navigate(['landing'], navigationExtras);&lt;br&gt;}&lt;/pre&gt;
&lt;p&gt;In &lt;code&gt;landing.page.ts&lt;/code&gt;, you can receive the data as follows&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;p&gt;This way, you have logged in, and received the profile info of the user 🎉&lt;/p&gt;
&lt;h4&gt;4.4 Sign out&lt;/h4&gt;
&lt;p&gt;Once user is successfully logged in, we redirect user to &lt;code&gt;Landing&lt;/code&gt; page. And when user logs out, we want to come back to &lt;code&gt;Home&lt;/code&gt; page.&lt;/p&gt;
&lt;p&gt;Sign out can be implemented with the following code on button click&lt;/p&gt;
&lt;pre&gt;signOut() {&lt;br&gt; GoogleAuth.signOut().then(() =&amp;gt; {&lt;br&gt;  this.router.navigate(['home']);&lt;br&gt; });&lt;br&gt;}&lt;/pre&gt;
&lt;h4&gt;4.5 Detect already logged in user / Auto-login&lt;/h4&gt;
&lt;p&gt;In most of the apps, if you have logged in once, next time you open the app, you don’t have to login again. This can be done with our plugin as well.&lt;/p&gt;
&lt;p&gt;We can detect already logged in user with &lt;code&gt;GoogleAuth.refresh()&lt;/code&gt; method, Here’s the implementation and the resulting full code for &lt;code&gt;home.page.ts&lt;/code&gt;&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;p&gt;So, on button click we check if user is already logged in using &lt;code&gt;checkLoggedIn()&lt;/code&gt; . If user is logged in, we send the user to Landing page with corresponding data. If not logged in, we go through the normal sign in route.&lt;/p&gt;
&lt;p&gt;Once the user is detected as already logged in, we send the app user to Landing page with &lt;code&gt;accessToken&lt;/code&gt; . This &lt;code&gt;accessToken&lt;/code&gt; can then be used in a REST API call to get user’s profile info. Here’s the full code for &lt;code&gt;landing.page.ts&lt;/code&gt; including getting the user’s profile info with REST API Call.&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;p&gt;Here, &lt;code&gt;YOUR_WEB_API_KEY&lt;/code&gt; is your web API key of Google project, which you obtained in Step 2.5&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;&lt;a href="https://www.googleapis.com/oauth2/v2/userinfo"&gt;https://www.googleapis.com/oauth2/v2/userinfo&lt;/a&gt;&lt;/code&gt; end-point gives us the user’s profile info.&lt;/p&gt;
&lt;blockquote&gt;
&lt;strong&gt;Note&lt;/strong&gt; : I have used Capacitor Http plugin to make the API call. This is because this plugin can make API calls from all platforms while avoiding CORS and other issues. You can learn more on&lt;a href="https://github.com/capacitor-community/http" rel="noopener"&gt; the plugin page&lt;/a&gt;
&lt;/blockquote&gt;
&lt;h3&gt;Step 4: Prepare and Test on Web&lt;/h3&gt;
&lt;p&gt;To implement Google Auth in web app with Capacitor, add this meta tag to head in &lt;code&gt;index.html&lt;/code&gt; file.&lt;/p&gt;
&lt;pre&gt;&amp;lt;meta name="google-signin-client_id" content="{your client id here}"&amp;gt;&lt;/pre&gt;
&lt;p&gt;With all the above code in place, web Google login can be tested in &lt;code&gt;ionic serve&lt;/code&gt; itself. Here’s how it will work on browser&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Normal login -&amp;gt; Navigates to Landing page -&amp;gt; Signout -&amp;gt; Back to home page&lt;/li&gt;
&lt;li&gt;Normal login -&amp;gt;Navigates to Landing page | Refresh app on home page to simulate existing login on app start -&amp;gt; Takes you directly to Landing page&lt;/li&gt;
&lt;/ol&gt;
&lt;img alt="Google login on Web&amp;amp;hairsp;—&amp;amp;hairsp;Ionic Capacitor Angular app" src="https://res.cloudinary.com/practicaldev/image/fetch/s--wJ6MciST--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2Aw4fwpWdypeEAxNDQp5Cfcw.gif"&gt;Google login on Web&amp;amp;hairsp;—&amp;amp;hairsp;Ionic Capacitor Angular app&lt;br&gt;&lt;p&gt;The response object user will output all auth info of the user as shown in following image&lt;/p&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CWRvO3g9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2Ag8RdOSjVTRbJbJlmOm1nXA.png"&gt;Auth response object on Google Login&lt;br&gt;&lt;p&gt;As you can see, you get all the required info in this response object. The response object obtained on the REST API call (as explained in Step 4.5) looks a little different. The profile photo comes under the property &lt;code&gt;picture&lt;/code&gt; instead of &lt;code&gt;imageUrl&lt;/code&gt;&lt;/p&gt;
&lt;h3&gt;Step 5&amp;amp;hairsp;—&amp;amp;hairsp;Build and Test your app on Android&lt;/h3&gt;
&lt;h4&gt;Create and configure platform&lt;/h4&gt;
&lt;p&gt;To build the app on Android, run these commands&lt;/p&gt;
&lt;pre&gt;// Add android platform&lt;br&gt;$ &lt;strong&gt;npx cap add android&lt;br&gt;&lt;/strong&gt;// Copy all changes to Android platform&lt;br&gt;$ &lt;strong&gt;npx cap sync&lt;br&gt;&lt;/strong&gt;// Open the project in Android studio&lt;br&gt;$ &lt;strong&gt;npx cap open android&lt;/strong&gt;&lt;/pre&gt;
&lt;p&gt;Also, add the following in your &lt;code&gt;strings.xml&lt;/code&gt; file in Android Project&lt;/p&gt;
&lt;pre&gt;&amp;lt;resources&amp;gt;&lt;br&gt;  &amp;lt;string name="server_client_id"&amp;gt;Your Web Client ID&amp;lt;/string&amp;gt;&lt;br&gt;&amp;lt;/resources&amp;gt;&lt;/pre&gt;
&lt;blockquote&gt;
&lt;strong&gt;Note&lt;/strong&gt;: As of Capacitor 3.0, you do not need to add the plugin in the &lt;code&gt;MainActivity.java&lt;/code&gt; file&lt;/blockquote&gt;
&lt;h4&gt;Avoid unimplemented methods&lt;/h4&gt;
&lt;p&gt;Build the app on Android device using Android studio. Make sure you detect the platform of device and NOT run &lt;code&gt;GoogleAuth.init()&lt;/code&gt; and &lt;code&gt;GoogleAuth.refresh()&lt;/code&gt; methods. These are currently not implemented in the plugin. Directly use &lt;code&gt;GoogleAuth.singIn()&lt;/code&gt; . Something like this needs to be added&lt;/p&gt;
&lt;pre&gt;import { Platform } from '@ionic/angular';&lt;br&gt;....&lt;br&gt;export class HomePage {&lt;br&gt; constructor(private platform: Platform, private router: Router) {&lt;br&gt;  this.isWeb = !this.platform.is('android') &amp;amp;&amp;amp;    !this.platform.is('ios');&lt;br&gt; }&lt;br&gt; checkLoggedIn() {&lt;br&gt;  if(this.isWeb){&lt;br&gt;   //run web implementation with init() and refresh()&lt;br&gt;  }&lt;br&gt;  else{&lt;br&gt;  // direct GoogleAuth.signIn()}&lt;br&gt;  }&lt;br&gt; }&lt;br&gt;}&lt;/pre&gt;
&lt;h4&gt;Make sure&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;You have added SHA-1 key to your Google project’s Android app settings &lt;strong&gt;as per Step 2.6&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Your app ID is same as the one you added in Google project’s Android app (and in &lt;code&gt;capacitor.config.json&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;With these settings, your Google login should work fine in Android. Following GIF shows the login flow in my Android device.&lt;/p&gt;
&lt;img alt="Google login in Ionic Angular Capacitor App&amp;amp;hairsp;—&amp;amp;hairsp;Android" src="https://res.cloudinary.com/practicaldev/image/fetch/s--fLPkHMEC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2Az-tXqAXUngzPJvCwp47mbg.gif"&gt;Google login in Ionic Angular Capacitor App&amp;amp;hairsp;—&amp;amp;hairsp;Android&lt;br&gt;&lt;h3&gt;Step 6&amp;amp;hairsp;—&amp;amp;hairsp;Build and Test your app on iOS&lt;/h3&gt;
&lt;h4&gt;Create and configure platform&lt;/h4&gt;
&lt;p&gt;To build the app on iOS, run these commands&lt;/p&gt;
&lt;pre&gt;// Add android platform&lt;br&gt;$ &lt;strong&gt;npx cap add ios&lt;br&gt;&lt;/strong&gt;// Copy all changes to iOS platform&lt;br&gt;$ &lt;strong&gt;npx cap sync&lt;br&gt;&lt;/strong&gt;// Open the project in XCode&lt;br&gt;$ &lt;strong&gt;npx cap open ios&lt;/strong&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;Place your downloaded&lt;code&gt;GoogleService.plist&lt;/code&gt; in &lt;code&gt;ios/App/App&lt;/code&gt; folder&lt;/li&gt;
&lt;li&gt;Find &lt;code&gt;REVERSED_CLIENT_ID&lt;/code&gt; from the &lt;code&gt;GoogleService.plist&lt;/code&gt; and add it as a URL scheme in &lt;code&gt;info.plist&lt;/code&gt; of Xcode&lt;/li&gt;
&lt;/ul&gt;
&lt;img alt="Add REVERSE_CLIENT_ID as URL scheme" src="https://res.cloudinary.com/practicaldev/image/fetch/s--6kjidwUL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/0%2AONMatwaQVGDmJu0c.png"&gt;Add &lt;code&gt;REVERSE_CLIENT_ID&lt;/code&gt; as URL scheme&lt;br&gt;&lt;h4&gt;Make sure&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;You have created iOS app in Google Project as per Step 2.3&lt;/li&gt;
&lt;li&gt;You have added &lt;code&gt;GoogleServices-Info.plist&lt;/code&gt; in &lt;code&gt;ios/App/App&lt;/code&gt; folder. Cross-check by checking in XCode&lt;/li&gt;
&lt;li&gt;You have added required URL scheme as mentioned is last paragraph&lt;/li&gt;
&lt;/ul&gt;
&lt;img alt="Make sure XCode shows the GoogleServices-Info.plist added" src="https://res.cloudinary.com/practicaldev/image/fetch/s--22wz29dG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2ACdWOkdjUjZmrAiL8nGXpSQ.png"&gt;Make sure XCode shows the &lt;code&gt;GoogleServices-Info.plist added&lt;/code&gt;&lt;br&gt;&lt;p&gt;Build the app on iOS device or Simulator using Xcode. You should be able to login via Google, and reach the inner page where you see the user information. Following GIF shows the login flow in my iPhone simulator&lt;/p&gt;
&lt;img alt="Google login in Ionic React Capacitor App&amp;amp;hairsp;—&amp;amp;hairsp;iOS" src="https://res.cloudinary.com/practicaldev/image/fetch/s--hFSaW5Ju--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AbG_skxM2kYF71mHEseE46g.gif"&gt;Google login in Ionic React Capacitor App&amp;amp;hairsp;—&amp;amp;hairsp;iOS&lt;br&gt;&lt;h3&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;In this post you learnt how to implement Google login in your Ionic Angular Capacitor app. Social logins are very important part of your apps, as they make users trust your apps more. It is also easy to use, and users don’t have to remember any passwords. You can always link the Social logins with your server as well.&lt;/p&gt;
&lt;p&gt;We also tested the Authentication on all three devices&amp;amp;hairsp;—&amp;amp;hairsp;Android, iOS and Web. This creates a complete set of devices a user can use with your app.&lt;/p&gt;
&lt;p&gt;Google Login is a complex one among social logins. Make sure you follow all the steps very carefully.&lt;/p&gt;

&lt;h3&gt;Next Steps&lt;/h3&gt;
&lt;p&gt;If you liked this blog, you will also find the following blogs interesting and helpful. Feel free to ask any questions in the comment section&lt;/p&gt;

&lt;h3&gt;Ionic Capacitor&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Basic&lt;/strong&gt;&amp;amp;hairsp;—&amp;amp;hairsp;&lt;a href="https://enappd.com/blog/use-geolocation-geocoding-and-reverse-geocoding-in-ionic-capacitor/131" rel="noopener nofollow noopener noopener noopener"&gt;Geolocation&lt;/a&gt; | &lt;a href="https://enappd.com/blog/qr-code-and-barcode-scanning-with-ionic-capacitor/127" rel="noopener nofollow noopener noopener noopener"&gt;Barcode &amp;amp; QR code&lt;/a&gt; | &lt;a href="https://enappd.com/blog/facebook-login-in-capacitor-apps-with-ionic-angular/128" rel="noopener nofollow noopener noopener noopener"&gt;Facebook Login&lt;/a&gt; (Angular) | &lt;a href="https://enappd.com/blog/facebook-login-in-ionic-react-capacitor-apps/118" rel="noopener nofollow noopener noopener noopener"&gt;Facebook Login (React)&lt;/a&gt; | &lt;a href="https://enappd.com/blog/icon-splash-in-ionic-react-capacitor-apps/114" rel="noopener nofollow noopener noopener noopener"&gt;Icon and Splash&lt;/a&gt; | &lt;a href="https://enappd.com/blog/camera-and-gallery-in-ionic-react-app-using-capacitor/110" rel="noopener nofollow noopener noopener noopener"&gt;Camera &amp;amp; Photo Gallery&lt;/a&gt; | &lt;a href="https://enappd.com/blog/debugging-ionic-apps-using-chrome-and-safari-developers-tools/167" rel="noopener"&gt;Debugging with browser&lt;/a&gt;|&lt;a href="https://enappd.com/blog/make-awesome-theme-switcher-in-ionic-5/170" rel="noopener"&gt;Theming in Ionic apps&lt;/a&gt; | &lt;a href="https://enappd.com/blog/google-login-in-ionic-capacitor-app-with-angular/178/" rel="noopener"&gt;Google Login (Angular)&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Advanced&lt;/strong&gt;&amp;amp;hairsp;—&amp;amp;hairsp;&lt;a href="https://enappd.com/blog/implement-admob-in-ionic-react-capacitor-apps/135" rel="noopener nofollow noopener noopener noopener"&gt;AdMob&lt;/a&gt; | &lt;a href="https://enappd.com/blog/local-notifications-in-ionic-5-capacitor/132" rel="noopener nofollow noopener noopener noopener"&gt;Local Notifications&lt;/a&gt; | &lt;a href="https://enappd.com/blog/google-login-in-ionic-react-capacitor-apps/122" rel="noopener nofollow noopener noopener noopener"&gt;Google Login&lt;/a&gt; | &lt;a href="https://enappd.com/blog/twitter-login-in-ionic-react-capacitor-app/121" rel="noopener nofollow noopener noopener noopener"&gt;Twitter Login&lt;/a&gt; | &lt;a href="https://enappd.com/blog/html5-games-in-ionic-capacitor-using-phaser/115" rel="noopener nofollow noopener noopener noopener"&gt;Games using Phaser&lt;/a&gt; | &lt;a href="https://enappd.com/blog/play-music-in-ionic-capacitor-apps/112" rel="noopener nofollow noopener noopener noopener"&gt;Play music&lt;/a&gt; | &lt;a href="https://enappd.com/blog/firebase-push-notification-in-ionic-react-capacitor/111" rel="noopener nofollow noopener noopener noopener"&gt;Push Notifications&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Ionic Cordova&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://enappd.com/blog/ionic-app-with-nodejs-express-mysql-sequelize-taxi-app/160" rel="noopener nofollow noopener noopener noopener"&gt;Taxi Booking App example with Ionic, Node, Express and MySQL&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Ionic Payment Gateways&amp;amp;hairsp;—&amp;amp;hairsp;&lt;a href="https://enappd.com/blog/integrate-stripe-payment-gateway-in-ionic-5-apps-and-pwa-using-firebase/158" rel="noopener nofollow noopener noopener noopener"&gt;Stripe with Firebase&lt;/a&gt; | &lt;a href="https://enappd.com/blog/ionic-5-stripe-payment-integration-firebase-cloud-functions-vs-node-express-based-server/159" rel="noopener nofollow noopener noopener noopener"&gt;Stripe with NodeJS&lt;/a&gt; | &lt;a href="https://enappd.com/blog/paypal-integration-in-ionic-apps-and-pwa/142" rel="noopener nofollow noopener noopener noopener"&gt;PayPal&lt;/a&gt; |&lt;a href="https://enappd.com/blog/paypal-payment-integration-using-braintree-in-ionic-5-apps/177/" rel="noopener"&gt;PayPal with Braintree&lt;/a&gt;| &lt;a href="https://enappd.com/blog/how-to-integrate-apple-pay-in-ionic-4-apps/21" rel="noopener nofollow noopener noopener noopener"&gt;Apple Pay&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-integrate-razorpay-in-ionic-4-apps-and-pwa/20" rel="noopener nofollow noopener noopener noopener"&gt;RazorPay&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Ionic Charts with&amp;amp;hairsp;—&amp;amp;hairsp;&lt;a href="https://enappd.com/blog/ionic-4-charts-using-google-charts/66" rel="noopener nofollow noopener noopener noopener"&gt;Google Charts &lt;/a&gt;| &lt;a href="https://enappd.com/blog/adding-charts-in-ionic-4-apps-and-pwa-part-3/60" rel="noopener nofollow noopener noopener noopener"&gt;HighCharts&lt;/a&gt; | &lt;a href="https://enappd.com/blog/adding-charts-in-ionic-4-apps-and-pwa-part-2/54" rel="noopener nofollow noopener noopener noopener"&gt;d3.js&lt;/a&gt; | &lt;a href="https://enappd.com/blog/charts-in-ionic-4-apps-and-pwa-part-1/52" rel="noopener nofollow noopener noopener noopener"&gt;Chart.js&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Ionic Authentications&amp;amp;hairsp;—&amp;amp;hairsp;&lt;a href="https://enappd.com/blog/firebase-email-authentication-in-ionic-apps/153" rel="noopener nofollow noopener noopener noopener"&gt;Via Email&lt;/a&gt; | &lt;a href="https://enappd.com/blog/implement-anonymous-login-in-ionic-apps-with-firebase/154" rel="noopener nofollow noopener noopener noopener"&gt;Anonymous&lt;/a&gt; | &lt;a href="https://enappd.com/blog/facebook-login-in-ionic-apps-using-firebase/150" rel="noopener nofollow noopener noopener noopener"&gt;Facebook&lt;/a&gt; | &lt;a href="https://enappd.com/blog/implement-google-login-in-ionic-apps-using-firebase/147" rel="noopener nofollow noopener noopener noopener"&gt;Google&lt;/a&gt; | &lt;a href="https://enappd.com/blog/twitter-login-in-ionic-4-apps-using-firebase/24" rel="noopener nofollow noopener noopener noopener"&gt;Twitter&lt;/a&gt; | &lt;a href="https://enappd.com/blog/firebase-phone-authentication-in-ionic-5-apps/169" rel="noopener"&gt;Via Phone&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Ionic Features&amp;amp;hairsp;—&amp;amp;hairsp;&lt;a href="https://enappd.com/blog/ionic-5-complete-guide-on-geolocation/141" rel="noopener nofollow noopener noopener noopener"&gt;Geolocation&lt;/a&gt;| &lt;a href="https://enappd.com/blog/ionic-complete-guide-barcode-qrcode-scan/140" rel="noopener nofollow noopener noopener noopener"&gt;QR Code reader&lt;/a&gt; | &lt;a href="https://enappd.com/blog/best-fitness-plugins-for-ionic-4-how-to-use-pedometer/15" rel="noopener nofollow noopener noopener noopener"&gt;Pedometer&lt;/a&gt;| &lt;a href="https://enappd.com/blog/implement-signature-pad-in-ionic-apps/145" rel="noopener nofollow noopener noopener noopener"&gt;Signature&lt;/a&gt; &lt;a href="https://enappd.com/blog/implement-signature-pad-in-ionic-apps/145" rel="noopener"&gt;Pad&lt;/a&gt; | &lt;a href="https://enappd.com/blog/using-background-geolocation-in-ionic-angular-apps/165" rel="noopener nofollow noopener noopener noopener"&gt;Background Geolocation&lt;/a&gt; | &lt;a href="https://enappd.com/blog/detect-wifi-and-data-network-in-ionic-5-apps/173" rel="noopener"&gt;Network Detection&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Media in Ionic&amp;amp;hairsp;—&amp;amp;hairsp;&lt;a href="https://enappd.com/blog/spotify-like-music-in-ionic-4-apps/48" rel="noopener nofollow noopener noopener noopener"&gt;Audio&lt;/a&gt; | &lt;a href="https://enappd.com/blog/adding-video-player-in-ionic-4-app/64" rel="noopener nofollow noopener noopener noopener"&gt;Video&lt;/a&gt; | &lt;a href="https://enappd.com/blog/camera-and-image-picker-in-ionic-apps/148" rel="noopener nofollow noopener noopener noopener"&gt;Image Picker&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-add-image-cropper-in-ionic-apps/149" rel="noopener nofollow noopener noopener noopener"&gt;Image Cropper&lt;/a&gt; | &lt;a href="https://enappd.com/blog/implement-sounds-and-vibration-in-ionic-apps/172" rel="noopener"&gt;Sounds and Vibrations&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Ionic Essentials&amp;amp;hairsp;—&amp;amp;hairsp;&lt;a href="https://enappd.com/blog/debugging-ionic-apps-using-chrome-and-safari-developers-tools/167" rel="noopener"&gt;Debugging with browser&lt;/a&gt;| &lt;a href="https://enappd.com/blog/ionic-4-save-and-retrieve-data-locally-on-device/59" rel="noopener nofollow noopener noopener noopener"&gt;Native Storage&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-translate-in-ionic-internationalization-and-localization/143" rel="noopener nofollow noopener noopener noopener"&gt;Translations&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-use-rtl-right-to-left-in-ionic-apps-pwa/152" rel="noopener nofollow noopener noopener noopener"&gt;RTL&lt;/a&gt; | &lt;a href="https://enappd.com/blog/using-sentry-error-monitoring-with-ionic-angular-applications/164" rel="noopener nofollow noopener noopener noopener"&gt;Sentry Error Monitoring&lt;/a&gt; | &lt;a href="https://enappd.com/blog/social-sharing-component-in-ionic-5-mobile-web-apps/168" rel="noopener"&gt;Social sharing&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-generate-and-download-pdf-in-ionic-apps/174" rel="noopener"&gt;PDF generation&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Ionic messaging&amp;amp;hairsp;—&amp;amp;hairsp;&lt;a href="https://enappd.com/blog/how-to-implement-firebase-push-notifications-in-ionic-apps/157" rel="noopener nofollow noopener noopener noopener"&gt;Firebase Push&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-automatically-read-sms-in-ionic-5-apps/175" rel="noopener"&gt;Reading SMS&lt;/a&gt; | &lt;a href="https://enappd.com/blog/local-notifications-in-ionic-5-capacitor/132" rel="noopener nofollow noopener noopener noopener"&gt;Local Notifications&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Ionic with Firebase&amp;amp;hairsp;—&amp;amp;hairsp;&lt;a href="https://enappd.com/blog/how-to-integrate-firebase-in-ionic-4-apps/23" rel="noopener nofollow noopener noopener noopener"&gt;Basics&lt;/a&gt; | &lt;a href="https://enappd.com/blog/firebase-with-ionic-4-hosting-auth-and-db-connection/58" rel="noopener nofollow noopener noopener noopener"&gt;Hosting and DB&lt;/a&gt; | &lt;a href="https://enappd.com/blog/firebase-cloud-functions-in-ionic-5-complete-guide/166" rel="noopener"&gt;Cloud functions&lt;/a&gt; | &lt;a href="https://enappd.com/blog/github-actions-deploying-ionic-angular-app-to-firebase-hosting/146" rel="noopener nofollow noopener noopener noopener"&gt;Deploy App to Firebase&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-use-firebase-emulators-with-ionic-angular-applications/163" rel="noopener nofollow noopener noopener noopener"&gt;Firebase simulator&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Unit Testing in Ionic&amp;amp;hairsp;—&amp;amp;hairsp;&lt;a href="https://enappd.com/blog/beginners-guide-to-ionic-angular-unit-testing-part-1/151" rel="noopener nofollow noopener noopener noopener"&gt;Part 1&lt;/a&gt; | &lt;a href="https://enappd.com/blog/beginners-guide-to-ionic-angular-unit-testing-part-2-mocks-and-spies/155" rel="noopener nofollow noopener noopener noopener"&gt;Mocks &amp;amp; Spies&lt;/a&gt;| &lt;a href="https://enappd.com/blog/beginners-guide-to-ionic-angular-unit-testing-async-testing/156" rel="noopener nofollow noopener noopener noopener"&gt;Async Testing&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Ionic Capacitor Full App (Angular)&lt;/h3&gt;
&lt;p&gt;If you need a base to start your next Angular &lt;strong&gt;Capacitor app&lt;/strong&gt;, you can make your next awesome app using &lt;a href="https://store.enappd.com/product/capacitor-full-app-with-ionic-angular/" rel="noopener nofollow noopener noopener noopener noopener"&gt;Capacitor Full App&lt;/a&gt;&lt;/p&gt;
&lt;img alt="Capacitor Full App with huge number of layouts and features" src="https://res.cloudinary.com/practicaldev/image/fetch/s--jbZt2zIJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/0%2AUwSHcofTMStMnzAX.png"&gt;Capacitor Full App with huge number of layouts and features&lt;br&gt;&lt;h3&gt;Ionic React Full App with Capacitor&lt;/h3&gt;
&lt;p&gt;If you need a base to start your next Ionic 5 React Capacitor app, you can make your next awesome app using &lt;a href="https://store.enappd.com/product/ionic-react-full-app-capacitor/" rel="noopener"&gt;Ionic 5 React Full App in Capacitor&lt;/a&gt;&lt;/p&gt;
&lt;img alt="Ionic 5 React Full App in Capacitor from Enappd" src="https://res.cloudinary.com/practicaldev/image/fetch/s--Z0sRDsyI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AG3yOFVX4oABx9MhUy-3kng.png"&gt;Ionic 5 React Full App in Capacitor from Enappd&lt;br&gt;&lt;h3&gt;Ionic Full App (Angular and Cordova)&lt;/h3&gt;
&lt;p&gt;If you need a base to start your next Ionic 5 app, you can make your next awesome app using &lt;a href="https://store.enappd.com/product/ionic-full-app" rel="noopener"&gt;Ionic 5 Full App&lt;/a&gt;&lt;/p&gt;
&lt;img alt="Ionic Full App with huge number of layouts and features" src="https://res.cloudinary.com/practicaldev/image/fetch/s--V1pEO0Mo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/0%2A1ArpKyhiDHZnevwB.jpeg"&gt;Ionic Full App in Cordova, with huge number of layouts and features&lt;br&gt;

</description>
      <category>ionic</category>
      <category>angular</category>
      <category>sociallogin</category>
      <category>capacitor</category>
    </item>
    <item>
      <title>How to make API calls in Ionic Capacitor Apps</title>
      <dc:creator>Abhijeet Rathore</dc:creator>
      <pubDate>Thu, 19 Aug 2021 21:10:48 +0000</pubDate>
      <link>https://forem.com/enappd/how-to-make-api-calls-in-ionic-capacitor-apps-4318</link>
      <guid>https://forem.com/enappd/how-to-make-api-calls-in-ionic-capacitor-apps-4318</guid>
      <description>
&lt;p&gt;In this post, we will learn how to make REST API calls from an Ionic Capacitor app. This might sound very trivial feature but it actually becomes confusing because of a lot of options available and even becomes an issue because of origin restrictions and CORS issues.&lt;/p&gt;
&lt;p&gt;We will explore various options to do these API calls in Ionic (Capacitor) apps, and test the same in Web, Android and iOS apps. Although I’m using a Capacitor app for demo, the solutions are applicable on Cordova as well.&lt;/p&gt;
&lt;h4&gt;Frameworks&lt;/h4&gt;
&lt;p&gt;All the options we explore in this post are equally applicable to any of the front-end framework, be it Vanilla JS, Angular, React or Vue. For demo purpose we will use &lt;strong&gt;Angular&lt;/strong&gt; front-end here.&lt;/p&gt;
&lt;p&gt;Also, for build environment we will stick to Capacitor. But we’ll see that Capacitor can use Cordova plugins as well.&lt;/p&gt;
&lt;h3&gt;REST API call issues&lt;/h3&gt;
&lt;p&gt;Before we explore the options to do http API calls, we need to understand why different options exist and how they are different.&lt;/p&gt;
&lt;p&gt;When we make REST API calls to a server, we often encounter CORS (&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS" rel="noopener noreferrer"&gt;Cross-Origin Resource Sharing&lt;/a&gt;) issues. This happens because our REST API calls contain the information of the request’s origin. E.g. If we are making the call from &lt;code&gt;ionic serve&lt;/code&gt; , the origin will be &lt;code&gt;&lt;a href="http://localhost:8100" rel="noopener noreferrer"&gt;http://localhost:8100&lt;/a&gt;&lt;/code&gt; or similar. The server receiving the request decides whether it will allow an API call from this origin or not. More info in &lt;a href="https://ionicframework.com/docs/troubleshooting/cors" rel="noopener noreferrer"&gt;Ionic’s documentation.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Similarly when you make API calls from Ionic Capacitor Android or iOS app, the origin is &lt;code&gt;capacitor://localhost&lt;/code&gt; and &lt;code&gt;&lt;a href="http://localhost" rel="noopener noreferrer"&gt;http://localhost&lt;/a&gt;&lt;/code&gt; respectively. For Cordova it is &lt;code&gt;ionic://localhost&lt;/code&gt; in iOS, and &lt;code&gt;&lt;a href="http://localhost" rel="noopener noreferrer"&gt;&lt;/a&gt;&lt;a href="http://localhost" rel="noopener noreferrer"&gt;http://localhost&lt;/a&gt;&lt;/code&gt; for android. These origins, again, will not be allowed in standard server like Firebase cloud, wooCommerce or Payment gateways etc.&lt;/p&gt;
&lt;h4&gt;Case 1 —&amp;amp;hairsp;If you have your own server, OR the server has no origin restriction&lt;/h4&gt;
&lt;p&gt;Life’s good then. If you have your own server where your API calls are ‘hitting’, you can make changes to allow these origins in the requests and problem solved. This can almost exclusively happen only if you are deploying the front-end and back-end yourself.&lt;/p&gt;
&lt;p&gt;If the server is not in your control, AND the server has no origin restriction, your API calls will still go through without any issue.&lt;/p&gt;
&lt;p&gt;In this case, we can use Angular Http Client for making REST API Calls. We’ll explore more on this in next section.&lt;/p&gt;
&lt;p&gt;Since not every server is relaxed in origin restrictions, we need some other solution to avoid CORS issues.&lt;/p&gt;
&lt;h4&gt;Case 2— You don’t have control over the server&lt;/h4&gt;
&lt;p&gt;This is the case most of the times. You need to make sure your requests are going through some kind of proxy (outside the webview), even if the request is actually made from the native app or localhost.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://ionicframework.com/blog/handling-cors-issues-in-ionic/" rel="noopener noreferrer"&gt;This old blog&lt;/a&gt; sheds some light on possible options to avoid CORS issues in Ionic. But there are some new methods we can implement for this issues&lt;/p&gt;
&lt;h3&gt;Choices in Ionic Capacitor apps for Http API calls&lt;/h3&gt;
&lt;p&gt;For making REST API calls, we have following options&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Fetch&lt;/strong&gt;&amp;amp;hairsp;—&amp;amp;hairsp;Default API to make Http calls&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://angular.io/api/common/http/HttpClient" rel="noopener noreferrer"&gt;&lt;strong&gt;Angular HttpClient&lt;/strong&gt;&lt;/a&gt; (Since we are using Angular for Demo. Similar options might be there in React as well) —This is Angular’s default way of making Http calls. If doesn’t fix CORS issues, but has few advantages over fetch API. You can check the advantages in &lt;a href="https://stackoverflow.com/a/57038001" rel="noopener noreferrer"&gt;this comparison.&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://ionicframework.com/docs/native/http/" rel="noopener noreferrer"&gt;&lt;strong&gt;@ionic-native/http plugin&amp;amp;hairsp;&lt;/strong&gt;&lt;/a&gt;—&amp;amp;hairsp;Works with &lt;a href="https://github.com/silkimen/cordova-plugin-advanced-http" rel="noopener noreferrer"&gt;cordova-plugin-advanced-http&lt;/a&gt;&amp;amp;hairsp;—&amp;amp;hairsp;Works only on device, so development is difficult. Fixes the CORS issues.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/sneas/ionic-native-http-connection-backend" rel="noopener noreferrer"&gt;&lt;strong&gt;Ionic Native Http Connection Backend&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;&amp;amp;hairsp;&lt;/strong&gt;—&amp;amp;hairsp;This package combines the above two. Essentially Angular HttpClient will work in browser, and will switch to @ionic-native/http when on device. Fixes CORS issue.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Option #3 looks good for our case, but involves Cordova plugins. This is OK if your app uses Cordova, but for Capacitor you might wanna avoid Cordova plugins. This leaves us with the final option&lt;/p&gt;
&lt;p&gt;5. &lt;a href="https://github.com/capacitor-community/http" rel="noopener noreferrer"&gt;&lt;strong&gt;Capacitor/Http plugin&lt;/strong&gt;&amp;amp;hairsp;&lt;/a&gt;—&amp;amp;hairsp;Works in browser, Android and iOS. Fixes CORS issue. This plugin essentially does the same as Option#3, but with less number of dependencies.&lt;/p&gt;
&lt;p&gt;Let’s explore all these options with code samples and see their limitations.&lt;/p&gt;
&lt;h3&gt;Demo Server&lt;/h3&gt;
&lt;p&gt;We will make a Firebase server (local) using &lt;code&gt;firebase serve&lt;/code&gt; and use it for the testing purpose. This is a standard method to run Firebase server locally, OR you can use &lt;strong&gt;Firebase Emulator&lt;/strong&gt;, which is an advanced version of &lt;code&gt;firebase serve&lt;/code&gt; . Here’s a short blog on &lt;a href="https://enappd.com/blog/how-to-use-firebase-emulators-with-ionic-angular-applications/163" rel="noopener noreferrer"&gt;how to run Firebase Emulator locally&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Once the server is up, we will access it from all three platforms&amp;amp;hairsp;—&amp;amp;hairsp;Web, Android and iOS.&lt;/p&gt;
&lt;h4&gt;How to access locally run server from device&lt;/h4&gt;
&lt;p&gt;You might be wondering how to access a locally run server (running on localhost:XXXX) from your device when you build the app.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;First you need to make sure your device is on the same WiFi as your server system&lt;/li&gt;
&lt;li&gt;You need to know the IPv4 of your system. For mac, find it with &lt;code&gt;ifconfig&lt;/code&gt; , for windows &lt;code&gt;ipconfig&lt;/code&gt; . It will be something like &lt;code&gt;192.168.x.x&lt;/code&gt; which is standard for local systems using a WiFi router&lt;/li&gt;
&lt;li&gt;Instead of default serve, you need to use &lt;code&gt;firebase serve -o YOUR_IP&lt;/code&gt; , replace &lt;code&gt;YOUR_IP&lt;/code&gt; with your actual IPv4 address&lt;/li&gt;
&lt;li&gt;When calling APIs, use this IP as the server address, with firebase serve port number, which defaults to 5000&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Firebase functions&lt;/h4&gt;
&lt;p&gt;Firebase functions essentially behave like &lt;code&gt;view&lt;/code&gt; in Django, or API methods in node (Firebase is node!). Following code shows the 4 standard methods and 4 CORS wrapped methods. (If you are new to Firebase functions, check this blog for &lt;a href="https://enappd.com/blog/firebase-cloud-functions-in-ionic-5-complete-guide/166" rel="noopener noreferrer"&gt;Firebase Cloud functions with Ionic&lt;/a&gt;)&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;p&gt;Note that there’s not much being done in the methods, like fetching some data from DB, or writing a new entry. All those functionalities lay ahead of this point, and these bare methods will serve to prove the point of CORS / restriction which we are trying to understand, with different libraries.&lt;/p&gt;
&lt;p&gt;The API method URL i.e. &lt;code&gt;&lt;a href="http://%24%7Bthis.localhost%7D:5000/ionic4fullapp/us-central1/getData" rel="nofollow noopener noreferrer"&gt;&lt;/a&gt;&lt;a href="http://192.168.0.7:5000/ionic4fullapp/us-central1/getData" rel="noopener noreferrer"&gt;http://192.168.0.7:5000/ionic4fullapp/us-central1/getData&lt;/a&gt;&lt;/code&gt; in my case, will be output in terminal when you run &lt;code&gt;firebase serve&lt;/code&gt; or &lt;code&gt;emulate&lt;/code&gt; command.&lt;/p&gt;
&lt;h3&gt;Testing Methodology&lt;/h3&gt;
&lt;p&gt;We will&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Make API calls to a sample Firebase server which has 4 methods&amp;amp;hairsp;—&amp;amp;hairsp;&lt;code&gt;getData&lt;/code&gt;(GET), &lt;code&gt;postData&lt;/code&gt;(POST), &lt;code&gt;putData&lt;/code&gt;(PUT), &lt;code&gt;deleteData&lt;/code&gt;(DELETE) which allows all origins and, 4 methods &lt;code&gt;_getData&lt;/code&gt;(GET), &lt;code&gt;_postData&lt;/code&gt;(POST), &lt;code&gt;_putData&lt;/code&gt;(PUT), &lt;code&gt;_deleteData&lt;/code&gt;(DELETE) which put CORS restrictions (by default Firebase feature).The “unrestricted” APIs are basically wrapped in CORS module, which has the setting to allow all origins.&lt;/li&gt;
&lt;li&gt;We’ll explore both these API servers from localhost (web) and device (Android/iOS)&amp;amp;hairsp;—&amp;amp;hairsp;all calling the same server. When using localhost (web), you can &lt;code&gt;firebase serve&lt;/code&gt; normally as well (without IP info)&lt;/li&gt;
&lt;li&gt;We will test these methods for all 5 options we mentioned in Choices section above.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Demo App for Http Calls&lt;/h3&gt;
&lt;p&gt;We will make a demo Ionic Angular Capacitor app to test the above. Creating the app is very simple. Run&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ionic start httpTester sidemenu --type=angular --capacitor
&lt;/code&gt;&lt;/pre&gt;




&lt;p&gt;The app name is &lt;code&gt;httpTester&lt;/code&gt; , type is &lt;code&gt;sidemenu&lt;/code&gt; and it incorporates Angular and Capacitor.&lt;/p&gt;
&lt;p&gt;My environment is —&lt;/p&gt;
&lt;pre&gt;&lt;strong&gt;Ionic&lt;/strong&gt;:&lt;br&gt;Ionic CLI : 6.16.3&lt;br&gt;Capacitor: 3.0.2&lt;/pre&gt;
&lt;pre&gt;&lt;strong&gt;Utility&lt;/strong&gt;:&lt;br&gt;cordova-res : 0.15.3&lt;br&gt;native-run  : 1.4.0&lt;/pre&gt;
&lt;pre&gt;&lt;strong&gt;System&lt;/strong&gt;:&lt;br&gt;NodeJS : v14.15.4&lt;br&gt;npm    : 7.17.0&lt;br&gt;OS     : macOS Big Sur&lt;/pre&gt;
&lt;p&gt;I have made custom UI to display the behavior across all options. Here’s a sample Page for Fetch API&lt;/p&gt;
&lt;img alt="Demo app for testing Ionic Capacitor Http calls" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AFcc4-UkTDAecXiRC1XmpNQ.png"&gt;Demo app UI for testing Ionic Capacitor Http calls&lt;p&gt;You can see the ❌ and ✅ marks for success and error in API calls. We’ll perform this routine on all&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Restricted and non-restricted API calls&lt;/li&gt;
&lt;li&gt;Platform wise behavior&lt;/li&gt;
&lt;li&gt;Behavior for each library / plugin&lt;/li&gt;
&lt;li&gt;Behavior for each method type i.e. GET, POST, PUT, DELETE&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;and finally overlap the results to see which library is best for our usage.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: The behavior of GET, POST, PUT, DELETE methods for a particular set of variables remain same in all cases. In other words, if one fails, all will fails, if one succeeds, all will.&lt;/p&gt;
&lt;h3&gt;Running the app&lt;/h3&gt;
&lt;p&gt;Once you install the required libraries for a particular option (We will see how to install each library in individual sections), you can simply run the app with following options :&lt;/p&gt;
&lt;h4&gt;Web&lt;/h4&gt;
&lt;p&gt;For web testing, you can simply run the app with&lt;/p&gt;
&lt;pre&gt;$ ionic serve&lt;/pre&gt;
&lt;h4&gt;Android / iOS&lt;/h4&gt;
&lt;p&gt;For Android and iOS, you will have to build the app , open the corresponding native IDE and build the app. Here are the steps&lt;/p&gt;
&lt;pre&gt;&lt;strong&gt;// Create platform&lt;/strong&gt;&lt;br&gt;$ npx cap add android // replace &lt;code&gt;android&lt;/code&gt; with &lt;code&gt;ios&lt;/code&gt; for iOS&lt;/pre&gt;
&lt;pre&gt;&lt;strong&gt;// Build app&lt;/strong&gt;&lt;br&gt;$ ionic build // replace &lt;code&gt;android&lt;/code&gt; with &lt;code&gt;ios&lt;/code&gt; for iOS&lt;/pre&gt;
&lt;pre&gt;&lt;strong&gt;// Sync data with native app &lt;/strong&gt;&lt;br&gt;$ npx cap sync // replace &lt;code&gt;android&lt;/code&gt; with &lt;code&gt;ios&lt;/code&gt; for iOS&lt;/pre&gt;
&lt;pre&gt;&lt;strong&gt;// Open native IDE to build app&lt;/strong&gt;&lt;br&gt;$ npx cap open android // replace &lt;code&gt;android&lt;/code&gt; with &lt;code&gt;ios&lt;/code&gt; for iOS&lt;/pre&gt;
&lt;p&gt;After every change in the app, you need to run &lt;code&gt;ionic build&lt;/code&gt; and &lt;code&gt;npx cap copy&lt;/code&gt; to reflect changes in Android /iOS build.&lt;/p&gt;
&lt;p&gt;Let’s start with the libraries/plugins one by one&lt;/p&gt;
&lt;h3&gt;1. Fetch API&lt;/h3&gt;
&lt;p&gt;Let’s start with web default Fetch API. You don’t need to setup anything to use Fetch. It’s the default for JS.&lt;/p&gt;
&lt;p&gt;Here’s the sample code for the unrestricted set of methods (the restricted set will be exact same, with only change in API method name). Here’s how the code looks&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;p&gt;Ignore the variables and &lt;code&gt;changeStatus&lt;/code&gt; method. These are only for displaying the ❌ and ✅ in the UI for better visualization of results.&lt;/p&gt;
&lt;p&gt;For Fetch API, here’s the overall result for Web, Android and iOS&lt;/p&gt;
&lt;img alt="Ionic Capacitor API call results&amp;amp;hairsp;—&amp;amp;hairsp;Fetch API" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AFcc4-UkTDAecXiRC1XmpNQ.png"&gt;Ionic Capacitor API call results&amp;amp;hairsp;—&amp;amp;hairsp;Fetch API&lt;h3&gt;2. Angular HttpClient&lt;/h3&gt;
&lt;p&gt;Angular &lt;code&gt;HttpClient&lt;/code&gt; comes with Angular setup in form of the &lt;code&gt;@angular/common/http&lt;/code&gt; package. It can be imported in any &lt;code&gt;.ts&lt;/code&gt; file and used as http client. Just add this in the page’s &lt;code&gt;module.ts&lt;/code&gt; file&lt;/p&gt;
&lt;pre&gt;import { HttpClientModule } from '@angular/common/http';&lt;/pre&gt;
&lt;pre&gt;....&lt;br&gt; @NgModule({&lt;br&gt;  ...&lt;br&gt;  imports: [HttpClientModule],&lt;br&gt;  providers:[..]&lt;br&gt;})&lt;/pre&gt;
&lt;p&gt;Here’s how the code looks for HttpClient&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;p&gt;For Angular HttpClient, here’s the overall result for Web, Android and iOS&lt;/p&gt;
&lt;img alt="Ionic Capacitor API call results&amp;amp;hairsp;—&amp;amp;hairsp;Angular HttpClient" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2A1XKJDrc0M_n1E7UlDLTCXg.png"&gt;Ionic Capacitor API call results&amp;amp;hairsp;—&amp;amp;hairsp;Angular HttpClient&lt;h3&gt;3. Ionic Native Http Plugin (Cordova)&lt;/h3&gt;
&lt;p&gt;Install the Ionic Native Http Plugin by running&lt;/p&gt;
&lt;pre&gt;$ npm install cordova-plugin-advanced-http&lt;br&gt;$ npm install @ionic-native/http&lt;/pre&gt;
&lt;p&gt;Also, in the page’s &lt;code&gt;module.ts&lt;/code&gt; file , add&lt;/p&gt;
&lt;pre&gt;import { HTTP } from '@ionic-native/http/ngx';&lt;br&gt;....&lt;br&gt; @NgModule({&lt;br&gt;  ...&lt;br&gt;  imports: [...],&lt;br&gt;  providers:[HTTP]&lt;br&gt;})&lt;/pre&gt;
&lt;p&gt;Since this is a Cordova plugin, it will not work on Web. But note that we can use this plugin in a Capacitor app, as Capacitor supports Cordova plugins.&lt;/p&gt;
&lt;p&gt;Also post install, you’ll have to run &lt;code&gt;npx cap sync&lt;/code&gt; for Android and iOS. Here’s how to code looks for this plugin&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;p&gt;For Ionic Native Http, here’s the overall result for Web, Android and iOS&lt;/p&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AaO1AWX4TInuCyCgCIzmFKA.png"&gt;Ionic Capacitor API call results&amp;amp;hairsp;—&amp;amp;hairsp;Ionic Native Http&lt;h3&gt;4. Ionic Native Http connection backend&lt;/h3&gt;
&lt;p&gt;For this options, you’ll need another plugin which combines the power of &lt;code&gt;httpClient&lt;/code&gt; and Ionic Native Http plugin. Install this plugin using&lt;/p&gt;
&lt;pre&gt;$ npm install --save ionic-native-http-connection-backend&lt;/pre&gt;
&lt;pre&gt;// In some cases, it might ask to install a dependency cordova-plugin-file&lt;/pre&gt;
&lt;pre&gt;$ npm install cordova-plugin-file&lt;br&gt;$ npm install @ionic-native/file&lt;/pre&gt;
&lt;p&gt;Again note that we can use this plugin in a Capacitor app, as Capacitor supports Cordova plugins.&lt;/p&gt;
&lt;p&gt;You’ll need to take few extra measures here:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Add &lt;code&gt;NativeHttpModule&lt;/code&gt;, &lt;code&gt;NativeHttpBackend&lt;/code&gt; and &lt;code&gt;NativeHttpFallback&lt;/code&gt; into the module where you are using the plugins. If you plan to use it throughout the app, add these in &lt;code&gt;app.module.ts&lt;/code&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;p&gt;Here’s how the code will look for calling APIs using this module&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;p&gt;Notice we haven’t added &lt;code&gt;import { HTTP } from ‘@ionic-native/http/ngx’;&lt;/code&gt; in this page, but that is automatically attached to API calls when run on device.&lt;/p&gt;
&lt;p&gt;For Ionic Native Advanced Http, here’s the overall result for Web, Android and iOS&lt;/p&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AH6qJaWEIX6DP2XYsgmQbEQ.png"&gt;Ionic Capacitor API call results&amp;amp;hairsp;—&amp;amp;hairsp;Ionic Native Advanced Http&lt;h3&gt;5. Capacitor Http&lt;/h3&gt;
&lt;p&gt;This plugin will run only in a Capacitor app. Install the plugin using&lt;/p&gt;
&lt;pre&gt;$ npm install @capacitor-community/http&lt;/pre&gt;
&lt;p&gt;No additional configuration required for Android and iOS. You can use it in the page as&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;p&gt;For Capacitor Http, here’s the overall result for Web, Android and iOS&lt;/p&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AJHs2GgYW2dwBLUxULP1IaQ.png"&gt;Ionic Capacitor API call results&amp;amp;hairsp;—&amp;amp;hairsp;Capacitor Http&lt;h3&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;We saw several options to call APIs in an Ionic Capacitor Angular app. We saw how the plugin can behave differently in Web vs Android/iOS environment, and also if the server is allowing all origins or not.&lt;/p&gt;
&lt;p&gt;Here’s a gist of which library to use when&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Fetch&lt;/strong&gt;&amp;amp;hairsp;—&amp;amp;hairsp;Use it when you are making an app where you can control the server &lt;code&gt;Allow-origin&lt;/code&gt; behavior. You can sent the server to accept your app’s origins, and then Fetch will work for all scenarios&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Angular HttpClient&lt;/strong&gt;&amp;amp;hairsp;—&amp;amp;hairsp;Same as Fetch&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ionic Native Http&lt;/strong&gt;&amp;amp;hairsp;—&amp;amp;hairsp;Can by-pass allow-origin restriction on Android/iOS device. But it cannot run on web, so development is difficult&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ionic Native Advanced Http&lt;/strong&gt;&amp;amp;hairsp;—&amp;amp;hairsp;This allows you to run the APIs in web, android and iOS, but still cannot run origin restricted APIs on web&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Capacitor Http&amp;amp;hairsp;&lt;/strong&gt;—&amp;amp;hairsp;This allows you to run the APIs in web, android and iOS, but still cannot run origin restricted APIs on web&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In conclusion, &lt;strong&gt;Capacitor Http&lt;/strong&gt; and &lt;strong&gt;Ionic Native Advanced Http&lt;/strong&gt; plugins will provide the same level of functionality for Ionic apps. Only difference being the nature of build environment —&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;While &lt;strong&gt;Ionic Native Advanced Http&lt;/strong&gt; can run both in Cordova and Capacitor apps, &lt;strong&gt;Capacitor Http&lt;/strong&gt; runs only in Capacitor environment&lt;/li&gt;
&lt;li&gt;While &lt;strong&gt;Capacitor Http &lt;/strong&gt;can run on Ionic-Angular, Ionic-React and Ionic Vue frameworks, &lt;strong&gt;Ionic Native Advanced Http Ionic Native Advanced Http &lt;/strong&gt;can be used only in Ionic-Angular&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So in essence it’s a tie ! 🤜 🤛 I personally like Capacitor Http, as it is just one plugin to be installed instead of 4 packages in Ionic Native Advanced case.&lt;/p&gt;
&lt;p&gt;Hope this post will clarify few of your Http call doubts.&lt;/p&gt;

&lt;h3&gt;Next Steps&lt;/h3&gt;
&lt;p&gt;If you liked this blog, you will also find the following blogs interesting and helpful. Feel free to ask any questions in the comment section&lt;/p&gt;

&lt;h3&gt;Ionic Capacitor&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Basic&lt;/strong&gt;&amp;amp;hairsp;—&amp;amp;hairsp;&lt;a href="https://enappd.com/blog/use-geolocation-geocoding-and-reverse-geocoding-in-ionic-capacitor/131" rel="noopener nofollow noreferrer"&gt;Geolocation&lt;/a&gt; | &lt;a href="https://enappd.com/blog/qr-code-and-barcode-scanning-with-ionic-capacitor/127" rel="noopener nofollow noreferrer"&gt;Barcode &amp;amp; QR code&lt;/a&gt; | &lt;a href="https://enappd.com/blog/facebook-login-in-capacitor-apps-with-ionic-angular/128" rel="noopener nofollow noreferrer"&gt;Facebook Login&lt;/a&gt; (Angular) | &lt;a href="https://enappd.com/blog/facebook-login-in-ionic-react-capacitor-apps/118" rel="noopener nofollow noreferrer"&gt;Facebook Login (React)&lt;/a&gt; | &lt;a href="https://enappd.com/blog/icon-splash-in-ionic-react-capacitor-apps/114" rel="noopener nofollow noreferrer"&gt;Icon and Splash&lt;/a&gt; | &lt;a href="https://enappd.com/blog/camera-and-gallery-in-ionic-react-app-using-capacitor/110" rel="noopener nofollow noreferrer"&gt;Camera &amp;amp; Photo Gallery&lt;/a&gt; | &lt;a href="https://enappd.com/blog/debugging-ionic-apps-using-chrome-and-safari-developers-tools/167" rel="noopener noreferrer"&gt;Debugging with browser&lt;/a&gt;|&lt;a href="https://enappd.com/blog/make-awesome-theme-switcher-in-ionic-5/170" rel="noopener noreferrer"&gt;Theming in Ionic apps&lt;/a&gt; | &lt;a href="https://enappd.com/blog/google-login-in-ionic-capacitor-app-with-angular/178/" rel="noopener noreferrer"&gt;Google Login (Angular)&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Advanced&lt;/strong&gt;&amp;amp;hairsp;—&amp;amp;hairsp;&lt;a href="https://enappd.com/blog/implement-admob-in-ionic-react-capacitor-apps/135" rel="noopener nofollow noreferrer"&gt;AdMob&lt;/a&gt; | &lt;a href="https://enappd.com/blog/local-notifications-in-ionic-5-capacitor/132" rel="noopener nofollow noreferrer"&gt;Local Notifications&lt;/a&gt; | &lt;a href="https://enappd.com/blog/google-login-in-ionic-react-capacitor-apps/122" rel="noopener nofollow noreferrer"&gt;Google Login&lt;/a&gt; | &lt;a href="https://enappd.com/blog/twitter-login-in-ionic-react-capacitor-app/121" rel="noopener nofollow noreferrer"&gt;Twitter Login&lt;/a&gt; | &lt;a href="https://enappd.com/blog/html5-games-in-ionic-capacitor-using-phaser/115" rel="noopener nofollow noreferrer"&gt;Games using Phaser&lt;/a&gt; | &lt;a href="https://enappd.com/blog/play-music-in-ionic-capacitor-apps/112" rel="noopener nofollow noreferrer"&gt;Play music&lt;/a&gt; | &lt;a href="https://enappd.com/blog/firebase-push-notification-in-ionic-react-capacitor/111" rel="noopener nofollow noreferrer"&gt;Push Notifications&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Ionic Cordova&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://enappd.com/blog/ionic-app-with-nodejs-express-mysql-sequelize-taxi-app/160" rel="noopener nofollow noreferrer"&gt;Taxi Booking App example with Ionic, Node, Express and MySQL&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Ionic Payment Gateways&amp;amp;hairsp;—&amp;amp;hairsp;&lt;a href="https://enappd.com/blog/integrate-stripe-payment-gateway-in-ionic-5-apps-and-pwa-using-firebase/158" rel="noopener nofollow noreferrer"&gt;Stripe with Firebase&lt;/a&gt; | &lt;a href="https://enappd.com/blog/ionic-5-stripe-payment-integration-firebase-cloud-functions-vs-node-express-based-server/159" rel="noopener nofollow noreferrer"&gt;Stripe with NodeJS&lt;/a&gt; | &lt;a href="https://enappd.com/blog/paypal-integration-in-ionic-apps-and-pwa/142" rel="noopener nofollow noreferrer"&gt;PayPal&lt;/a&gt; |&lt;a href="https://enappd.com/blog/paypal-payment-integration-using-braintree-in-ionic-5-apps/177/" rel="noopener noreferrer"&gt;PayPal with Braintree&lt;/a&gt;| &lt;a href="https://enappd.com/blog/how-to-integrate-apple-pay-in-ionic-4-apps/21" rel="noopener nofollow noreferrer"&gt;Apple Pay&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-integrate-razorpay-in-ionic-4-apps-and-pwa/20" rel="noopener nofollow noreferrer"&gt;RazorPay&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Ionic Charts with&amp;amp;hairsp;—&amp;amp;hairsp;&lt;a href="https://enappd.com/blog/ionic-4-charts-using-google-charts/66" rel="noopener nofollow noreferrer"&gt;Google Charts &lt;/a&gt;| &lt;a href="https://enappd.com/blog/adding-charts-in-ionic-4-apps-and-pwa-part-3/60" rel="noopener nofollow noreferrer"&gt;HighCharts&lt;/a&gt; | &lt;a href="https://enappd.com/blog/adding-charts-in-ionic-4-apps-and-pwa-part-2/54" rel="noopener nofollow noreferrer"&gt;d3.js&lt;/a&gt; | &lt;a href="https://enappd.com/blog/charts-in-ionic-4-apps-and-pwa-part-1/52" rel="noopener nofollow noreferrer"&gt;Chart.js&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Ionic Authentications&amp;amp;hairsp;—&amp;amp;hairsp;&lt;a href="https://enappd.com/blog/firebase-email-authentication-in-ionic-apps/153" rel="noopener nofollow noreferrer"&gt;Via Email&lt;/a&gt; | &lt;a href="https://enappd.com/blog/implement-anonymous-login-in-ionic-apps-with-firebase/154" rel="noopener nofollow noreferrer"&gt;Anonymous&lt;/a&gt; | &lt;a href="https://enappd.com/blog/facebook-login-in-ionic-apps-using-firebase/150" rel="noopener nofollow noreferrer"&gt;Facebook&lt;/a&gt; | &lt;a href="https://enappd.com/blog/implement-google-login-in-ionic-apps-using-firebase/147" rel="noopener nofollow noreferrer"&gt;Google&lt;/a&gt; | &lt;a href="https://enappd.com/blog/twitter-login-in-ionic-4-apps-using-firebase/24" rel="noopener nofollow noreferrer"&gt;Twitter&lt;/a&gt; | &lt;a href="https://enappd.com/blog/firebase-phone-authentication-in-ionic-5-apps/169" rel="noopener noreferrer"&gt;Via Phone&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Ionic Features&amp;amp;hairsp;—&amp;amp;hairsp;&lt;a href="https://enappd.com/blog/ionic-5-complete-guide-on-geolocation/141" rel="noopener nofollow noreferrer"&gt;Geolocation&lt;/a&gt;| &lt;a href="https://enappd.com/blog/ionic-complete-guide-barcode-qrcode-scan/140" rel="noopener nofollow noreferrer"&gt;QR Code reader&lt;/a&gt; | &lt;a href="https://enappd.com/blog/best-fitness-plugins-for-ionic-4-how-to-use-pedometer/15" rel="noopener nofollow noreferrer"&gt;Pedometer&lt;/a&gt;| &lt;a href="https://enappd.com/blog/implement-signature-pad-in-ionic-apps/145" rel="noopener nofollow noreferrer"&gt;Signature&lt;/a&gt; &lt;a href="https://enappd.com/blog/implement-signature-pad-in-ionic-apps/145" rel="noopener noreferrer"&gt;Pad&lt;/a&gt; | &lt;a href="https://enappd.com/blog/using-background-geolocation-in-ionic-angular-apps/165" rel="noopener nofollow noreferrer"&gt;Background Geolocation&lt;/a&gt; | &lt;a href="https://enappd.com/blog/detect-wifi-and-data-network-in-ionic-5-apps/173" rel="noopener noreferrer"&gt;Network Detection&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Media in Ionic&amp;amp;hairsp;—&amp;amp;hairsp;&lt;a href="https://enappd.com/blog/spotify-like-music-in-ionic-4-apps/48" rel="noopener nofollow noreferrer"&gt;Audio&lt;/a&gt; | &lt;a href="https://enappd.com/blog/adding-video-player-in-ionic-4-app/64" rel="noopener nofollow noreferrer"&gt;Video&lt;/a&gt; | &lt;a href="https://enappd.com/blog/camera-and-image-picker-in-ionic-apps/148" rel="noopener nofollow noreferrer"&gt;Image Picker&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-add-image-cropper-in-ionic-apps/149" rel="noopener nofollow noreferrer"&gt;Image Cropper&lt;/a&gt; | &lt;a href="https://enappd.com/blog/implement-sounds-and-vibration-in-ionic-apps/172" rel="noopener noreferrer"&gt;Sounds and Vibrations&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Ionic Essentials&amp;amp;hairsp;—&amp;amp;hairsp;&lt;a href="https://enappd.com/blog/debugging-ionic-apps-using-chrome-and-safari-developers-tools/167" rel="noopener noreferrer"&gt;Debugging with browser&lt;/a&gt;| &lt;a href="https://enappd.com/blog/ionic-4-save-and-retrieve-data-locally-on-device/59" rel="noopener nofollow noreferrer"&gt;Native Storage&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-translate-in-ionic-internationalization-and-localization/143" rel="noopener nofollow noreferrer"&gt;Translations&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-use-rtl-right-to-left-in-ionic-apps-pwa/152" rel="noopener nofollow noreferrer"&gt;RTL&lt;/a&gt; | &lt;a href="https://enappd.com/blog/using-sentry-error-monitoring-with-ionic-angular-applications/164" rel="noopener nofollow noreferrer"&gt;Sentry Error Monitoring&lt;/a&gt; | &lt;a href="https://enappd.com/blog/social-sharing-component-in-ionic-5-mobile-web-apps/168" rel="noopener noreferrer"&gt;Social sharing&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-generate-and-download-pdf-in-ionic-apps/174" rel="noopener noreferrer"&gt;PDF generation&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Ionic messaging&amp;amp;hairsp;—&amp;amp;hairsp;&lt;a href="https://enappd.com/blog/how-to-implement-firebase-push-notifications-in-ionic-apps/157" rel="noopener nofollow noreferrer"&gt;Firebase Push&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-automatically-read-sms-in-ionic-5-apps/175" rel="noopener noreferrer"&gt;Reading SMS&lt;/a&gt; | &lt;a href="https://enappd.com/blog/local-notifications-in-ionic-5-capacitor/132" rel="noopener nofollow noreferrer"&gt;Local Notifications&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Ionic with Firebase&amp;amp;hairsp;—&amp;amp;hairsp;&lt;a href="https://enappd.com/blog/how-to-integrate-firebase-in-ionic-4-apps/23" rel="noopener nofollow noreferrer"&gt;Basics&lt;/a&gt; | &lt;a href="https://enappd.com/blog/firebase-with-ionic-4-hosting-auth-and-db-connection/58" rel="noopener nofollow noreferrer"&gt;Hosting and DB&lt;/a&gt; | &lt;a href="https://enappd.com/blog/firebase-cloud-functions-in-ionic-5-complete-guide/166" rel="noopener noreferrer"&gt;Cloud functions&lt;/a&gt; | &lt;a href="https://enappd.com/blog/github-actions-deploying-ionic-angular-app-to-firebase-hosting/146" rel="noopener nofollow noreferrer"&gt;Deploy App to Firebase&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-use-firebase-emulators-with-ionic-angular-applications/163" rel="noopener nofollow noreferrer"&gt;Firebase simulator&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Unit Testing in Ionic&amp;amp;hairsp;—&amp;amp;hairsp;&lt;a href="https://enappd.com/blog/beginners-guide-to-ionic-angular-unit-testing-part-1/151" rel="noopener nofollow noreferrer"&gt;Part 1&lt;/a&gt; | &lt;a href="https://enappd.com/blog/beginners-guide-to-ionic-angular-unit-testing-part-2-mocks-and-spies/155" rel="noopener nofollow noreferrer"&gt;Mocks &amp;amp; Spies&lt;/a&gt;| &lt;a href="https://enappd.com/blog/beginners-guide-to-ionic-angular-unit-testing-async-testing/156" rel="noopener nofollow noreferrer"&gt;Async Testing&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Ionic Capacitor Full App (Angular)&lt;/h3&gt;
&lt;p&gt;If you need a base to start your next Angular &lt;strong&gt;Capacitor app&lt;/strong&gt;, you can make your next awesome app using &lt;a href="https://store.enappd.com/product/capacitor-full-app-with-ionic-angular/" rel="noopener nofollow noreferrer"&gt;Capacitor Full App&lt;/a&gt;&lt;/p&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2Afed8vWeCTOvkNBLbFxsvDw.png"&gt;Capacitor Full App with huge number of layouts and features&lt;h3&gt;Ionic Capacitor Full App (React)&lt;/h3&gt;
&lt;p&gt;If you need a base to start your next Ionic 5 React Capacitor app, you can make your next awesome app using &lt;a href="https://store.enappd.com/product/ionic-react-full-app-capacitor/" rel="noopener noreferrer"&gt;Ionic 5 React Full App in Capacitor&lt;/a&gt;&lt;/p&gt;
&lt;img alt="Ionic 5 React Full App in Capacitor from Enappd" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AG3yOFVX4oABx9MhUy-3kng.png"&gt;Ionic 5 React Full App in Capacitor from Enappd&lt;h3&gt;Ionic Cordova Full App (Angular)&lt;/h3&gt;
&lt;p&gt;If you need a base to start your next Ionic 5 app, you can make your next awesome app using &lt;a href="https://store.enappd.com/product/ionic-full-app" rel="noopener noreferrer"&gt;Ionic 5 Full App&lt;/a&gt;&lt;/p&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2ARAe0nXh5ymkCfxGqSqdE-A.png"&gt;Ionic Full App in Cordova, with huge number of layouts and features

</description>
      <category>ionic</category>
      <category>capacitor</category>
      <category>angular</category>
      <category>api</category>
    </item>
    <item>
      <title>Implement Signature Pad in Ionic 5 apps </title>
      <dc:creator>Abhijeet Rathore</dc:creator>
      <pubDate>Sun, 16 Aug 2020 11:40:42 +0000</pubDate>
      <link>https://forem.com/enappd/implement-signature-pad-in-ionic-5-apps-bld</link>
      <guid>https://forem.com/enappd/implement-signature-pad-in-ionic-5-apps-bld</guid>
      <description>
&lt;p class="graf graf--p graf-after--figure"&gt;You might have seen the delivery guys taking your signature on the phone, or someone scribbling their handwriting on their phone. It looks pretty cool, and in this post, you’ll &lt;strong class="markup--strong markup--p-strong"&gt;learn how to integrate a Signature pad functionality in Ionic 5 apps and PWA.&lt;/strong&gt;&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;By signing on your phone you can do (among many) following things&lt;/p&gt;
&lt;ul class="postList"&gt;
&lt;li class="graf graf--li graf-after--p"&gt;Sign on a document and email/share&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Scribble your signature and save as an image for later&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Get signature from a user on delivery / trip completion etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;img class="graf-image" alt="Getting hand signature on phone is a major addition to your app’s authenticity" src="https://res.cloudinary.com/practicaldev/image/fetch/s--Kgb7DJ4I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/0%2Ab30rIyxEZ_yB_rZe.png"&gt;&lt;br&gt;Getting hand signature on phone is a major addition to your app’s authenticity&lt;p class="graf graf--p graf-after--figure"&gt;We’ll implement this functionality in an Ionic 5 Angular Cordova app. We will learn how to sign on the phone and then save the signature in phone’s gallery as a png.&lt;/p&gt;
&lt;h3 class="graf graf--h3 graf-after--p"&gt;What is Ionic ?&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;(Just for the sake of beginners) &lt;br&gt;&lt;strong class="markup--strong markup--p-strong"&gt;Ionic&lt;/strong&gt; is a hybrid mobile app development SDK. It provides tools and services for developing hybrid mobile apps using Web technologies like CSS, HTML5, and Sass. Apps can be built with these Web technologies and then distributed through native app stores to be installed on devices by leveraging &lt;a href="https://cordova.apache.org/" class="markup--anchor markup--p-anchor" rel="noopener nofollow noopener"&gt;Cordova&lt;/a&gt; or Capacitor environment.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;So, in other words — If you create Native apps in Android, you code in Java. If you create Native apps in iOS, you code in Obj-C or Swift. Both of these are powerful but complex languages. &lt;strong class="markup--strong markup--p-strong"&gt;With Ionic you can write a single piece of code for your app that can run on both iOS and Android &lt;/strong&gt;and web (as PWA), that too with the simplicity of HTML, CSS, and JS.&lt;/p&gt;
&lt;h3 class="graf graf--h3 graf-after--p"&gt;Signature Pad functionality&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;Scribbling signature pad is not at all different from writing on an image, which we all do regularly in our Whatsapp, Facebook etc. image shares. Essentially, we create a Canvas in the app, and let the user draw on the Canvas.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;Canvas is a very powerful tool in HTML/Javascript. You can draw/scribble on a designated area, resize it, change colors, put a picture in background and write on it etc. Canvas can even cater to PDF and other files, but we’ll stick to images for this post.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;Due to Ionic being platform agnostic, there are different types of Ionic Apps you can build for same functionality. Most popular ones are :&lt;/p&gt;
&lt;ul class="postList"&gt;
&lt;li class="graf graf--li graf-after--p"&gt;&lt;strong class="markup--strong markup--li-strong"&gt;Front-end: Angular | Build environment : Cordova ✅&lt;/strong&gt;&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Front-end: Angular | Build environment : Capacitor&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Front-end: React | Build environment : Capacitor&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;&lt;strong class="markup--strong markup--li-strong"&gt;Front-end: React/Angular | as PWA ✅&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p class="graf graf--p graf-after--li"&gt;Canvas can be implemented in any of the above, but for our example I’m choosing Angular Cordova framework. Besides having dedicated plugins for a lot of integrations, Cordova also has a huge community backing.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;We’ll implement the Signature functionality in both PWA and apps.&lt;/p&gt;
&lt;h3 class="graf graf--h3 graf-after--p"&gt;Structure of post&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;As always, I’ll go step-by-step in the post. If you are an experienced dev, you can just skip over the known stuff and jump to the section you need&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;&lt;strong class="markup--strong markup--p-strong"&gt;Step 1&lt;/strong&gt; — Creating a basic Ionic 5 Angular app&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;&lt;strong class="markup--strong markup--p-strong"&gt;Step 2&lt;/strong&gt;— Install required plugins&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;&lt;strong class="markup--strong markup--p-strong"&gt;Step 3&lt;/strong&gt;— Implement Signature pad functionality on web&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;&lt;strong class="markup--strong markup--p-strong"&gt;Step 4&lt;/strong&gt;— Save the created signatures in Android gallery&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;&lt;strong class="markup--strong markup--p-strong"&gt;Step 5&lt;/strong&gt;— Test on Android&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;Let’s dive right in !&lt;/p&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--WxaDYYUq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AhRj3iNulVXYHcu6wHkeMeg.gif"&gt;&lt;br&gt;Dive …… better
&lt;h3 class="graf graf--h3 graf--leading"&gt;Step 1— Create a basic Ionic Angular app&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;First you need to make sure you have the latest Ionic CLI. This will ensure you are using everything latest. Ensure latest Ionic CLI installation using&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;$ npm install -g ionic@latest&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;(My node version at the time of writing the blog is 12.14.0)&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;Creating a basic Ionic-Angular app. Start a basic &lt;code class="markup--code markup--p-code"&gt;tabs&lt;/code&gt; starter using&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;$ ionic start ionicSign tabs --type=angular --cordova&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;The &lt;code class="markup--code markup--p-code"&gt;--type=angular&lt;/code&gt; told the CLI to create an &lt;strong class="markup--strong markup--p-strong"&gt;Angular&lt;/strong&gt; app, not a &lt;strong class="markup--strong markup--p-strong"&gt;React&lt;/strong&gt; app !!&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;Run the app in browser using&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;$ ionic serve&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;You won’t see much in the homepage created in the starter. I have modified the homepage a little to test our Signature functionality. To make wider space for signatures, I have kept the orientation landscape.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;My homepage looks like this&lt;/p&gt;
&lt;img class="graf-image" alt="Basic UI to test Signature pad functionality in Ionic 5" src="https://res.cloudinary.com/practicaldev/image/fetch/s--I2iCous---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2A5ik6dhdryt9-LZVAxSyvzg.png"&gt;&lt;br&gt;Basic UI to test Signature pad functionality in Ionic 5&lt;blockquote class="graf graf--blockquote graf-after--figure"&gt;HTML code for &lt;code class="markup--code markup--blockquote-code"&gt;tab1.page.html&lt;/code&gt; is given in Step 3&lt;/blockquote&gt;
&lt;h3 class="graf graf--h3 graf-after--blockquote"&gt;
&lt;strong class="markup--strong markup--h3-strong"&gt;Step 2&lt;/strong&gt; — Install required plugins&lt;/h3&gt;
&lt;h4 class="graf graf--h4 graf-after--h3"&gt;&lt;a href="https://www.npmjs.com/package/signature_pad" class="markup--anchor markup--h4-anchor" rel="noopener"&gt;Signature Pad npm package&lt;/a&gt;&lt;/h4&gt;
&lt;p class="graf graf--p graf-after--h4"&gt;We’ll use the Javascript &lt;code class="markup--code markup--p-code"&gt;signature_pad&lt;/code&gt; package for our functionality. Over the years, many angular and ionic plugins have used this package to create signature pad plugins, but at the time of this post none of them is actively maintained. So it is better to use the core package itself.&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;$ npm install --save signature_pad&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;Import the plugin in your &lt;code class="markup--code markup--p-code"&gt;tab1.page.ts&lt;/code&gt;&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;import SignaturePad from 'signature_pad';&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;In &lt;code class="markup--code markup--p-code"&gt;tab1.page.html&lt;/code&gt; , we’ll create a &lt;code class="markup--code markup--p-code"&gt;canvas&lt;/code&gt; element,&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;&amp;lt;canvas class="signature-pad-canvas" #canvas width="900" height="400" style="touch-action: none;"&amp;gt;&amp;lt;/canvas&amp;gt;&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;which can then be referenced in the JS file with&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;export class Tab1Page implements OnInit, AfterViewInit {&lt;/pre&gt;
&lt;pre class="graf graf--pre graf-after--pre"&gt;@ViewChild('canvas', { static: true }) signaturePadElement;&lt;br&gt;.....&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;The signature pad is rendered with&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;this.signaturePad = new SignaturePad(this.signaturePadElement.nativeElement);&lt;/pre&gt;
&lt;h4 class="graf graf--h4 graf-after--pre"&gt;&lt;a href="https://ionicframework.com/docs/native/base64-to-gallery" class="markup--anchor markup--h4-anchor" rel="noopener"&gt;Base64toGallery Plugin&lt;/a&gt;&lt;/h4&gt;
&lt;p class="graf graf--p graf-after--h4"&gt;Our Canvas signature pad will output the signature in png format, but in base64 encoding. To save this in phone’s gallery, we can either&lt;/p&gt;
&lt;ul class="postList"&gt;
&lt;li class="graf graf--li graf-after--p"&gt;Save the base64 data as a blob using FileWrite (you can use it in PWA), OR&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Use base64toGallery Ionic Native Plugin, which does the above for us in an easier fashion&lt;/li&gt;
&lt;/ul&gt;
&lt;p class="graf graf--p graf-after--li"&gt;Install the plugin using&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;$ ionic cordova plugin add cordova-base64-to-gallery&lt;/pre&gt;
&lt;pre class="graf graf--pre graf-after--pre"&gt;$ npm install @ionic-native/base64-to-gallery&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;Import the plugin in &lt;code class="markup--code markup--p-code"&gt;app.module.ts&lt;/code&gt;&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;import { Base64ToGallery } from '@ionic-native/base64-to-gallery/ngx';&lt;/pre&gt;
&lt;pre class="graf graf--pre graf-after--pre"&gt;@NgModule({&lt;br&gt; ...&lt;br&gt; providers: [&lt;br&gt;  ...&lt;br&gt;  Base64ToGallery,&lt;br&gt;  ...&lt;br&gt;})&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;Import the plugin in &lt;code class="markup--code markup--p-code"&gt;tab1.page.ts&lt;/code&gt;&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;import { Base64ToGallery } from '@ionic-native/base64-to-gallery/ngx';&lt;/pre&gt;
&lt;pre class="graf graf--pre graf-after--pre"&gt;constructor(private base64ToGallery: Base64ToGallery){}&lt;/pre&gt;
&lt;h4 class="graf graf--h4 graf-after--pre"&gt;&lt;a href="https://ionicframework.com/docs/native/android-permissions" class="markup--anchor markup--h4-anchor" rel="noopener"&gt;Android Permissions Plugin&lt;/a&gt;&lt;/h4&gt;
&lt;p class="graf graf--p graf-after--h4"&gt;To save images in Android gallery, you need permission to read/write external storage. Android Permissions plugin will help ask the user for permissions. Install the plugin using&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;$ ionic cordova plugin add cordova-plugin-android-permissions&lt;/pre&gt;
&lt;pre class="graf graf--pre graf-after--pre"&gt;$ npm install @ionic-native/android-permissions&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;Import the plugin in &lt;code class="markup--code markup--p-code"&gt;app.module.ts&lt;/code&gt;&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;import { AndroidPermissions } from '@ionic-native/android-permissions/ngx';&lt;/pre&gt;
&lt;pre class="graf graf--pre graf-after--pre"&gt;@NgModule({&lt;br&gt; ...&lt;br&gt; providers: [&lt;br&gt;  ...&lt;br&gt;  AndroidPermissions,&lt;br&gt;  ...&lt;br&gt;})&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;Import the plugin in &lt;code class="markup--code markup--p-code"&gt;tab1.page.ts&lt;/code&gt;&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;import { AndroidPermissions } from '@ionic-native/android-permissions/ngx';&lt;/pre&gt;
&lt;pre class="graf graf--pre graf-after--pre"&gt;constructor(private androidPermissions: AndroidPermissions){}&lt;/pre&gt;
&lt;h3 class="graf graf--h3 graf-after--pre"&gt;
&lt;strong class="markup--strong markup--h3-strong"&gt;Step 3&lt;/strong&gt; — Implement Signature pad functionality&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;Following the above steps, you’ll have a canvas where you can scribble. Here’s the code for &lt;code class="markup--code markup--p-code"&gt;tab1.page.html&lt;/code&gt; and &lt;code class="markup--code markup--p-code"&gt;tab1.page.ts&lt;/code&gt; . We’ll go walk through the code step by step&lt;/p&gt;
&lt;h4 class="graf graf--h4 graf-after--p"&gt;tab1.page.html&lt;/h4&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;h4 class="graf graf--h4 graf-after--figure"&gt;tab1.page.ts&lt;/h4&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;ul class="postList"&gt;
&lt;li class="graf graf--li graf-after--figure"&gt;First, we referenced the &lt;code class="markup--code markup--li-code"&gt;canvas&lt;/code&gt; element from the HTML as &lt;code class="markup--code markup--li-code"&gt;signaturePadElement&lt;/code&gt;, using &lt;code class="markup--code markup--li-code"&gt;@ViewChild&lt;/code&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;
&lt;strong class="markup--strong markup--li-strong"&gt;init()&lt;/strong&gt; — In this function, we are setting &lt;code class="markup--code markup--li-code"&gt;width&lt;/code&gt; and &lt;code class="markup--code markup--li-code"&gt;height&lt;/code&gt; for the signature pad area. This is called on page load, as well as on each window resize&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;In &lt;code class="markup--code markup--li-code"&gt;ngAfterViewInit&lt;/code&gt; , we create the SignaturePad and set the pen color to a specific &lt;strong class="markup--strong markup--li-strong"&gt;RGB&lt;/strong&gt; value. At this point, you can start scribbling text or your signature on the screen&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;
&lt;strong class="markup--strong markup--li-strong"&gt;clear() &lt;/strong&gt;— method clears the canvas of all content&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;
&lt;strong class="markup--strong markup--li-strong"&gt;undo()&lt;/strong&gt; — method clears out the very last stroke from the canvas&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;In the &lt;strong class="markup--strong markup--li-strong"&gt;save()&lt;/strong&gt; method, we use &lt;code class="markup--code markup--li-code"&gt;toDataURL()&lt;/code&gt; This method outputs the canvas content as an image in base64 encoded data. You can then go ahead and save this in gallery using &lt;strong class="markup--strong markup--li-strong"&gt;base64ToGallery &lt;/strong&gt;plugin’s &lt;code class="markup--code markup--li-code"&gt;base64ToGallery&lt;/code&gt; method&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote class="graf graf--blockquote graf-after--li"&gt;
&lt;strong class="markup--strong markup--blockquote-strong"&gt;Note&lt;/strong&gt; : &lt;code class="markup--code markup--blockquote-code"&gt;toDataURL()&lt;/code&gt; method outputs &lt;strong class="markup--strong markup--blockquote-strong"&gt;PNG &lt;/strong&gt;format as default. You can give &lt;code class="markup--code markup--blockquote-code"&gt;image/jpeg&lt;/code&gt; as an argument to get JPEG data as well. However, the &lt;code class="markup--code markup--blockquote-code"&gt;base64ToGallery&lt;/code&gt; plugin is explicitly coded only to handle PNG data. Hence, if you try to save JPEG data from the canvas, the data will not be saved.&lt;/blockquote&gt;
&lt;p class="graf graf--p graf-after--blockquote"&gt;Here’s how the signature pad works&lt;/p&gt;
&lt;img class="graf-image" alt="Signature Pad functionality in Ionic 5" src="https://res.cloudinary.com/practicaldev/image/fetch/s--DjE-yQSJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AnRjryzhWEUgsV_PNovbEow.gif"&gt;&lt;br&gt;Signature Pad functionality in Ionic 5&lt;p class="graf graf--p graf-after--figure"&gt;So we have our own signature pad functionality built in Ionic 5 web app, with Undo and Clear functionalities.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;The &lt;strong class="markup--strong markup--p-strong"&gt;Save() &lt;/strong&gt;method will not work on &lt;code class="markup--code markup--p-code"&gt;ionic serve&lt;/code&gt; as it is dependent on a Cordova plugin. Once you build the app in Android (&lt;strong class="markup--strong markup--p-strong"&gt;Step 5&lt;/strong&gt;) , when you try to save the signature in gallery, you’ll see an error&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;error in saving image&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;(Well ! that’s very informative !!)&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;This happens because we don’t have enough permission to write to the device’s storage.&lt;/p&gt;
&lt;h3 class="graf graf--h3 graf-after--p"&gt;
&lt;strong class="markup--strong markup--h3-strong"&gt;Step 4&lt;/strong&gt; — Save signatures in Android gallery&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;To get permission to write on device’s storage, we’ll use Android Permissions plugin. Install and import the plugin as shown in Step 2. After that, add/modify the following in your &lt;code class="markup--code markup--p-code"&gt;tab1.page.ts&lt;/code&gt; file&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;p class="graf graf--p graf-after--figure"&gt;The &lt;strong class="markup--strong markup--p-strong"&gt;save() &lt;/strong&gt;function now first checks if the app has permission to save on device storage. If not, it calls &lt;strong class="markup--strong markup--p-strong"&gt;requestPermissions &lt;/strong&gt;function , where the app requests a permission using a user prompt.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;Once the permission is granted, the image is saved in device’s gallery. 🎉&lt;/p&gt;
&lt;blockquote class="graf graf--blockquote graf-after--p"&gt;
&lt;strong class="markup--strong markup--blockquote-strong"&gt;The Gotcha&lt;/strong&gt;: If you’re keeping your signature pen color black, and saving image in gallery, make sure you gallery’s background color is not black. If it is, you won’t see anything but black in the image in gallery, because it is a PNG with transparency. Similar result for other color match.&lt;/blockquote&gt;
&lt;img class="graf-image" alt="Request permission to save image in gallery" src="https://res.cloudinary.com/practicaldev/image/fetch/s--pu4_zthk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2A9Rqc9AQd5klN_0nZd7vNPg.jpeg"&gt;&lt;br&gt;Request permission to save image in gallery&lt;h3 class="graf graf--h3 graf-after--figure"&gt;Step 5 — Test in Android&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;If you haven’t already, build the app for a test run in Android using&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;$ ionic cordova platform add android&lt;/pre&gt;
&lt;pre class="graf graf--pre graf-after--pre"&gt;$ ionic cordova run android&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;This will build and run the app in your default emulator or a connected device.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;Remember, you can test the ‘Save to gallery’ functionality only on a device.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;Here’s how the app functions in an android device&lt;/p&gt;
&lt;img class="graf-image" alt="Signature Pad functionality in Ionic 5 App — Android Test" src="https://res.cloudinary.com/practicaldev/image/fetch/s--q-zTzmjK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2At5ObWVdx2TeYyLsqbDxdlg.gif"&gt;&lt;br&gt;Signature Pad functionality in Ionic 5 App — Android Test&lt;p class="graf graf--p graf-after--figure"&gt;Congrats ! you just learnt how to sign in an Ionic 5 app, and save it in the gallery as PNG.&lt;/p&gt;
&lt;h3 class="graf graf--h3 graf-after--p"&gt;Conclusion&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;This post describes how to implement a signature pad functionality in Ionic 5 apps and PWA. You can save these signatures as PNG and use those at a later time. You can also load any image in the &lt;code class="markup--code markup--p-code"&gt;canvas&lt;/code&gt; and mark/write over the image. This can work on PDF content as well, but that is for a later post.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p graf--trailing"&gt;Happy Coding !&lt;/p&gt;

&lt;h3 class="graf graf--h3 graf--leading is-selected"&gt;Next Steps&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;If you liked this blog, you will also find the following blogs interesting and helpful. Feel free to ask any questions in the comment section&lt;/p&gt;
&lt;ul class="postList"&gt;
&lt;li class="graf graf--li graf-after--p"&gt;Ionic Payment Gateways — &lt;a href="https://enappd.com/blog/ionic-4-stripe-payment-integration-with-firebase-for-apps-and-pwa/17" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;Stripe&lt;/a&gt; | &lt;a href="https://enappd.com/blog/ionic-4-paypal-payment-integration-for-apps-and-pwa/16" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;PayPal&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-integrate-apple-pay-in-ionic-4-apps/21" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;Apple Pay&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-integrate-razorpay-in-ionic-4-apps-and-pwa/20" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;RazorPay&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Ionic Charts with — &lt;a href="https://enappd.com/blog/ionic-4-charts-using-google-charts/66" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;Google Charts &lt;/a&gt;| &lt;a href="https://enappd.com/blog/adding-charts-in-ionic-4-apps-and-pwa-part-3/60" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;HighCharts&lt;/a&gt; | &lt;a href="https://enappd.com/blog/adding-charts-in-ionic-4-apps-and-pwa-part-2/54" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;d3.js&lt;/a&gt; | &lt;a href="https://enappd.com/blog/charts-in-ionic-4-apps-and-pwa-part-1/52" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;Chart.js&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Ionic Social Logins — &lt;a href="https://enappd.com/blog/facebook-login-in-ionic-4-apps-using-firebase/25" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;Facebook&lt;/a&gt; | &lt;a href="https://enappd.com/blog/google-login-in-ionic-4-apps-using-firebase/39" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;Google&lt;/a&gt; | &lt;a href="https://enappd.com/blog/twitter-login-in-ionic-4-apps-using-firebase/24" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;Twitter&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Ionic Authentications — &lt;a href="https://enappd.com/blog/email-authentication-with-firebase-in-ionic-4/38" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;Via Email&lt;/a&gt; | &lt;a href="https://enappd.com/blog/firebase-anonymous-login-in-ionic-4/37" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;Anonymous&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Ionic Features — &lt;a href="https://enappd.com/blog/using-geolocation-geocoding-and-reverse-geocoding-in-ionic-4/45" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;Geolocation&lt;/a&gt; | &lt;a href="https://enappd.com/blog/qr-code-scanning-and-optical-character-recognition-ocr-in-ionic-4/9" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;QR Code reader &lt;/a&gt;| &lt;a href="https://enappd.com/blog/best-fitness-plugins-for-ionic-4-how-to-use-pedometer/15" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;Pedometer&lt;/a&gt;| &lt;a href="https://enappd.com/blog/implement-signature-pad-in-ionic-apps/145/" class="markup--anchor markup--li-anchor" rel="noopener"&gt;Signature Pad&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Media in Ionic — &lt;a href="https://enappd.com/blog/spotify-like-music-in-ionic-4-apps/48" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;Audio&lt;/a&gt; | &lt;a href="https://enappd.com/blog/adding-video-player-in-ionic-4-app/64" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;Video&lt;/a&gt; | &lt;a href="https://enappd.com/blog/image-picker-in-ionic-4-app/67" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;Image Picker&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-add-image-cropper-in-ionic-4-app/68" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;Image Cropper&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Ionic Essentials — &lt;a href="https://enappd.com/blog/ionic-4-save-and-retrieve-data-locally-on-device/59" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;Native Storage&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-translate-in-ionic-4-globalization-internationalization-and-localization/11" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;Translations&lt;/a&gt; | &lt;a href="https://enappd.com/blog/rtl-right-to-left-use-in-ionic-4/50" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;RTL&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Ionic messaging — &lt;a href="https://enappd.com/blog/implement-ionic-4-firebase-push/34" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;Firebase Push&lt;/a&gt; | &lt;a href="https://enappd.com/blog/automatically-read-sms-in-ionic-4-apps/42" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;Reading SMS&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li graf--trailing"&gt;Ionic with Firebase — &lt;a href="https://enappd.com/blog/how-to-integrate-firebase-in-ionic-4-apps/23" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;Basics&lt;/a&gt; | &lt;a href="https://enappd.com/blog/firebase-with-ionic-4-hosting-auth-and-db-connection/58" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;Hosting and DB&lt;/a&gt; | &lt;a href="https://enappd.com/blog/firebase-cloud-functions-in-ionic-4-complete-guide/32" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;Cloud functions&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 class="graf graf--h3 graf--leading"&gt;Ionic React Full App with Capacitor&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;If you need a base to start your next Ionic 5 React Capacitor app, you can make your next awesome app using &lt;a href="https://store.enappd.com/product/ionic-react-full-app-capacitor/" class="markup--anchor markup--p-anchor" rel="noopener"&gt;Ionic 5 React Full App in Capacitor&lt;/a&gt;&lt;/p&gt;
&lt;img class="graf-image" alt="Ionic 5 React Full App in Capacitor from Enappd" src="https://res.cloudinary.com/practicaldev/image/fetch/s--Z0sRDsyI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AG3yOFVX4oABx9MhUy-3kng.png"&gt;&lt;br&gt;Ionic 5 React Full App in Capacitor from Enappd&lt;h3 class="graf graf--h3 graf-after--figure"&gt;Ionic Capacitor Full App (Angular)&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;If you need a base to start your next Angular &lt;strong class="markup--strong markup--p-strong"&gt;Capacitor app&lt;/strong&gt;, you can make your next awesome app using &lt;a href="https://store.enappd.com/product/capacitor-full-app-with-ionic-angular/" class="markup--anchor markup--p-anchor" rel="noopener nofollow noopener noopener noopener"&gt;Capacitor Full App&lt;/a&gt;&lt;/p&gt;
&lt;img class="graf-image" alt="Capacitor Full App with huge number of layouts and features" src="https://res.cloudinary.com/practicaldev/image/fetch/s--jbZt2zIJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/0%2AUwSHcofTMStMnzAX.png"&gt;&lt;br&gt;Capacitor Full App with huge number of layouts and features&lt;h3 class="graf graf--h3 graf-after--figure"&gt;Ionic Full App (Angular and Cordova)&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;If you need a base to start your next Ionic 5 app, you can make your next awesome app using &lt;a href="https://store.enappd.com/product/ionic-full-app" class="markup--anchor markup--p-anchor" rel="noopener"&gt;Ionic 5 Full App&lt;/a&gt;&lt;/p&gt;
&lt;img class="graf-image" alt="Ionic Full App with huge number of layouts and features" src="https://res.cloudinary.com/practicaldev/image/fetch/s--V1pEO0Mo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/0%2A1ArpKyhiDHZnevwB.jpeg"&gt;&lt;br&gt;Ionic Full App in Cordova, with huge number of layouts and features

</description>
      <category>angular</category>
      <category>ionic</category>
      <category>signature</category>
      <category>cordova</category>
    </item>
    <item>
      <title>Facebook login in Ionic 5 Cordova apps using Firebase</title>
      <dc:creator>Abhijeet Rathore</dc:creator>
      <pubDate>Sun, 16 Aug 2020 11:29:49 +0000</pubDate>
      <link>https://forem.com/enappd/facebook-login-in-ionic-5-cordova-apps-using-firebase-4pd7</link>
      <guid>https://forem.com/enappd/facebook-login-in-ionic-5-cordova-apps-using-firebase-4pd7</guid>
      <description>
&lt;p class="graf graf--p graf-after--figure"&gt;In this post, you will learn how to implement Facebook authentication in Ionic 5 apps using Firebase 🔥.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;We’ll cook a sample app 👨‍🍳 , where users can login using their Facebook account. After login, users can see their basic profile information on the home page, and sessions are saved in Firebase. On repeat app start, users can auto-login using Firebase session.&lt;/p&gt;
&lt;h3 class="graf graf--h3 graf-after--p"&gt;Social logins — What and why&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;It’s helpful to use social sign-in with Ionic for your users who would rather not create and remember another username/password combination. Instead, you can allow users to sign in with accounts they already own. You don’t need to store hashed passwords to compare, you don’t have to handle sending sign up emails, and you don’t need to reset passwords. The user’s chosen provider will handle all of this for you. Plus, in mobile apps, the Facebook login is automatically done with the pre-installed Facebook app.&lt;/p&gt;
&lt;h3 class="graf graf--h3 graf-after--p"&gt;Facebook login — What and why&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;There are several reasons why you should use a Facebook login in your app&lt;/p&gt;
&lt;ul class="postList"&gt;
&lt;li class="graf graf--li graf-after--p"&gt;
&lt;strong class="markup--strong markup--li-strong"&gt;Ease of use&lt;/strong&gt; — When a new user uses your app, only two buttons clicks are required to login using Facebook. In other scenario, user will have to type in an email/password and login.&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;
&lt;strong class="markup--strong markup--li-strong"&gt;No “forgot password” &lt;/strong&gt;— When your app uses Facebook login, the user does not have to worry about forgetting password for your app’s login.&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;
&lt;strong class="markup--strong markup--li-strong"&gt;No “verify email”&lt;/strong&gt; — If you use a custom-email authentication of your own, you will have to verify the email if it is a valid one or not. Facebook login will always have a valid email/phone number associated.&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;
&lt;strong class="markup--strong markup--li-strong"&gt;Single solution — &lt;/strong&gt;Facebook login can allow your users to use single login credentials across multiple devices.&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;
&lt;strong class="markup--strong markup--li-strong"&gt;Facebook integration&lt;/strong&gt; — If your app uses Facebook authentication, you can use Facebook APIs inside your app as well. This can include fetching user tweets etc.&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;
&lt;strong class="markup--strong markup--li-strong"&gt;Trust&lt;/strong&gt; — Nowadays, people generally trust social logins moreover custom email logins. Social logins follow standard privacy protocols and hence are more reliable for information sharing.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 class="graf graf--h3 graf-after--li"&gt;Ionic Authentication&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;The ionic framework has been around for around 5 years and has been very popular among developers for its ease of usage over Swift / Java. Also in Ionic 5, you get to keep a single source code for both Android and iOS app.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;What more can a developer ask for!&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;Ionic 5 is the latest version (at the time of writing this post) of Ionic and is much more reliable and robust than previous versions.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;There are several ways of Authentication in Ionic 5 apps&lt;/p&gt;
&lt;ul class="postList"&gt;
&lt;li class="graf graf--li graf-after--p"&gt;
&lt;strong class="markup--strong markup--li-strong"&gt;Social logins &lt;/strong&gt;— Social logins are a popular and easy way of authentication in mobile apps. You must have seen Google, Facebook, Instagram logins in almost all the modern apps. Social logins are easy to use and more reliable for quick integrations.&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;
&lt;strong class="markup--strong markup--li-strong"&gt;Create your own back-end&lt;/strong&gt; — You can create your own back-end in Node.js, Go, Django or Ruby-on-rails, and connect your app authentication to your own back-end. This method is favored by developers who need full control over user authentication. But this method is the most time taking one as well.&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;
&lt;strong class="markup--strong markup--li-strong"&gt;Back-end as a Service (BaaS) — &lt;/strong&gt;You&lt;strong class="markup--strong markup--li-strong"&gt; &lt;/strong&gt;can use pre-built BaaS platforms which allows easy integration of authentication in your apps. Basically, these platforms provide you with a ready-made back-end, so you don’t have to make one on your own. Firebase, Parse, &lt;em class="markup--em markup--li-em"&gt;Back4App&lt;/em&gt; are some BaaS platforms.&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;
&lt;strong class="markup--strong markup--li-strong"&gt;&lt;em class="markup--em markup--li-em"&gt;Firebase&lt;/em&gt;&lt;/strong&gt; is the most popular among these for mobile apps, which we’ll study in the next section.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 class="graf graf--h3 graf-after--li"&gt;Firebase&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;Firebase is a Backend-as-a-Service (BaaS) platform. It started as a &lt;a href="http://blog.ycombinator.com/firebase-yc-s11-raises-5-dollars-dot-6m-series-a-from-union-square-ventures-and-flybridge" class="markup--anchor markup--p-anchor" rel="noopener nofollow noopener noopener"&gt;YC11 startup&lt;/a&gt; and grew up into a next-generation app-development platform on Google Cloud Platform. It is getting popular by the day because of the ease of integration and a variety of functionalities available on it.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;A lot of quick integrations are available with Firebase. Some of these are listed below:&lt;/p&gt;
&lt;ul class="postList"&gt;
&lt;li class="graf graf--li graf-after--p"&gt;Real-time database&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Email Authentication&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Social logins&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;In-app messages&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Push notifications&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Analytics&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Crashlytics&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Remote config&lt;/li&gt;
&lt;/ul&gt;
&lt;p class="graf graf--p graf-after--li"&gt;Firebase is quickly growing to become the most popular mobile app back-end platform.&lt;/p&gt;
&lt;h4 class="graf graf--h4 graf-after--p"&gt;Firebase Authentication Options&lt;/h4&gt;
&lt;p class="graf graf--p graf-after--h4"&gt;Firebase not only provides ready-made email authentication but also provides authentication using a variety of social logins. You can see the authentication options available with Firebase.&lt;/p&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--H2XrPx6X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AT0ahVQ8vWbQOd-Eg6-HEbw.jpeg"&gt;&lt;br&gt;Authentication options available in Firebase&lt;p class="graf graf--p graf-after--figure"&gt;We will use Firebase to store user profile information once the Facebook login is done. This is the preferred method, as it is reliable for both apps and PWA.&lt;/p&gt;
&lt;h3 class="graf graf--h3 graf-after--p"&gt;Steps for Facebook authentication&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;We will follow these step-by-step instructions to create our Ionic 5 app with Facebook authentication&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;&lt;strong class="markup--strong markup--p-strong"&gt;Step 1&lt;/strong&gt;: Setting up a latest Ionic CLI&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;&lt;strong class="markup--strong markup--p-strong"&gt;Step 2&lt;/strong&gt;: Creating an Ionic 5 app&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;&lt;strong class="markup--strong markup--p-strong"&gt;Step 3&lt;/strong&gt;: Facebook Developer Console — Create your app&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;&lt;strong class="markup--strong markup--p-strong"&gt;Step 4&lt;/strong&gt;: Add your Platforms to Facebook&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;&lt;strong class="markup--strong markup--p-strong"&gt;‌Step 5&lt;/strong&gt;: Enable Facebook Sign-In in Firebase project&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;&lt;strong class="markup--strong markup--p-strong"&gt;‌Step 6&lt;/strong&gt;: Install the Cordova Facebook Plugin to connect your app with Firebase&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;&lt;strong class="markup--strong markup--p-strong"&gt;Step 7&lt;/strong&gt;: Authenticate Users using Facebook&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;&lt;strong class="markup--strong markup--p-strong"&gt;Step 8&lt;/strong&gt;: Store the Facebook auth tokens in Firebase&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;&lt;strong class="markup--strong markup--p-strong"&gt;Step 9&lt;/strong&gt;: Use Firebase to auto-login the user&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;&lt;strong class="markup--strong markup--p-strong"&gt;Step 10&lt;/strong&gt;: Test your app for Android&lt;/p&gt;
&lt;h3 class="graf graf--h3 graf-after--p"&gt;Step 1: Setting up a latest Ionic CLI&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;Make sure the latest version of the Ionic CLI is installed. Get the installed version by running &lt;code class="markup--code markup--p-code"&gt;ionic --version&lt;/code&gt;&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;My node version for this post is &lt;strong class="markup--strong markup--p-strong"&gt;12.13.1&lt;/strong&gt;. See &lt;a href="https://ionicframework.com/docs/intro/environment#node-npm" class="markup--anchor markup--p-anchor" rel="noopener"&gt;Node &amp;amp; npm&lt;/a&gt; environment setup.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;(At the time of writing the blog, my node version is 12.13.1)&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;&lt;strong class="markup--strong markup--p-strong"&gt;Step1.1&lt;/strong&gt;: Installation&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;The Ionic CLI can be installed globally with npm:&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;&lt;code class="markup--code markup--pre-code"&gt;$ npm install -g @ionic/cli&lt;/code&gt;&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;And you are good to go. Check your environment information using&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;$ ionic info&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;This will display your runtime environment, something like following (Android SDK tools and XCode will require separate installations)&lt;/p&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s---AIyypys--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AxpZrOslOU6qS_-woOaHMSg.jpeg"&gt;&lt;br&gt;Development environment information&lt;h3 class="graf graf--h3 graf-after--figure"&gt;Step 2: Creating an Ionic 5 app&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;For the purposes of this post we’ll create an app using the below command:&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;&lt;code class="markup--code markup--pre-code"&gt;$ ionic start facebook-login sidemenu&lt;/code&gt;&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;For now, we only need to know that this command creates a sidemnu layout app with the following structure.&lt;/p&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--vxWKruD9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AdRHARQ6gy3JLzFVA6hzgJg.jpeg"&gt;&lt;br&gt;Folder structure&lt;h3 class="graf graf--h3 graf-after--figure"&gt;Step 3: Facebook Developer Console&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;The first thing we need to do is to create a new application in Facebook’s developer dashboard, and this app is the one that Facebook will use to ask our users for their permission when we try to log them into our Ionic application.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;For that, you’ll need to go to &lt;a href="https://developers.facebook.com/apps" class="markup--anchor markup--p-anchor" rel="noopener"&gt;&lt;strong class="markup--strong markup--p-strong"&gt;F&lt;/strong&gt;&lt;/a&gt;&lt;a href="https://developers.facebook.com/apps" class="markup--anchor markup--p-anchor" rel="noopener noreferrer noopener noopener"&gt;&lt;strong class="markup--strong markup--p-strong"&gt;acebook developer console&lt;/strong&gt;&lt;/a&gt; and create a new app.&lt;/p&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--32aKdmt0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AxhUabRpSLLGxauvD5JCkuw.jpeg"&gt;&lt;br&gt;Select the type of Application Facebook Developer console&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--e13ndUPY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AKB2yU0H7wuv12iyV8DhBYg.jpeg"&gt;&lt;br&gt;Create new app in Facebook Developer console&lt;p class="graf graf--p graf-after--figure"&gt;Once we finish creating our app, we will go to Facebook app dashboard and pick &lt;strong class="markup--strong markup--p-strong"&gt;App Id&lt;/strong&gt; from there. It will be required in installing Facebook plugin in the app.&lt;/p&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--tbFSRDCW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2ApH3KFkmz3hMjD_josuUHuQ.jpeg"&gt;&lt;br&gt;Facebook Developer Console — App ID on top-left&lt;h3 class="graf graf--h3 graf-after--figure"&gt;Step 4: Add your Platforms to Facebook&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;We need to let Facebook know which platforms we’ll be using (&lt;em class="markup--em markup--p-em"&gt;if it’s just web, iOS, or Android&lt;/em&gt;).&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;‌In our case, we will add all platforms iOS and Android.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;To add the platforms, go ahead inside your Facebook dashboard and click on &lt;strong class="markup--strong markup--p-strong"&gt;Settings&lt;/strong&gt;, then right below the app’s information you’ll see a button that says &lt;strong class="markup--strong markup--p-strong"&gt;Add Platform&lt;/strong&gt;, click it.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;You’ll see several options for the platforms you’re creating&lt;/p&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--nWeHQ9_k--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AmFcr7IhywkC5djSkRs--nw.jpeg"&gt;&lt;br&gt;Options to create platforms&lt;h4 class="graf graf--h4 graf-after--figure"&gt;Add Platforms in Facebook dashboard&lt;/h4&gt;
&lt;p class="graf graf--p graf-after--h4"&gt;&lt;strong class="markup--strong markup--p-strong"&gt;Let’s start with iOS:-&lt;/strong&gt; You’ll see a form asking you for some information, right now we just need the &lt;code class="markup--code markup--p-code"&gt;Bundle ID&lt;/code&gt;.&lt;/p&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--Un8c2c4g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AyuwwCAhHl-Sz8zgk4MTZ1w.jpeg"&gt;&lt;br&gt;Create an iOS app in Facebook console&lt;p class="graf graf--p graf-after--figure"&gt;If you don’t know where to get the Bundle ID, it’s the same as the package name when you create an Ionic app, it’s inside your &lt;code class="markup--code markup--p-code"&gt;config.xml&lt;/code&gt; file:&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;&amp;lt;widget id="io.ionic.sociallogin" version="0.0.1" xmlns="&lt;a href="http://www.w3.org/ns/widgets"&gt;http://www.w3.org/ns/widgets&lt;/a&gt;" xmlns:cdv="&lt;a href="http://cordova.apache.org/ns/1.0"&gt;http://cordova.apache.org/ns/1.0&lt;/a&gt;"&amp;gt;&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;Once you add the Bundle ID, just follow the process to create the app.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;&lt;strong class="markup--strong markup--p-strong"&gt;Android:-&lt;/strong&gt; The difference is that instead of &lt;code class="markup--code markup--p-code"&gt;Bundle ID&lt;/code&gt;, Android calls it “&lt;strong class="markup--strong markup--p-strong"&gt;Google Play Package Name&lt;/strong&gt;”.&lt;/p&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--EBYwqMCi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2Aw_cOaOKvkRdbVHnEFrfmyw.jpeg"&gt;&lt;br&gt;Create an Android app in Facebook console&lt;h3 class="graf graf--h3 graf-after--figure"&gt;Step 5: Enable Facebook Login in Firebase.&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;Now that everything is set up on Facebook’s side, we need to go into our Firebase console and enable Facebook authentication for our app.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;‌To enable Facebook, you’ll need to go to &lt;a href="https://console.firebase.google.com/" class="markup--anchor markup--p-anchor" rel="noopener noreferrer noopener noopener"&gt;your Firebase Console&lt;/a&gt; and locate the app you’re using (or create a new Firebase project)&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;‌Once you’re inside the app’s dashboard, you’re going to go into &lt;strong class="markup--strong markup--p-strong"&gt;Authentication &amp;gt; Sign-In Method &amp;gt; Facebook&lt;/strong&gt; and are going to click the &lt;strong class="markup--strong markup--p-strong"&gt;Enable&lt;/strong&gt; toggle.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;It will ask you App ID and App secret. Copy it from your Facebook console, under your app’s settings.&lt;/p&gt;
&lt;h3 class="graf graf--h3 graf-after--p"&gt;Step 6: Install the Facebook Cordova Plugin&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;Open your terminal and type&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;$ ionic cordova plugin add cordova-plugin-facebook4 --variable APP_ID="FACEBOOK_APP_ID" --variable APP_NAME="myApplication"&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;You’ll need to replace the values or &lt;code class="markup--code markup--p-code"&gt;FACEBOOK_APP_ID&lt;/code&gt; and &lt;code class="markup--code markup--p-code"&gt;APP_NAME&lt;/code&gt; with your real credentials. You can find both of these inside your Facebook Developers Dashboard.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;You’ll see a warning from Ionic saying they prefer Capacitor over Cordova now. But that is ok, you can proceed with Cordova itself. &lt;strong class="markup--strong markup--p-strong"&gt;If you want to implement Facebook login with Capacitor, &lt;/strong&gt;&lt;a href="https://enappd.com/blog/facebook-login-in-capacitor-apps-with-ionic-angular/128" class="markup--anchor markup--p-anchor" rel="noopener"&gt;&lt;strong class="markup--strong markup--p-strong"&gt;check my other blog&lt;/strong&gt;&lt;/a&gt;&lt;strong class="markup--strong markup--p-strong"&gt;.&lt;/strong&gt;&lt;/p&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--aiHWB9ei--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AtYhKlsT8b4MBMP0AU4jrrQ.jpeg"&gt;&lt;br&gt;Process to install Facebook Plugin&lt;p class="graf graf--p graf-after--figure"&gt;Open your terminal and run this command‌ to install Facebook package from Ionic Native.&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;$ npm install --save @ionic-native/facebook&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;Also, we need to install &lt;a href="https://github.com/angular/angularfire2" class="markup--anchor markup--p-anchor" rel="nofollow noopener noopener noopener"&gt;AngularFire2 npm module&lt;/a&gt; and &lt;a href="https://www.npmjs.com/package/firebase" class="markup--anchor markup--p-anchor" rel="noopener"&gt;Firebase&lt;/a&gt;, which actually connects the Firebase functionality to Ionic app. To install the module, run&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;$ npm install firebase @angular/fire --save&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;Also, include &lt;code class="markup--code markup--p-code"&gt;environment&lt;/code&gt; ,&lt;code class="markup--code markup--p-code"&gt;AngularFireModule&lt;/code&gt; and &lt;code class="markup--code markup--p-code"&gt;AngularFireAuthModule&lt;/code&gt;in &lt;code class="markup--code markup--p-code"&gt;app.module.ts&lt;/code&gt;&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;p class="graf graf--p graf-after--figure"&gt;Notice that Firebase is initialized in your app with&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;AngularFireModule.initializeApp(environment.firebaseConfig)&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;where &lt;code class="markup--code markup--p-code"&gt;environment.config&lt;/code&gt; is the Firebase config you picked from Firebase project.&lt;/p&gt;
&lt;blockquote class="graf graf--blockquote graf-after--p"&gt;
&lt;em class="markup--em markup--blockquote-em"&gt;Details of this step can be found in our blog &lt;/em&gt;&lt;a href="https://enappd.com/blog/connect-firebase-with-ionic-5-app/134/" class="markup--anchor markup--blockquote-anchor" rel="noopener"&gt;How to connect Firebase with Ionic 5 App&lt;/a&gt;
&lt;/blockquote&gt;
&lt;p class="graf graf--p graf-after--blockquote"&gt;To connect your app to Firebase, you first need a Firebase project. From the project, pick up your Firebase config parameters and include them in an &lt;code class="markup--code markup--p-code"&gt;environment.ts&lt;/code&gt; file at the root of your Ionic project. The environment file will look like following.&lt;/p&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--P52jBTiT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2A-CySwP5vyY5P6HxWZqQ2gw.jpeg"&gt;&lt;br&gt;Firebase config params in environment file&lt;p class="graf graf--p graf-after--figure"&gt;You can create two different environment files for development and production environments — &lt;code class="markup--code markup--p-code"&gt;environment.ts&lt;/code&gt; and &lt;code class="markup--code markup--p-code"&gt;environment.prod.ts&lt;/code&gt;&lt;/p&gt;
&lt;h3 class="graf graf--h3 graf-after--p"&gt;Step 7: Authenticate Users.&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;The first thing we need to do is to get the authorization token from Facebook. To do that, we need to import Facebook plugin from Ionic Native and ask our user to log in. The import and login functions will be as follows:&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--rVXZv1fX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AQ1DYDU6etSgS3PdcGr3_oQ.png"&gt;&lt;br&gt;Login Page&lt;p class="graf graf--p graf-after--figure"&gt;This function will give you Facebook Token and from this token, we will login user to Firebase app.&lt;/p&gt;
&lt;h3 class="graf graf--h3 graf-after--p"&gt;Step 8— Store the Facebook auth token in Firebase&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;In the previous step, the authentication is done via a Facebook app on your phone. Once logged in, you will receive a &lt;code class="markup--code markup--p-code"&gt;token&lt;/code&gt; response. This info will be used to connect to Firebase in the &lt;code class="markup--code markup--p-code"&gt;success&lt;/code&gt; of Facebook login.&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;p class="graf graf--p graf-after--figure"&gt;So, in short, we have logged in via Facebook and created a Firebase user using the Facebook auth token. From now on, Firebase can handle your login/logout in the app. After we store the token in Firebase, we navigate to a &lt;strong class="markup--strong markup--p-strong"&gt;Profile&lt;/strong&gt; page.&lt;/p&gt;
&lt;h4 class="graf graf--h4 graf-after--p"&gt;Get user profile info&lt;/h4&gt;
&lt;p class="graf graf--p graf-after--h4"&gt;In the &lt;strong class="markup--strong markup--p-strong"&gt;Profile&lt;/strong&gt; page, we will get the profile information of the user using the Firebase Auth Module again.&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--RkKmfaoK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2ABtLU99PhmI-pIO1YT_O5Cg.png"&gt;&lt;br&gt;User Profile Page&lt;blockquote class="graf graf--blockquote graf-after--figure"&gt;
&lt;strong class="markup--strong markup--blockquote-strong"&gt;Note&lt;/strong&gt;:- If you want profile image with better resolution you can check &lt;a href="https://developers.facebook.com/docs/graph-api/" class="markup--anchor markup--blockquote-anchor" rel="noopener"&gt;Facebook graph API&lt;/a&gt;
&lt;/blockquote&gt;
&lt;h4 class="graf graf--h4 graf-after--blockquote"&gt;Logout function&lt;/h4&gt;
&lt;p class="graf graf--p graf-after--h4"&gt;Since Firebase is now handling the login/logout, the logout function in &lt;code class="markup--code markup--p-code"&gt;profile.page.ts&lt;/code&gt; the logout code will look like following.&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;h3 class="graf graf--h3 graf-after--figure"&gt;Step 9— Use Firebase to auto-login the user&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;At this point, we have covered the following points&lt;/p&gt;
&lt;ul class="postList"&gt;
&lt;li class="graf graf--li graf-after--p"&gt;Login with Cordova Facebook plugin&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Pass Facebook auth token to Firebase&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Fetch user profile info via the Facebook plugin&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Logout using Firebase&lt;/li&gt;
&lt;/ul&gt;
&lt;p class="graf graf--p graf-after--li"&gt;Now, if the user does not logout and leaves the app, we want the app to auto-login the next time user starts the app. For this, we will use Firebase’s &lt;code class="markup--code markup--p-code"&gt;onAuthStateChanged&lt;/code&gt; function at the start of the app. If there is a valid user logged in, it will return the user’s information. Our &lt;code class="markup--code markup--p-code"&gt;app.component.ts&lt;/code&gt; the file will look like following&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;h3 class="graf graf--h3 graf-after--figure"&gt;Step 10: Test your app on Android&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;To test this app you’ll need to run in a real device. You can do it generating an APK using the command &lt;code class="markup--code markup--p-code"&gt;ionic cordova run android&lt;/code&gt; . Here we’ll use the first method.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;So, run the below commando to generate your APK.&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;$ ionic cordova build android&lt;/pre&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--AbDOu-am--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2ArCWKqDD0IoGuhEUc7aG6gw.gif"&gt;&lt;br&gt;Gif Demo&lt;blockquote class="graf graf--blockquote graf-after--figure"&gt;&lt;strong class="markup--strong markup--blockquote-strong"&gt;Note: If your app still in Development Mode then it throws an error like below image.&lt;/strong&gt;&lt;/blockquote&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--h-ND4tDm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2A8YR4jJjBLgWHllui4OVBxg.jpeg"&gt;&lt;br&gt;Developer Mode ON error&lt;p class="graf graf--p graf-after--figure"&gt;&lt;strong class="markup--strong markup--p-strong"&gt;Follow these steps to make it live:&lt;/strong&gt;&lt;/p&gt;
&lt;ul class="postList"&gt;
&lt;li class="graf graf--li graf-after--p"&gt;Login to Facebook developer account &lt;a href="https://developers.facebook.com/" class="markup--anchor markup--li-anchor" rel="nofollow noreferrer noopener"&gt;&lt;/a&gt;&lt;a href="https://developers.facebook.com/"&gt;https://developers.facebook.com/&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Goto you app dashboard&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Switch on to change status live (before that you just need to fill privacy policy URL and etc. in basic setting).&lt;/li&gt;
&lt;/ul&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ku1lok0V--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AApj897GvooDlgkzzTzklGA.jpeg"&gt;&lt;br&gt;Enable Live Mode&lt;h3 class="graf graf--h3 graf-after--figure"&gt;Conclusion&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3 graf--trailing"&gt;In this post, you learnt how to implement Facebook login in your Ionic 5 app. You also learnt how to auto-login your user using info stored in Firebase. The Firebase integration done for Authentication, can be used for various purposes like Database CRUD operations, push notifications, analytics etc.&lt;/p&gt;



&lt;h3 class="graf graf--h3 graf--leading"&gt;Next Steps&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;If you liked this blog, you will also find the following blogs interesting and helpful. Feel free to ask any questions in the comment section&lt;/p&gt;
&lt;ul class="postList"&gt;
&lt;li class="graf graf--li graf-after--p"&gt;Ionic Payment Gateways — &lt;a href="https://medium.com/r/?url=https%3A%2F%2Fenappd.com%2Fblog%2Fionic-4-stripe-payment-integration-with-firebase-for-apps-and-pwa%2F17" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;Stripe&lt;/a&gt; | &lt;a href="https://medium.com/r/?url=https%3A%2F%2Fenappd.com%2Fblog%2Fionic-4-paypal-payment-integration-for-apps-and-pwa%2F16" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;PayPal&lt;/a&gt; | &lt;a href="https://medium.com/r/?url=https%3A%2F%2Fenappd.com%2Fblog%2Fhow-to-integrate-apple-pay-in-ionic-4-apps%2F21" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;Apple Pay&lt;/a&gt; | &lt;a href="https://medium.com/r/?url=https%3A%2F%2Fenappd.com%2Fblog%2Fhow-to-integrate-razorpay-in-ionic-4-apps-and-pwa%2F20" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;RazorPay&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Ionic Charts with — &lt;a href="https://medium.com/r/?url=https%3A%2F%2Fenappd.com%2Fblog%2Fionic-4-charts-using-google-charts%2F66" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;Google Charts &lt;/a&gt;| &lt;a href="https://medium.com/r/?url=https%3A%2F%2Fenappd.com%2Fblog%2Fadding-charts-in-ionic-4-apps-and-pwa-part-3%2F60" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;HighCharts&lt;/a&gt; | &lt;a href="https://medium.com/r/?url=https%3A%2F%2Fenappd.com%2Fblog%2Fadding-charts-in-ionic-4-apps-and-pwa-part-2%2F54" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;d3.js&lt;/a&gt; | &lt;a href="https://medium.com/r/?url=https%3A%2F%2Fenappd.com%2Fblog%2Fcharts-in-ionic-4-apps-and-pwa-part-1%2F52" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;Chart.js&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Ionic Social Logins — &lt;a href="https://medium.com/r/?url=https%3A%2F%2Fenappd.com%2Fblog%2Ffacebook-login-in-ionic-4-apps-using-firebase%2F25" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;Facebook&lt;/a&gt; | &lt;a href="https://medium.com/r/?url=https%3A%2F%2Fenappd.com%2Fblog%2Fgoogle-login-in-ionic-4-apps-using-firebase%2F39" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;Google&lt;/a&gt; | &lt;a href="https://medium.com/r/?url=https%3A%2F%2Fenappd.com%2Fblog%2Ftwitter-login-in-ionic-4-apps-using-firebase%2F24" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;Twitter&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Ionic Authentications — &lt;a href="https://medium.com/r/?url=https%3A%2F%2Fenappd.com%2Fblog%2Femail-authentication-with-firebase-in-ionic-4%2F38" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;Via Email&lt;/a&gt; | &lt;a href="https://medium.com/r/?url=https%3A%2F%2Fenappd.com%2Fblog%2Ffirebase-anonymous-login-in-ionic-4%2F37" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;Anonymous&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Ionic Features — &lt;a href="https://medium.com/r/?url=https%3A%2F%2Fenappd.com%2Fblog%2Fusing-geolocation-geocoding-and-reverse-geocoding-in-ionic-4%2F45" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;Geolocation&lt;/a&gt; | &lt;a href="https://medium.com/r/?url=https%3A%2F%2Fenappd.com%2Fblog%2Fqr-code-scanning-and-optical-character-recognition-ocr-in-ionic-4%2F9" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;QR Code reader &lt;/a&gt;| &lt;a href="https://medium.com/r/?url=https%3A%2F%2Fenappd.com%2Fblog%2Fbest-fitness-plugins-for-ionic-4-how-to-use-pedometer%2F15" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;Pedometer&lt;/a&gt;| &lt;a href="https://medium.com/r/?url=https%3A%2F%2Fenappd.com%2Fblog%2Fimplement-signature-pad-in-ionic-apps%2F145%2F" class="markup--anchor markup--li-anchor" rel="noopener"&gt;Signature Pad&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Media in Ionic — &lt;a href="https://medium.com/r/?url=https%3A%2F%2Fenappd.com%2Fblog%2Fspotify-like-music-in-ionic-4-apps%2F48" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;Audio&lt;/a&gt; | &lt;a href="https://medium.com/r/?url=https%3A%2F%2Fenappd.com%2Fblog%2Fadding-video-player-in-ionic-4-app%2F64" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;Video&lt;/a&gt; | &lt;a href="https://medium.com/r/?url=https%3A%2F%2Fenappd.com%2Fblog%2Fimage-picker-in-ionic-4-app%2F67" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;Image Picker&lt;/a&gt; | &lt;a href="https://medium.com/r/?url=https%3A%2F%2Fenappd.com%2Fblog%2Fhow-to-add-image-cropper-in-ionic-4-app%2F68" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;Image Cropper&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Ionic Essentials — &lt;a href="https://medium.com/r/?url=https%3A%2F%2Fenappd.com%2Fblog%2Fionic-4-save-and-retrieve-data-locally-on-device%2F59" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;Native Storage&lt;/a&gt; | &lt;a href="https://medium.com/r/?url=https%3A%2F%2Fenappd.com%2Fblog%2Fhow-to-translate-in-ionic-4-globalization-internationalization-and-localization%2F11" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;Translations&lt;/a&gt; | &lt;a href="https://medium.com/r/?url=https%3A%2F%2Fenappd.com%2Fblog%2Frtl-right-to-left-use-in-ionic-4%2F50" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;RTL&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Ionic messaging — &lt;a href="https://medium.com/r/?url=https%3A%2F%2Fenappd.com%2Fblog%2Fimplement-ionic-4-firebase-push%2F34" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;Firebase Push&lt;/a&gt; | &lt;a href="https://medium.com/r/?url=https%3A%2F%2Fenappd.com%2Fblog%2Fautomatically-read-sms-in-ionic-4-apps%2F42" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;Reading SMS&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li graf--trailing"&gt;Ionic with Firebase — &lt;a href="https://medium.com/r/?url=https%3A%2F%2Fenappd.com%2Fblog%2Fhow-to-integrate-firebase-in-ionic-4-apps%2F23" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;Basics&lt;/a&gt; | &lt;a href="https://medium.com/r/?url=https%3A%2F%2Fenappd.com%2Fblog%2Ffirebase-with-ionic-4-hosting-auth-and-db-connection%2F58" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;Hosting and DB&lt;/a&gt; | &lt;a href="https://medium.com/r/?url=https%3A%2F%2Fenappd.com%2Fblog%2Ffirebase-cloud-functions-in-ionic-4-complete-guide%2F32" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;Cloud functions&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;



&lt;h3 class="graf graf--h3 graf--leading is-selected"&gt;Ionic React Full App with Capacitor&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;If you need a base to start your next Ionic 5 React Capacitor app, you can make your next awesome app using &lt;a href="https://medium.com/r/?url=https%3A%2F%2Fstore.enappd.com%2Fproduct%2Fionic-react-full-app-capacitor%2F" class="markup--anchor markup--p-anchor" rel="noopener"&gt;Ionic 5 React Full App in Capacitor&lt;/a&gt;&lt;/p&gt;
&lt;img class="graf-image" alt="Ionic 5 React Full App in Capacitor from Enappd" src="https://res.cloudinary.com/practicaldev/image/fetch/s--Z0sRDsyI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AG3yOFVX4oABx9MhUy-3kng.png"&gt;Ionic 5 React Full App in Capacitor from Enappd&lt;h3 class="graf graf--h3 graf-after--figure"&gt;Ionic Capacitor Full App (Angular)&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;If you need a base to start your next Angular &lt;strong class="markup--strong markup--p-strong"&gt;Capacitor app&lt;/strong&gt;, you can make your next awesome app using &lt;a href="https://medium.com/r/?url=https%3A%2F%2Fstore.enappd.com%2Fproduct%2Fcapacitor-full-app-with-ionic-angular%2F" class="markup--anchor markup--p-anchor" rel="noopener nofollow noopener noopener"&gt;Capacitor Full App&lt;/a&gt;&lt;/p&gt;
&lt;img class="graf-image" alt="Capacitor Full App with huge number of layouts and features" src="https://res.cloudinary.com/practicaldev/image/fetch/s--jbZt2zIJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/0%2AUwSHcofTMStMnzAX.png"&gt;Capacitor Full App with huge number of layouts and features&lt;h3 class="graf graf--h3 graf-after--figure"&gt;Ionic Full App (Angular and Cordova)&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;If you need a base to start your next Ionic 5 app, you can make your next awesome app using &lt;a href="https://medium.com/r/?url=https%3A%2F%2Fstore.enappd.com%2Fproduct%2Fionic-full-app" class="markup--anchor markup--p-anchor" rel="noopener"&gt;Ionic 5 Full App&lt;/a&gt;&lt;/p&gt;
&lt;img class="graf-image" alt="Ionic Full App with huge number of layouts and features" src="https://res.cloudinary.com/practicaldev/image/fetch/s--V1pEO0Mo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/0%2A1ArpKyhiDHZnevwB.jpeg"&gt;Ionic Full App in Cordova, with huge number of layouts and features


</description>
      <category>angular</category>
      <category>cordova</category>
      <category>ionic</category>
      <category>facebook</category>
    </item>
    <item>
      <title>How to use RTL (right-to-left) in Ionic 5 apps and PWA</title>
      <dc:creator>Abhijeet Rathore</dc:creator>
      <pubDate>Sun, 16 Aug 2020 11:16:56 +0000</pubDate>
      <link>https://forem.com/enappd/how-to-use-rtl-right-to-left-in-ionic-5-apps-and-pwa-2afh</link>
      <guid>https://forem.com/enappd/how-to-use-rtl-right-to-left-in-ionic-5-apps-and-pwa-2afh</guid>
      <description>
&lt;p class="graf graf--p graf-after--figure"&gt;RTL is a very specific feature desired by people whose language is written from right to left. In this post you’ll learn how to implement RTL in Ionic 5.&lt;br&gt; I will also show how various Ionic components look in an RTL layout.&lt;/p&gt;
&lt;blockquote class="graf graf--blockquote graf-after--p"&gt;
&lt;strong class="markup--strong markup--blockquote-strong"&gt;All the layouts used in this blogpost can be found in &lt;/strong&gt;&lt;a href="https://store.enappd.com/product/ionic-full-app/" class="markup--anchor markup--blockquote-anchor"&gt;&lt;strong class="markup--strong markup--blockquote-strong"&gt;Ionic 5 Full app starter&lt;/strong&gt;&lt;/a&gt;
&lt;/blockquote&gt;
&lt;h3 class="graf graf--h3 graf-after--blockquote"&gt;What is RTL (Right to Left)&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;LTR (left-to-right) and RTL (right-to-left) are the two major layout patterns based on various languages in the world. The major difference between LTR and RTL language scripts is the direction in which content is displayed:&lt;/p&gt;
&lt;ul class="postList"&gt;
&lt;li class="graf graf--li graf-after--p"&gt;LTR languages display content from left to right&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;RTL languages display content from right to left&lt;/li&gt;
&lt;/ul&gt;
&lt;p class="graf graf--p graf-after--li"&gt;RTL content also affects the direction in which some icons and images are displayed, particularly those depicting a sequence of events. For example, &lt;code class="markup--code markup--p-code"&gt;ion-item&lt;/code&gt; component has a left-to-right flow by default, whatever element is added inside it. But making the content RTL makes the whole layout mirrored.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;In general, the passage of time is depicted as left to right for LTR languages, and right to left for RTL languages.&lt;/p&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--s23EdH3X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2Ah9eBYKF0LEK7tZfTZk6gfg.jpeg"&gt;&lt;br&gt;LTR and RTL layout comparison for a simple form&lt;p class="graf graf--p graf-after--figure"&gt;In the above image, notice the&lt;/p&gt;
&lt;ul class="postList"&gt;
&lt;li class="graf graf--li graf-after--p"&gt;Change in text alignment&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Change in position of * on the words&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Position of down arrow for the dropdown&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Change in position of Hamburger menu and filter icon in header&lt;/li&gt;
&lt;/ul&gt;
&lt;p class="graf graf--p graf-after--li"&gt;This will give you a basic idea of RTL layouts.&lt;/p&gt;
&lt;blockquote class="graf graf--blockquote graf-after--p"&gt;Notice that since both the images above have English as the language, you still see the actual sentence going from left-to-right. But when you are writing in an RTL language, the text will start from right to left.&lt;/blockquote&gt;
&lt;h3 class="graf graf--h3 graf-after--blockquote"&gt;What is Ionic 5&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;I know most of the readers reading this blog will know what is Ionic 5, but just for the sake of beginners, I explain this in my every blog.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;You probably already know about Ionic, but put this section in every blog just for the sake of beginners. &lt;strong class="markup--strong markup--p-strong"&gt;Ionic&lt;/strong&gt; is a complete open-source SDK for hybrid mobile app development. Ionic provides tools and services for developing hybrid mobile apps using Web technologies like CSS, HTML5, and Sass. Apps can be built with these Web technologies and then distributed through native app stores to be installed on devices.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;In other words — If you create native apps in Android, you code in &lt;strong class="markup--strong markup--p-strong"&gt;Java&lt;/strong&gt;. If you create native apps in iOS, you code in &lt;strong class="markup--strong markup--p-strong"&gt;Obj-C&lt;/strong&gt; or &lt;strong class="markup--strong markup--p-strong"&gt;Swift&lt;/strong&gt;. Both of these are powerful, but complex languages. With Cordova (and Ionic) you can write a single piece of code for your app that can run on both iOS and Android (and windows!), that too with the simplicity of HTML, CSS, and JS. I’m a huge fan of Ionic and been developing Ionic apps for last 4 years.&lt;/p&gt;
&lt;h3 class="graf graf--h3 graf-after--p"&gt;How to implement RTL in Ionic 5 apps&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;Implementing RTL in Ionic 5 apps is very easy. It can be done in two ways&lt;/p&gt;
&lt;ul class="postList"&gt;
&lt;li class="graf graf--li graf-after--p"&gt;Using &lt;code class="markup--code markup--li-code"&gt;dir="rtl"&lt;/code&gt; attribute in HTML tags&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Using &lt;code class="markup--code markup--li-code"&gt;direction= rtl&lt;/code&gt; in css&lt;/li&gt;
&lt;/ul&gt;
&lt;p class="graf graf--p graf-after--li"&gt;All implementations revolve around these two methods. Following are the ways you can implement RTL in your Ionic 5 app.&lt;/p&gt;
&lt;h4 class="graf graf--h4 graf-after--p"&gt;1. Using HTML tag&lt;/h4&gt;
&lt;p class="graf graf--p graf-after--h4"&gt;If you want to convert the complete app into RTL layout, then use &lt;code class="markup--code markup--p-code"&gt;dir="rtl"&lt;/code&gt; on &lt;code class="markup--code markup--p-code"&gt;&amp;lt;html&amp;gt;&lt;/code&gt; tag itself. For Ionic 5 apps, the parent HTML is &lt;code class="markup--code markup--p-code"&gt;index.html&lt;/code&gt; in &lt;code class="markup--code markup--p-code"&gt;src&lt;/code&gt; folder&lt;/p&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--KoIhnqCJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AdX9FWTMFf2SiNEdBM3RgNw.png"&gt;&lt;br&gt;Global RTL setting on &amp;lt;html&amp;gt; tag&lt;h4 class="graf graf--h4 graf-after--figure"&gt;2. Using router-outlet or ion-app&lt;/h4&gt;
&lt;p class="graf graf--p graf-after--h4"&gt;Editing HTML tag with &lt;code class="markup--code markup--p-code"&gt;dir="rtl"&lt;/code&gt; is not a good solution if you want to change the layout dynamically from a setting inside the app.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;In such case, you can make use of &lt;code class="markup--code markup--p-code"&gt;ion-router-outlet&lt;/code&gt; or &lt;code class="markup--code markup--p-code"&gt;&amp;lt;ion-app&amp;gt;&lt;/code&gt; tag which is the parent of all the pages in Ionic 5 apps. Use &lt;code class="markup--code markup--p-code"&gt;dir="rtl"&lt;/code&gt; on &lt;code class="markup--code markup--p-code"&gt;&amp;lt;ion-router-outlet&amp;gt;&lt;/code&gt; or &lt;code class="markup--code markup--p-code"&gt;&amp;lt;ion-app&amp;gt;&lt;/code&gt;tag, and all the pages under that will get RTL layout&lt;/p&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--I6KdH6WW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2Aom9k12_nfNz9AhBa-HfrUA.png"&gt;&lt;br&gt;RTL implementation on ion-router-outlet&lt;p class="graf graf--p graf-after--figure"&gt;One thing to notice here - when you apply RTL on &lt;code class="markup--code markup--p-code"&gt;ion-router-outlet&lt;/code&gt; , the sidemenu behaves opposite to how it behaves with &lt;code class="markup--code markup--p-code"&gt;dir="rtl"&lt;/code&gt; on &lt;code class="markup--code markup--p-code"&gt;&amp;lt;html&lt;/code&gt; tag&lt;/p&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--_t3uvZzX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2Aj6LLe6yK2729rDCpIaaCsA.jpeg"&gt;&lt;p class="graf graf--p graf-after--figure"&gt;Notice in both cases, the Hamburger menu icon in header is on right, but the menu opens in different way for both implementations.&lt;/p&gt;
&lt;h4 class="graf graf--h4 graf-after--p"&gt;3. Using CSS at global level&lt;/h4&gt;
&lt;p class="graf graf--p graf-after--h4"&gt;You can also convert the complete app to RTL using CSS in &lt;code class="markup--code markup--p-code"&gt;global.scss&lt;/code&gt; &lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;:root {&lt;br&gt;direction: rtl;&lt;br&gt;}&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;This will apply RTL to all pages and components. Again, sidemenu in this implementation behaves a little different from Method 1&lt;/p&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--SaRTgVBc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2Ast1F4teHcq18aljYky3Utw.jpeg"&gt;&lt;p class="graf graf--p graf-after--figure"&gt;So RTL at root css level and &lt;code class="markup--code markup--p-code"&gt;dir="rtl"&lt;/code&gt; on &lt;code class="markup--code markup--p-code"&gt;&amp;lt;ion-app&amp;gt;&lt;/code&gt; tag have same effect.&lt;/p&gt;
&lt;h4 class="graf graf--h4 graf-after--p"&gt;4. Using CSS at Page level&lt;/h4&gt;
&lt;p class="graf graf--p graf-after--h4 graf--trailing"&gt;If you only want to convert a particular page to RTL, then you can make use of CSS at the page level. Just add &lt;code class="markup--code markup--p-code"&gt;direction: rtl;&lt;/code&gt; on a page level class, and you’ll get the page in RTL layout.&lt;/p&gt;

&lt;h3 class="graf graf--h3 graf--leading"&gt;Ionic 5 components in RTL (right-to-left) Layout&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;Now let’s take a good look at how different Ionic 5 components and pages look in RTL.&lt;/p&gt;
&lt;blockquote class="graf graf--blockquote graf-after--p"&gt;
&lt;strong class="markup--strong markup--blockquote-strong"&gt;All the layouts used below can be found in &lt;/strong&gt;&lt;a href="https://store.enappd.com/product/ionic-full-app/" class="markup--anchor markup--blockquote-anchor"&gt;&lt;strong class="markup--strong markup--blockquote-strong"&gt;Ionic 5 Full app starter&lt;/strong&gt;&lt;/a&gt;
&lt;/blockquote&gt;
&lt;h4 class="graf graf--h4 graf-after--blockquote"&gt;Instagram Layout — Ion-item ✅&lt;/h4&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--oxBP6EbO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2ApMW9MELbO3Z7124YgdQZvA.jpeg"&gt;&lt;h4 class="graf graf--h4 graf-after--figure"&gt;Whatsapp Layout — Header and Ion-item ✅&lt;/h4&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--EA2tTRcL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2Aq2CYVjtSVpifn82Cz6Zrzw.jpeg"&gt;&lt;h4 class="graf graf--h4 graf-after--figure"&gt;Youtube layout — Ion-item ✅&lt;/h4&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--aZoefmF9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AvQzgZMjiEj0J81DtdTvZXA.jpeg"&gt;&lt;h4 class="graf graf--h4 graf-after--figure"&gt;Horizontal Sliders ✅&lt;/h4&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--rIhBeBtJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AIk-HJBsldahXZf0_gyJv_A.gif"&gt;&lt;br&gt;Horizontal slider in LTR&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--mBeqQorU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2ALZQ5MFd5E8rIzXMkJmcfww.gif"&gt;&lt;br&gt;Horizontal slider in RTL&lt;h4 class="graf graf--h4 graf-after--figure"&gt;Segments ✅&lt;/h4&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--PpLFMrZR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AdupFGlbuMt5lvdJxjUj7mA.jpeg"&gt;&lt;h4 class="graf graf--h4 graf-after--figure"&gt;Ion-item ✅&lt;/h4&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--S4YHNKib--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AKaZtC6CafdXttfZSm0RhYw.jpeg"&gt;&lt;p class="graf graf--p graf-after--figure"&gt;Notice how both the left-side and right-side icons have shifted in RTL layout&lt;/p&gt;
&lt;h4 class="graf graf--h4 graf-after--p"&gt;Content-loaders (Skeleton text) ✅&lt;/h4&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--sXJx355L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AjJyDg8S4UDcxeVDWbmTZ8w.jpeg"&gt;&lt;p class="graf graf--p graf-after--figure"&gt;Skeleton text changes as per RTL layout as well.&lt;/p&gt;
&lt;h4 class="graf graf--h4 graf-after--p"&gt;Chat Layout 🤔&lt;/h4&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--gPTyJUU3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AaTFX0JUbKQvJmtqOUiSqmA.jpeg"&gt;&lt;p class="graf graf--p graf-after--figure"&gt;As you can see, the chat layout is an edge case for RTL. You really need to know if the users of your RTL language are habitual of seeing their text on the right or left. Accordingly, you’ll have to change the CSS of your chat layout&lt;/p&gt;
&lt;h4 class="graf graf--h4 graf-after--p"&gt;Date pickers 🤔&lt;/h4&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--miPC9zIE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AhNz3pjTG8eFUe5X8OIu5Vw.jpeg"&gt;&lt;p class="graf graf--p graf-after--figure"&gt;You can see most of the Date picker input fields adjusted as per RTL, but the floating type input couldn’t. Also the ticker shown for picking value does not change as per RTL.&lt;/p&gt;
&lt;h4 class="graf graf--h4 graf-after--p"&gt;Action sheet ✅&lt;/h4&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--W11TUd-v--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AlEktHW-vxCBuf2B6TpNt7Q.jpeg"&gt;&lt;h4 class="graf graf--h4 graf-after--figure"&gt;Alert and prompts ✅&lt;/h4&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--7gCWjtsD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2Afe2TQ0r5KaJon780c4797w.jpeg"&gt;&lt;h4 class="graf graf--h4 graf-after--figure"&gt;Range selectors ✅&lt;/h4&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--5zpLq5Zb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2A_-uEdreOSoIqpoLmr_Tu2g.jpeg"&gt;&lt;p class="graf graf--p graf-after--figure"&gt;Notice the minimum and maximum value of range selectors get swapped in RTL, and so is the movement of slider to increase value.&lt;/p&gt;
&lt;h4 class="graf graf--h4 graf-after--p"&gt;Grid layout&lt;/h4&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--vkIYTrxH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AM88wRtSNIB4PEkEb6euftA.jpeg"&gt;&lt;p class="graf graf--p graf-after--figure"&gt;These two almost look the same, but if you look closely, you’ll notice that the first product in the grid starts from the right in RTL layout.&lt;/p&gt;
&lt;h4 class="graf graf--h4 graf-after--p"&gt;Buttons ✅&lt;/h4&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--0ASU6HA5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AVT65q-V0doIUZbGwbyULpw.jpeg"&gt;&lt;p class="graf graf--p graf-after--figure"&gt;Notice how the button icons shift in RTL layout. The text centered in the button stays centered.&lt;/p&gt;
&lt;h4 class="graf graf--h4 graf-after--p"&gt;Filtering List ✅&lt;/h4&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--X9JumVRi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AOCk58mhezOcNBXpkhOUITg.jpeg"&gt;&lt;h3 class="graf graf--h3 graf-after--figure"&gt;Conclusion&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;We looked at various methods of implementation of RTL in Ionic 5. We also had a look at various layouts and how they look in RTL layout.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;This is not an exhaustive list of all Ionic components and what all combination are possible. But all these example give us an idea of how the app will look and behave if we use RTL layouts.&lt;/p&gt;
&lt;blockquote class="graf graf--blockquote graf-after--p graf--trailing"&gt;
&lt;strong class="markup--strong markup--blockquote-strong"&gt;All the layouts used in this blogpost can be found in &lt;/strong&gt;&lt;a href="https://store.enappd.com/product/ionic-4-full-app/" class="markup--anchor markup--blockquote-anchor" rel="noopener"&gt;&lt;strong class="markup--strong markup--blockquote-strong"&gt;Ionic 5 Full app starter&lt;/strong&gt;&lt;/a&gt;
&lt;/blockquote&gt;

&lt;h3 class="graf graf--h3 graf--leading"&gt;Next Steps&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;If you liked this blog, you will also find the following blogs interesting and helpful. Feel free to ask any questions in the comment section&lt;/p&gt;
&lt;ul class="postList"&gt;
&lt;li class="graf graf--li graf-after--p"&gt;Ionic Payment Gateways — &lt;a href="https://enappd.com/blog/ionic-4-stripe-payment-integration-with-firebase-for-apps-and-pwa/17" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;Stripe&lt;/a&gt; | &lt;a href="https://enappd.com/blog/ionic-4-paypal-payment-integration-for-apps-and-pwa/16" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;PayPal&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-integrate-apple-pay-in-ionic-4-apps/21" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;Apple Pay&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-integrate-razorpay-in-ionic-4-apps-and-pwa/20" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;RazorPay&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Ionic Charts with — &lt;a href="https://enappd.com/blog/ionic-4-charts-using-google-charts/66" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;Google Charts &lt;/a&gt;| &lt;a href="https://enappd.com/blog/adding-charts-in-ionic-4-apps-and-pwa-part-3/60" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;HighCharts&lt;/a&gt; | &lt;a href="https://enappd.com/blog/adding-charts-in-ionic-4-apps-and-pwa-part-2/54" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;d3.js&lt;/a&gt; | &lt;a href="https://enappd.com/blog/charts-in-ionic-4-apps-and-pwa-part-1/52" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;Chart.js&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Ionic Social Logins — &lt;a href="https://enappd.com/blog/facebook-login-in-ionic-4-apps-using-firebase/25" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;Facebook&lt;/a&gt; | &lt;a href="https://enappd.com/blog/google-login-in-ionic-4-apps-using-firebase/39" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;Google&lt;/a&gt; | &lt;a href="https://enappd.com/blog/twitter-login-in-ionic-4-apps-using-firebase/24" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;Twitter&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Ionic Authentications — &lt;a href="https://enappd.com/blog/email-authentication-with-firebase-in-ionic-4/38" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;Via Email&lt;/a&gt; | &lt;a href="https://enappd.com/blog/firebase-anonymous-login-in-ionic-4/37" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;Anonymous&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Ionic Features — &lt;a href="https://enappd.com/blog/using-geolocation-geocoding-and-reverse-geocoding-in-ionic-4/45" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;Geolocation&lt;/a&gt; | &lt;a href="https://enappd.com/blog/qr-code-scanning-and-optical-character-recognition-ocr-in-ionic-4/9" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;QR Code reader &lt;/a&gt;| &lt;a href="https://enappd.com/blog/best-fitness-plugins-for-ionic-4-how-to-use-pedometer/15" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;Pedometer&lt;/a&gt;| &lt;a href="https://enappd.com/blog/implement-signature-pad-in-ionic-apps/145/" class="markup--anchor markup--li-anchor" rel="noopener"&gt;Signature Pad&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Media in Ionic — &lt;a href="https://enappd.com/blog/spotify-like-music-in-ionic-4-apps/48" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;Audio&lt;/a&gt; | &lt;a href="https://enappd.com/blog/adding-video-player-in-ionic-4-app/64" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;Video&lt;/a&gt; | &lt;a href="https://enappd.com/blog/image-picker-in-ionic-4-app/67" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;Image Picker&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-add-image-cropper-in-ionic-4-app/68" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;Image Cropper&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Ionic Essentials — &lt;a href="https://enappd.com/blog/ionic-4-save-and-retrieve-data-locally-on-device/59" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;Native Storage&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-translate-in-ionic-4-globalization-internationalization-and-localization/11" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;Translations&lt;/a&gt; | &lt;a href="https://enappd.com/blog/rtl-right-to-left-use-in-ionic-4/50" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;RTL&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Ionic messaging — &lt;a href="https://enappd.com/blog/implement-ionic-4-firebase-push/34" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;Firebase Push&lt;/a&gt; | &lt;a href="https://enappd.com/blog/automatically-read-sms-in-ionic-4-apps/42" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;Reading SMS&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li graf--trailing"&gt;Ionic with Firebase — &lt;a href="https://enappd.com/blog/how-to-integrate-firebase-in-ionic-4-apps/23" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;Basics&lt;/a&gt; | &lt;a href="https://enappd.com/blog/firebase-with-ionic-4-hosting-auth-and-db-connection/58" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;Hosting and DB&lt;/a&gt; | &lt;a href="https://enappd.com/blog/firebase-cloud-functions-in-ionic-4-complete-guide/32" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener"&gt;Cloud functions&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 class="graf graf--h3 graf--leading"&gt;Ionic React Full App with Capacitor&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;If you need a base to start your next Ionic 5 React Capacitor app, you can make your next awesome app using &lt;a href="https://store.enappd.com/product/ionic-react-full-app-capacitor/" class="markup--anchor markup--p-anchor" rel="noopener"&gt;Ionic 5 React Full App in Capacitor&lt;/a&gt;&lt;/p&gt;
&lt;img class="graf-image" alt="Ionic 5 React Full App in Capacitor from Enappd" src="https://res.cloudinary.com/practicaldev/image/fetch/s--Z0sRDsyI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AG3yOFVX4oABx9MhUy-3kng.png"&gt;&lt;br&gt;Ionic 5 React Full App in Capacitor from Enappd&lt;h3 class="graf graf--h3 graf-after--figure"&gt;Ionic Capacitor Full App (Angular)&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;If you need a base to start your next Angular &lt;strong class="markup--strong markup--p-strong"&gt;Capacitor app&lt;/strong&gt;, you can make your next awesome app using &lt;a href="https://store.enappd.com/product/capacitor-full-app-with-ionic-angular/" class="markup--anchor markup--p-anchor" rel="noopener nofollow noopener noopener"&gt;Capacitor Full App&lt;/a&gt;&lt;/p&gt;
&lt;img class="graf-image" alt="Capacitor Full App with huge number of layouts and features" src="https://res.cloudinary.com/practicaldev/image/fetch/s--jbZt2zIJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/0%2AUwSHcofTMStMnzAX.png"&gt;&lt;br&gt;Capacitor Full App with huge number of layouts and features&lt;h3 class="graf graf--h3 graf-after--figure"&gt;Ionic Full App (Angular and Cordova)&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;If you need a base to start your next Ionic 5 app, you can make your next awesome app using &lt;a href="https://store.enappd.com/product/ionic-full-app" class="markup--anchor markup--p-anchor" rel="noopener"&gt;Ionic 5 Full App&lt;/a&gt;&lt;/p&gt;
&lt;img class="graf-image" alt="Ionic Full App with huge number of layouts and features" src="https://res.cloudinary.com/practicaldev/image/fetch/s--V1pEO0Mo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/0%2A1ArpKyhiDHZnevwB.jpeg"&gt;&lt;br&gt;Ionic Full App in Cordova, with huge number of layouts and features


</description>
      <category>angular</category>
      <category>ionic</category>
      <category>rtl</category>
      <category>righttoleft</category>
    </item>
    <item>
      <title>PayPal payment integration in Ionic 5 Apps and PWA</title>
      <dc:creator>Abhijeet Rathore</dc:creator>
      <pubDate>Fri, 31 Jul 2020 18:39:36 +0000</pubDate>
      <link>https://forem.com/enappd/paypal-payment-integration-in-ionic-5-apps-and-pwa-2l39</link>
      <guid>https://forem.com/enappd/paypal-payment-integration-in-ionic-5-apps-and-pwa-2l39</guid>
      <description>
&lt;p class="graf graf--p graf-after--figure"&gt;In this post, you’ll learn to integrate PayPal payment in Ionic 5 apps and PWA, so you can accept payment both on mobile and desktop devices.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;PayPal is one of the most widely used and easiest payment gateway to integrate in your website or app. Plus it is spread all over the globe, and supports a wide variety of payment options. PayPal can take care of almost all your payment requirements, so you don’t have to go all&lt;/p&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--Y01XsYsg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AgvTQzWX-AEqL-Ut46v3ILw.gif"&gt;&lt;br&gt;Not a great way of making payments 😝&lt;h3 class="graf graf--h3 graf-after--figure"&gt;What is Ionic ?&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;You probably already know about Ionic, but I’m putting it here just for the sake of beginners. &lt;strong class="markup--strong markup--p-strong"&gt;Ionic&lt;/strong&gt; is a hybrid mobile app development SDK. It provides tools and services for developing hybrid mobile apps using Web technologies like CSS, HTML5, and Sass. Apps can be built with these Web technologies and then distributed through native app stores to be installed on devices by leveraging &lt;a href="https://cordova.apache.org/" class="markup--anchor markup--p-anchor" rel="noopener nofollow"&gt;Cordova&lt;/a&gt; or Capacitor environment.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;So, in other words — If you create Native apps in Android, you code in Java. If you create Native apps in iOS, you code in Obj-C or Swift. Both of these are powerful but complex languages. &lt;strong class="markup--strong markup--p-strong"&gt;With Ionic you can write a single piece of code for your app that can run on both iOS and Android &lt;/strong&gt;and web (as PWA), that too with the simplicity of HTML, CSS, and JS.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;It is important to note the contribution of Cordova/Capacitor in this. Ionic is only a UI wrapper made up of HTML, CSS and JS. So, by default, Ionic cannot run as an app in an iOS or Android device. Cordova/Capacitor is the build environment that containerizes (sort of) this Ionic web app and converts it into a device installable app, along with providing this app access to native APIs like Camera etc.&lt;/p&gt;
&lt;h3 class="graf graf--h3 graf-after--p"&gt;Ionic and Payment Gateways &lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;Ionic can create a wide variety of apps, and hence a wide variety of payment gateways can be implemented in Ionic apps. The popular ones are PayPal, Stripe, Braintree, in-app purchase etc. For more details on payment gateways, you can read my blog on &lt;a href="https://medium.com/enappd/payment-solutions-in-ionic-8c4bb28ce5cc" class="markup--anchor markup--p-anchor"&gt;Payment Gateway Solutions in Ionic.&lt;/a&gt;&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;Also, there are different types of Ionic Apps you can build for same functionality. Most popular ones are :&lt;/p&gt;
&lt;ul class="postList"&gt;
&lt;li class="graf graf--li graf-after--p"&gt;&lt;strong class="markup--strong markup--li-strong"&gt;Front-end: Angular | Build environment : Cordova ✅&lt;/strong&gt;&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Front-end: Angular | Build environment : Capacitor&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Front-end: React | Build environment : Capacitor&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;&lt;strong class="markup--strong markup--li-strong"&gt;Front-end: React/Angular | as PWA ✅&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p class="graf graf--p graf-after--li"&gt;As you see, PayPal can be integrated in websites as well as mobile apps. In this blog we’ll learn &lt;strong class="markup--strong markup--p-strong"&gt;how to integrate PayPal payment gateway in Ionic 5 apps and Ionic 5 PWA.&lt;/strong&gt;&lt;/p&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--t4xAzFvg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2At5-AzGmKvmvvGGlUpFrxuQ.jpeg"&gt;&lt;br&gt;Ionic 4 and PayPal make a great team&lt;h3 class="graf graf--h3 graf-after--figure"&gt;Structure of post&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;In this post we will learn how to implement Paypal payments for an Ionic 5 PWA and mobile app. We can break down the post in these steps:&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;&lt;strong class="markup--strong markup--p-strong"&gt;Step 1&lt;/strong&gt;— Create a PayPal developer account and configure it for integration&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;&lt;strong class="markup--strong markup--p-strong"&gt;Step 2&lt;/strong&gt;— Creating a basic Ionic 5 Angular app&lt;/p&gt;
&lt;h4 class="graf graf--h4 graf-after--p"&gt;PWA integration&lt;/h4&gt;
&lt;p class="graf graf--p graf-after--h4"&gt;&lt;strong class="markup--strong markup--p-strong"&gt;Step 3&lt;/strong&gt; —Configure PayPal web integration&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;&lt;strong class="markup--strong markup--p-strong"&gt;Step 4&lt;/strong&gt; — Run the PWA on &lt;code class="markup--code markup--p-code"&gt;ionic serve&lt;/code&gt; to test web payments&lt;/p&gt;
&lt;h4 class="graf graf--h4 graf-after--p"&gt;App integration&lt;/h4&gt;
&lt;p class="graf graf--p graf-after--h4"&gt;&lt;strong class="markup--strong markup--p-strong"&gt;Step 5&lt;/strong&gt; — Integrate Ionic Native plugin for PayPal &lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;&lt;strong class="markup--strong markup--p-strong"&gt;Step 6&lt;/strong&gt; — Build the app on android to test app payments.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;&lt;strong class="markup--strong markup--p-strong"&gt;Step 7&lt;/strong&gt; — Going Live&lt;/p&gt;
&lt;h3 class="graf graf--h3 graf-after--p"&gt;Step 1 — Create PayPal developer account and configure it for integration&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;To configure PayPal payments in your Ionic app or PWA, you need to create a business PayPal account. But for testing purposes, you have to use the Sandbox test accounts. Sandbox testing will look exactly like live payments, but it won’t deduct any money from your account or Credit Card.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;To obtain your Sandbox credentials follow the steps below:&lt;/p&gt;
&lt;ul class="postList"&gt;
&lt;li class="graf graf--li graf-after--p"&gt;Go to &lt;a href="https://developer.paypal.com/developer/accounts/" class="markup--anchor markup--li-anchor" rel="nofollow noopener noopener noopener"&gt;Sandbox - Accounts&lt;/a&gt; and create a sandbox business and personal test accounts.&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Go to &lt;a href="https://developer.paypal.com/developer/applications/" class="markup--anchor markup--li-anchor" rel="nofollow noopener noopener noopener"&gt;My Apps &amp;amp; Credentials&lt;/a&gt; and generate a REST API app, and link it to your sandbox test business account (by default you have a business and personal  sandbox account in developer dashboard).When your app’s PayPal SDK is running in Sandbox mode, you cannot make payments with an “actual” PayPal account, you need a Sandbox account. So, the personal sandbox account “pays” and business sandbox account “receives” the money.&lt;/li&gt;
&lt;/ul&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--iNFyAIdl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2Alj9qsgc9527h8UFIcw7xiQ.png"&gt;&lt;br&gt;Create new app in PayPal account&lt;p class="graf graf--p graf-after--figure"&gt;Also note down your&lt;strong class="markup--strong markup--p-strong"&gt; Client ID &lt;/strong&gt;from the app details. This is mostly what you need to integrate PayPal in your app / PWA and test payments.&lt;/p&gt;
&lt;img class="graf-image" alt="Obtain Client ID from PayPal sandbox" src="https://res.cloudinary.com/practicaldev/image/fetch/s--b6bqyvVl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2ACCfWlSCrmZsnp0o_ortzkw.png"&gt;&lt;br&gt;Obtain Client ID from PayPal sandbox&lt;h4 class="graf graf--h4 graf-after--figure"&gt;Country specific gotchas&lt;/h4&gt;
&lt;ul class="postList"&gt;
&lt;li class="graf graf--li graf-after--h4"&gt;Being a payment gateway, PayPal has to respect different countries rules. E.g. In India, PayPal users can only pay and receive payments done from India in INR. So if you are testing from India, and your Sandbox accounts are created with &lt;strong class="markup--strong markup--li-strong"&gt;India&lt;/strong&gt; as country, you’ll have to make payments in INR. Similar restrictions may exist for other countries.&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Sandbox payment credit cards are also currency sensitive. If you are facing issue making payments with the default sandbox credit card, generate a new one using &lt;strong class="markup--strong markup--li-strong"&gt;Credit Card Generator &lt;/strong&gt;from the left menu. Make sure you keep the country same as the sandbox account. Add this card with the &lt;code class="markup--code markup--li-code"&gt;Add new card&lt;/code&gt; option when you are making a sandbox payment&lt;/li&gt;
&lt;/ul&gt;
&lt;img class="graf-image" alt="Generate a new sandbox credit card for PayPal payments" src="https://res.cloudinary.com/practicaldev/image/fetch/s--cbfBdb0I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AI2iuVFLbDYXMtJVvH_DVYg.png"&gt;&lt;br&gt;Generate a new sandbox credit card for PayPal payments&lt;h3 class="graf graf--h3 graf-after--figure"&gt;Step 2— Create a basic Ionic Angular app&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;First you need to make sure you have the latest Ionic CLI. This will ensure you are using everything latest. Ensure latest Ionic CLI installation using&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;$ npm install -g ionic@latest&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;(My node version at the time of writing the blog is 12.14.0)&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;Creating a basic Ionic-Angular app. Start a basic &lt;code class="markup--code markup--p-code"&gt;blank&lt;/code&gt; starter using&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;$ ionic start PayPalIonic sidemenu --type=angular --cordova&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;The &lt;code class="markup--code markup--p-code"&gt;--type=angular&lt;/code&gt; told the CLI to create an &lt;strong class="markup--strong markup--p-strong"&gt;Angular&lt;/strong&gt; app, not a &lt;strong class="markup--strong markup--p-strong"&gt;React&lt;/strong&gt; app !!&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;Run the app in browser using &lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;$ ionic serve&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;You won’t see much in the homepage created in the starter. I have modified the homepage a little to test our PayPal functionality — basically you can do away with just a button for PayPal payments. &lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;My homepage looks like this&lt;/p&gt;
&lt;img class="graf-image" alt="HomePage UI for PayPal PWA implementation" src="https://res.cloudinary.com/practicaldev/image/fetch/s--BAW7aCJ_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AV0UNg6_It1ij2HFi8g4wuA.png"&gt;&lt;br&gt;HomePage UI for PayPal PWA implementation&lt;p class="graf graf--p graf-after--figure"&gt;Overall &lt;code class="markup--code markup--p-code"&gt;PayPal-web.page.html&lt;/code&gt; code looks like this&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;

&lt;h3 class="graf graf--h3 graf--leading"&gt;
&lt;strong class="markup--strong markup--h3-strong"&gt;Step 3&lt;/strong&gt; — Configure PayPal web integration&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;We can’t use the PayPal Cordova plugin in an Ionic Progressive Web App (PWA). But we can use the PayPal front-end Javascript SDK in such case.&lt;/p&gt;
&lt;blockquote class="graf graf--blockquote graf-after--p"&gt;
&lt;strong class="markup--strong markup--blockquote-strong"&gt;Warning&lt;/strong&gt; : In websites or PWA, it is recommended to use payment gateway functions in back-end, because front-end implementation can reveal your client-ID, secret etc&lt;/blockquote&gt;
&lt;h4 class="graf graf--h4 graf-after--blockquote"&gt;Add PayPal Javascript SDK to index.html&lt;/h4&gt;
&lt;p class="graf graf--p graf-after--h4"&gt;For website/PWA front-end implementation, PayPal provides &lt;strong class="markup--strong markup--p-strong"&gt;Payment Buttons &lt;/strong&gt;(the yellow button in the above image)&lt;strong class="markup--strong markup--p-strong"&gt;. &lt;/strong&gt;These are pre-configured PayPal buttons + functions, attached to a JS file we import in our PWA’s &lt;code class="markup--code markup--p-code"&gt;index.html&lt;/code&gt; as :&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;&amp;lt;script src="&lt;a href="https://www.paypal.com/sdk/js?client-id=YOUR_CLIENT_ID&amp;amp;currency=USD%22&amp;gt;&amp;lt;/script"&gt;https://www.paypal.com/sdk/js?client-id=YOUR_CLIENT_ID&amp;amp;amp;currency=USD"&amp;amp;gt;&amp;amp;lt;/script&lt;/a&gt;&amp;gt;&lt;/pre&gt;
&lt;blockquote class="graf graf--blockquote graf-after--pre"&gt;
&lt;strong class="markup--strong markup--blockquote-strong"&gt;Replace &lt;/strong&gt;&lt;code class="markup--code markup--blockquote-code"&gt;&lt;strong class="markup--strong markup--blockquote-strong"&gt;YOUR_CLIENT_ID&lt;/strong&gt;&lt;/code&gt;&lt;strong class="markup--strong markup--blockquote-strong"&gt; in above script call with your own client ID, and change the currency as per your sandbox/live account currency. Client ID is what attaches the Payment with your PayPal REST API app, so do not get it wrong.&lt;/strong&gt;
&lt;/blockquote&gt;
&lt;h4 class="graf graf--h4 graf-after--blockquote"&gt;SDK Parameters&lt;/h4&gt;
&lt;p class="graf graf--p graf-after--h4"&gt;PayPal JavaScript SDK uses default values for parameters you don’t pass in the imported script. You might want to override these default values depending on your functionality. A few common parameters you might override:&lt;/p&gt;
&lt;ul class="postList"&gt;
&lt;li class="graf graf--li graf-after--p"&gt;
&lt;code class="markup--code markup--li-code"&gt;currency&lt;/code&gt; - The PayPal JavaScript SDK defaults to &lt;code class="markup--code markup--li-code"&gt;USD&lt;/code&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;
&lt;code class="markup--code markup--li-code"&gt;intent&lt;/code&gt; - The PayPal JavaScript SDK defaults to &lt;code class="markup--code markup--li-code"&gt;capture&lt;/code&gt;, which results in the capturing the funds immediately. If you want to authorize funds immediately but capture the funds later, you have to explicitly pass &lt;code class="markup--code markup--li-code"&gt;authorize&lt;/code&gt; as the intent for the transaction&lt;/li&gt;
&lt;/ul&gt;
&lt;p class="graf graf--p graf-after--li"&gt;Now, PayPal official documentation tells you to code the remaining part of the logic in index.html itself. But the default implementation is good for two reasons&lt;/p&gt;
&lt;ul class="postList"&gt;
&lt;li class="graf graf--li graf-after--p"&gt;Ionic app takes time to compile and load in the webview environment, so the render function cannot find the button container&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;We need to pass variables like amount, currency etc to the functions. So it makes more sense to keep the functions inside the page.ts file of PWA&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 class="graf graf--h4 graf-after--li"&gt;Render Payment Buttons&lt;/h4&gt;
&lt;p class="graf graf--p graf-after--h4"&gt;In the HTML template, we replace the &lt;code class="markup--code markup--p-code"&gt;ion-button&lt;/code&gt; with&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;&amp;lt;div id="paypal-button-container"&amp;gt;&amp;lt;/div&amp;gt;&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;This &lt;code class="markup--code markup--p-code"&gt;id&lt;/code&gt; is used to identify the button, and attached correct render and payment functions to the button.&lt;/p&gt;
&lt;h4 class="graf graf--h4 graf-after--p"&gt;Payment Functions&lt;/h4&gt;
&lt;p class="graf graf--p graf-after--h4"&gt;&lt;strong class="markup--strong markup--p-strong"&gt;createOrder — &lt;/strong&gt;This function is called when the buyer clicks the PayPal button. This button &lt;/p&gt;
&lt;ul class="postList"&gt;
&lt;li class="graf graf--li graf-after--p"&gt;Calls PayPal using &lt;code class="markup--code markup--li-code"&gt;actions.order.create()&lt;/code&gt; to set up the details of a one-time transaction, including the amount, line item details, and more&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Launches the PayPal Checkout window so the buyer can log in and approve the transaction on paypal.com&lt;/li&gt;
&lt;/ul&gt;
&lt;p class="graf graf--p graf-after--li"&gt;&lt;strong class="markup--strong markup--p-strong"&gt;onApprove — &lt;/strong&gt;This function is called after the buyer approves the transaction on paypal.com. This function:&lt;/p&gt;
&lt;ul class="postList"&gt;
&lt;li class="graf graf--li graf-after--p"&gt;Calls PayPal using &lt;code class="markup--code markup--li-code"&gt;actions.order.capture()&lt;/code&gt; to capture the funds from the transaction.&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Shows a message to the buyer to let them know the transaction is successful.&lt;/li&gt;
&lt;/ul&gt;
&lt;p class="graf graf--p graf-after--li"&gt;&lt;code class="markup--code markup--p-code"&gt;onApprove&lt;/code&gt; function carries out the success or error part after a transaction. Here, you can call your server with a REST API and save a successful payment in your database.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;Here’s the full code of &lt;code class="markup--code markup--p-code"&gt;PayPal-web.page.ts&lt;/code&gt; &lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;p class="graf graf--p graf-after--figure"&gt;You can also try different styles of payment buttons at &lt;a href="https://developer.paypal.com/demo/checkout/#/pattern/client" class="markup--anchor markup--p-anchor" rel="noopener"&gt;PayPal Payment Button demo page&lt;/a&gt;&lt;/p&gt;
&lt;h3 class="graf graf--h3 graf-after--p"&gt;
&lt;strong class="markup--strong markup--h3-strong"&gt;Step 4&lt;/strong&gt; — Test payments in PWA&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;Run the PWA on browser using &lt;code class="markup--code markup--p-code"&gt;ionic serve&lt;/code&gt; &lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;When you click on the Payment Button, PayPal script automatically pops-up a modal with required functionality. Remember, this PayPal popup is attached to your &lt;strong class="markup--strong markup--p-strong"&gt;PayPal REST API app, &lt;/strong&gt;based on the Client ID you provided.&lt;/p&gt;
&lt;img class="graf-image" alt="PayPal web script launches modal for login and payment" src="https://res.cloudinary.com/practicaldev/image/fetch/s--891qDAGB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AVMXDaRXht_t-zf0GmbsHJA.png"&gt;&lt;br&gt;PayPal web script launches modal for login and payment&lt;p class="graf graf--p graf-after--figure"&gt;Login with your &lt;strong class="markup--strong markup--p-strong"&gt;Sandbox account&lt;/strong&gt;, and you’ll see payment options just like a normal PayPal transaction. Add a new credit card as I mentioned in Step 1, if you are getting an error saying &lt;code class="markup--code markup--p-code"&gt;Your bank was not able to verify your card&lt;/code&gt; . This is generally a mismatch in currency of the app, sandbox account or the credit card. &lt;/p&gt;
&lt;blockquote class="graf graf--blockquote graf-after--p"&gt;Remember, you cannot login with a non-sandbox PayPal account for testing&lt;/blockquote&gt;
&lt;img class="graf-image" alt="Payment options in your sandbox account — PayPal web implementation" src="https://res.cloudinary.com/practicaldev/image/fetch/s--ok5Dse74--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2ARhbD0DS-C3-ve5tfR-1NOA.png"&gt;&lt;br&gt;Payment options in your sandbox account — PayPal web implementation&lt;p class="graf graf--p graf-after--figure"&gt;Select the appropriate method, and your payment is done. &lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;Sometimes, there will be an additional verification step involved, imitating a 3D secure password for real transaction. As you can see, being a Sandbox transaction, the password is mentioned as the &lt;strong class="markup--strong markup--p-strong"&gt;Personal message. &lt;/strong&gt;&lt;/p&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--gpaWcLB1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2Ad_U_-iT23pSS4cObdgSjNA.png"&gt;&lt;br&gt;Additional verification step&lt;p class="graf graf--p graf-after--figure"&gt;Once the payment is done, the response object will look like this&lt;/p&gt;
&lt;img class="graf-image" alt="Response from PayPal web payments" src="https://res.cloudinary.com/practicaldev/image/fetch/s--T8i1S9-_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2ADBYA0ga0G-qeNw7HqKNC8g.png"&gt;&lt;br&gt;Response from PayPal web payments&lt;p class="graf graf--p graf-after--figure graf--trailing"&gt;You can easily use the response to determine if the payment was successful.&lt;/p&gt;

&lt;h3 class="graf graf--h3 graf--leading"&gt;
&lt;strong class="markup--strong markup--h3-strong"&gt;Step 5&lt;/strong&gt; — Integrate Ionic Native plugin for PayPal&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;To implement PayPal payment in Ionic Mobile apps, install PayPal Cordova plugin first&lt;/p&gt;
&lt;br&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ionic cordova plugin add com.paypal.cordova.mobilesdk
$ npm install @ionic-native/paypal
&lt;/code&gt;&lt;/pre&gt;

&lt;h4 class="graf graf--h4 graf-after--pre"&gt;Import PayPal in app.module&lt;/h4&gt;
&lt;p class="graf graf--p graf-after--h4"&gt;Import and include &lt;code class="markup--code markup--p-code"&gt;PayPal&lt;/code&gt; in the list of &lt;code class="markup--code markup--p-code"&gt;providers&lt;/code&gt; in your &lt;code class="markup--code markup--p-code"&gt;app.module.ts&lt;/code&gt; file.&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;import { PayPal } from '@ionic-native/paypal/ngx';&lt;/pre&gt;
&lt;img class="graf-image" alt="Import PayPal in app.module.ts" src="https://res.cloudinary.com/practicaldev/image/fetch/s---N1wat2a--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AGN6VMlC_k2-pRxwuU6rgsQ.png"&gt;&lt;br&gt;Import PayPal in app.module.ts&lt;h4 class="graf graf--h4 graf-after--figure"&gt;Import PayPal in your page&lt;/h4&gt;
&lt;p class="graf graf--p graf-after--h4"&gt;Create a separate folder for PayPal app implementation. &lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;$ ionic generate page paypal-mobile&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;Import &lt;code class="markup--code markup--p-code"&gt;PayPal&lt;/code&gt; in your &lt;code class="markup--code markup--p-code"&gt;paypal-mobile.page.ts&lt;/code&gt; same as &lt;code class="markup--code markup--p-code"&gt;app.module.ts&lt;/code&gt; &lt;/p&gt;
&lt;br&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { PayPal, PayPalPayment, PayPalConfiguration } from '@ionic-native/paypal/ngx';
....
export class PaypalPage {constructor(private payPal: PayPal) { }
&lt;/code&gt;&lt;/pre&gt;



&lt;p class="graf graf--p graf-after--pre"&gt;Modify the page’s UI a little to match the phone payment functionality&lt;/p&gt;
&lt;img class="graf-image" alt="HomePage UI for PayPal App implementation" src="https://res.cloudinary.com/practicaldev/image/fetch/s--jv8-76I6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2ApNc2w3CdW1mfXlnFi09uFA.png"&gt;&lt;br&gt;HomePage UI for PayPal App implementation&lt;p class="graf graf--p graf-after--figure"&gt;Here’s the &lt;code class="markup--code markup--p-code"&gt;paypal-mobile.page.html&lt;/code&gt; code, in case you need&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;h4 class="graf graf--h4 graf-after--figure"&gt;PayPal payment function&lt;/h4&gt;
&lt;p class="graf graf--p graf-after--h4"&gt;Invoke the payment function to initiate a payment. As mentioned earlier, You will require your &lt;code class="markup--code markup--p-code"&gt;client_id&lt;/code&gt; from your PayPal account. (&lt;a href="https://developer.paypal.com/docs/integration/direct/webhooks/my-apps-and-credentials/" class="markup--anchor markup--p-anchor" rel="noopener nofollow noopener noopener"&gt;How to get my credentials from PayPal account&lt;/a&gt;). This function will be attached to &lt;strong class="markup--strong markup--p-strong"&gt;Pay with PayPal&lt;/strong&gt; button we saw earlier in the app screenshot.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;Here’s the complete code for PayPal mobile app implementation&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;p class="graf graf--p graf-after--figure"&gt;In the &lt;code class="markup--code markup--p-code"&gt;payWithPaypal()&lt;/code&gt; function, you start by initializing the &lt;code class="markup--code markup--p-code"&gt;PayPal&lt;/code&gt; object with the PayPal environment (Sandbox or Production) to prepare the device for processing payments. Βy calling the &lt;code class="markup--code markup--p-code"&gt;prepareToRender()&lt;/code&gt; method you pass the environment we set earlier. Finally, you render the PayPal UI to collect the payment from the user by calling the &lt;code class="markup--code markup--p-code"&gt;renderSinglePaymentUI() &lt;/code&gt;method.&lt;/p&gt;
&lt;blockquote class="graf graf--blockquote graf-after--p"&gt;Notice the &lt;code class="markup--code markup--blockquote-code"&gt;PayPalEnvironmentSandbox&lt;/code&gt; parameter. This is used for Sandbox environment. For production environment, it will change to &lt;code class="markup--code markup--blockquote-code"&gt;PayPalEnvironmentProduction&lt;/code&gt; . Of course, do not forget to replace &lt;code class="markup--code markup--blockquote-code"&gt;YOUR_SANDBOX_CLIENT_ID&lt;/code&gt; with your Sandbox Client ID .&lt;/blockquote&gt;
&lt;p class="graf graf--p graf-after--blockquote"&gt;Also notice, for the sake of a sample, we have taken &lt;code class="markup--code markup--p-code"&gt;PaymentAmount&lt;/code&gt; and&lt;code class="markup--code markup--p-code"&gt;currency&lt;/code&gt; as static in the logic, but these can be easily dynamic as per your app’s requirement.&lt;/p&gt;
&lt;img class="graf-image" alt="Static amount and currency for sample purpose" src="https://res.cloudinary.com/practicaldev/image/fetch/s--0jLFeOGA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2ATsKZg2K2TGWtEVW-z6o9aQ.png"&gt;&lt;br&gt;Static amount and currency for sample purpose&lt;p class="graf graf--p graf-after--figure"&gt;Once payment is done, PayPal SDK will return a response. A sample sandbox response is shown in the gist above. One can use this response to show appropriate &lt;em class="markup--em markup--p-em"&gt;Toast&lt;/em&gt; or &lt;em class="markup--em markup--p-em"&gt;Alert&lt;/em&gt; to app users.&lt;/p&gt;
&lt;h3 class="graf graf--h3 graf-after--p"&gt;
&lt;strong class="markup--strong markup--h3-strong"&gt;Step 6&lt;/strong&gt; — Build the app on android to test app payments&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;To build the app on android, run the following commands one after another&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;$ ionic cordova platform add android&lt;/pre&gt;
&lt;pre class="graf graf--pre graf-after--pre"&gt;$ ionic cordova run android&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre is-selected"&gt;The final command will run the app on either default emulator, or an android device attached to your system. Once you click the &lt;strong class="markup--strong markup--p-strong"&gt;Pay with PayPal &lt;/strong&gt;button, you will see the PayPal payment screens&lt;/p&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--YzJOwvqd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2A7Os74byq1BO00-oaFH-uZQ.png"&gt;&lt;br&gt;PayPal payment options screen&lt;p class="graf graf--p graf-after--figure"&gt;You can choose to&lt;/p&gt;
&lt;ul class="postList"&gt;
&lt;li class="graf graf--li graf-after--p"&gt;
&lt;strong class="markup--strong markup--li-strong"&gt;Pay with PayPal&lt;/strong&gt; — using your PayPal account, OR&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;
&lt;strong class="markup--strong markup--li-strong"&gt;Pay with Card &lt;/strong&gt;— This will use your’s device’s camera to help read your credit card (to avoid typing your card number, expiry date etc)&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 class="graf graf--h4 graf-after--li"&gt;&lt;strong class="markup--strong markup--h4-strong"&gt;1. Pay with PayPal&lt;/strong&gt;&lt;/h4&gt;
&lt;p class="graf graf--p graf-after--h4"&gt;You will need to login to your &lt;strong class="markup--strong markup--p-strong"&gt;Sandbox Account&lt;/strong&gt; to make a payment (because, remember, you are in a sandbox environment)&lt;/p&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--Mz5JxCYh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AWllDJZsf95kMiCfBgARh5Q.png"&gt;&lt;br&gt;Sign in to your sandbox account to make test payments&lt;p class="graf graf--p graf-after--figure"&gt;Once you are logged in, you’ll see the checkout options&lt;/p&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--38C4il-P--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AFFUXz7ublrQatM8pnMqK7g.png"&gt;&lt;br&gt;Payment options in your sandbox account&lt;p class="graf graf--p graf-after--figure"&gt;Select one option, and pay for the dummy amount.&lt;/p&gt;
&lt;h4 class="graf graf--h4 graf-after--p"&gt;2. &lt;strong class="markup--strong markup--h4-strong"&gt;Pay with Card&lt;/strong&gt;
&lt;/h4&gt;
&lt;p class="graf graf--p graf-after--h4"&gt;In this case, your apps’ camera will open up to scan your card.&lt;/p&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--NLCD37LS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2A0igYsuKFhlk32HbKMdLLOA.png"&gt;&lt;br&gt;Scan your card&lt;p class="graf graf--p graf-after--figure"&gt;Once it is done scanning, it will confirm the card number, expiry date and ask for your CVV details etc. Lastly, it’ll show you a confirmation screen, and you proceed to pay the amount.&lt;/p&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--rAsoPkP2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AKDX1FlYyeg5kjqmmc5lVNQ.png"&gt;&lt;br&gt;Confirm payment with PayPal card payment&lt;p class="graf graf--p graf-after--figure"&gt;In both payment cases, you should receive a successful payment response like the following&lt;/p&gt;
&lt;img class="graf-image" alt="Successful payment response on Chrome console" src="https://res.cloudinary.com/practicaldev/image/fetch/s--52r6BIDg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2ABQhDMK64bc2K5wOfl6xbFA.png"&gt;&lt;br&gt;Successful payment response on Chrome console&lt;p class="graf graf--p graf-after--figure"&gt;This completes the Mobile app part of PayPal payment.&lt;/p&gt;
&lt;h3 class="graf graf--h3 graf-after--p"&gt;Going Live&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;After testing on app and PWA, when you want to go live, you will need to perform following steps&lt;/p&gt;
&lt;ul class="postList"&gt;&lt;li class="graf graf--li graf-after--p"&gt;Copy the &lt;code class="markup--code markup--li-code"&gt;production&lt;/code&gt; client-ID from your PayPal account and use it in your app&lt;/li&gt;&lt;/ul&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--8AqSWlRs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AWyJl7GFlM5fkXM9E4k_vHQ.png"&gt;&lt;br&gt;Get your live client-ID for production usage&lt;ul class="postList"&gt;
&lt;li class="graf graf--li graf-after--figure"&gt;In app implementation, change the &lt;code class="markup--code markup--li-code"&gt;PayPalEnvironmentSandbox&lt;/code&gt; to &lt;code class="markup--code markup--li-code"&gt;PayPalEnvironmentProduction&lt;/code&gt; in &lt;code class="markup--code markup--li-code"&gt;prepareToRender&lt;/code&gt; function&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;In web-implementation, change the script import with&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class="graf graf--pre graf-after--li"&gt;&amp;lt;script src=”&lt;a href="https://www.paypal.com/sdk/js?client-id=LIVE_CLIENT_ID"&gt;https://www.paypal.com/sdk/js?client-id=LIVE_CLIENT_ID&lt;/a&gt;"&amp;gt; &amp;lt;/script&amp;gt;&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;You’re all set now to make and accept payment from your Ionic app and PWA. Go enjoy, homie !&lt;/p&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--5nv6oWUx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2A1gWamK_ovlqZe_sQjLEkhQ.gif"&gt;&lt;br&gt;Let it rain !!!!&lt;h3 class="graf graf--h3 graf-after--figure"&gt;Conclusion&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;In this post, we learnt how to integrate PayPal in an Ionic app, as well as in an Ionic progressive web app. Testing can be performed easily using Sandbox accounts, and we can go live by simply changing sandbox client-ID with live-ID.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;Leave comments if you face any issues in the implementation. I’ll be happy to help.&lt;/p&gt;
&lt;h3 class="graf graf--h3 graf-after--p"&gt;Next Steps&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;If you liked this blog, you will also find the following Ionic blogs interesting and helpful. Feel free to ask any questions in the comment section&lt;/p&gt;
&lt;ul class="postList"&gt;
&lt;li class="graf graf--li graf-after--p"&gt;Ionic Payment Gateways — &lt;a href="https://enappd.com/blog/ionic-4-stripe-payment-integration-with-firebase-for-apps-and-pwa/17" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener"&gt;Stripe&lt;/a&gt; | &lt;a href="https://enappd.com/blog/ionic-4-paypal-payment-integration-for-apps-and-pwa/16" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener"&gt;PayPal&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-integrate-apple-pay-in-ionic-4-apps/21" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener"&gt;Apple Pay&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-integrate-razorpay-in-ionic-4-apps-and-pwa/20" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener"&gt;RazorPay&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Ionic Charts with — &lt;a href="https://enappd.com/blog/ionic-4-charts-using-google-charts/66" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener"&gt;Google Charts &lt;/a&gt;| &lt;a href="https://enappd.com/blog/adding-charts-in-ionic-4-apps-and-pwa-part-3/60" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener"&gt;HighCharts&lt;/a&gt; | &lt;a href="https://enappd.com/blog/adding-charts-in-ionic-4-apps-and-pwa-part-2/54" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener"&gt;d3.js&lt;/a&gt; | &lt;a href="https://enappd.com/blog/charts-in-ionic-4-apps-and-pwa-part-1/52" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener"&gt;Chart.js&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Ionic Social Logins — &lt;a href="https://enappd.com/blog/facebook-login-in-ionic-4-apps-using-firebase/25" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener"&gt;Facebook&lt;/a&gt; | &lt;a href="https://enappd.com/blog/google-login-in-ionic-4-apps-using-firebase/39" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener"&gt;Google&lt;/a&gt; | &lt;a href="https://enappd.com/blog/twitter-login-in-ionic-4-apps-using-firebase/24" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener"&gt;Twitter&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Ionic Authentications — &lt;a href="https://enappd.com/blog/email-authentication-with-firebase-in-ionic-4/38" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener"&gt;Via Email&lt;/a&gt; | &lt;a href="https://enappd.com/blog/firebase-anonymous-login-in-ionic-4/37" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener"&gt;Anonymous&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Ionic Features — &lt;a href="https://enappd.com/blog/using-geolocation-geocoding-and-reverse-geocoding-in-ionic-4/45" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener"&gt;Geolocation&lt;/a&gt; | &lt;a href="https://enappd.com/blog/qr-code-scanning-and-optical-character-recognition-ocr-in-ionic-4/9" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener"&gt;QR Code reader &lt;/a&gt;| &lt;a href="https://enappd.com/blog/best-fitness-plugins-for-ionic-4-how-to-use-pedometer/15" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener"&gt;Pedometer&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Media in Ionic — &lt;a href="https://enappd.com/blog/spotify-like-music-in-ionic-4-apps/48" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener"&gt;Audio&lt;/a&gt; | &lt;a href="https://enappd.com/blog/adding-video-player-in-ionic-4-app/64" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener"&gt;Video&lt;/a&gt; | &lt;a href="https://enappd.com/blog/image-picker-in-ionic-4-app/67" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener"&gt;Image Picker&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-add-image-cropper-in-ionic-4-app/68" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener"&gt;Image Cropper&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Ionic Essentials — &lt;a href="https://enappd.com/blog/ionic-4-save-and-retrieve-data-locally-on-device/59" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener"&gt;Native Storage&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-translate-in-ionic-4-globalization-internationalization-and-localization/11" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener"&gt;Translations&lt;/a&gt; | &lt;a href="https://enappd.com/blog/rtl-right-to-left-use-in-ionic-4/50" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener"&gt;RTL&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Ionic messaging — &lt;a href="https://enappd.com/blog/implement-ionic-4-firebase-push/34" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener"&gt;Firebase Push&lt;/a&gt; | &lt;a href="https://enappd.com/blog/automatically-read-sms-in-ionic-4-apps/42" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener"&gt;Reading SMS&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li graf--trailing"&gt;Ionic with Firebase — &lt;a href="https://enappd.com/blog/how-to-integrate-firebase-in-ionic-4-apps/23" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener"&gt;Basics&lt;/a&gt; | &lt;a href="https://enappd.com/blog/firebase-with-ionic-4-hosting-auth-and-db-connection/58" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener"&gt;Hosting and DB&lt;/a&gt; | &lt;a href="https://enappd.com/blog/firebase-cloud-functions-in-ionic-4-complete-guide/32" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener"&gt;Cloud functions&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 class="graf graf--h3 graf--leading"&gt;Ionic React Full App with Capacitor&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;If you need a base to start your next Ionic 5 React Capacitor app, you can make your next awesome app using &lt;a href="https://store.enappd.com/product/ionic-react-full-app-capacitor/" class="markup--anchor markup--p-anchor" rel="noopener"&gt;Ionic 5 React Full App in Capacitor&lt;/a&gt;&lt;/p&gt;
&lt;img class="graf-image" alt="Ionic 5 React Full App in Capacitor from Enappd" src="https://res.cloudinary.com/practicaldev/image/fetch/s--Z0sRDsyI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AG3yOFVX4oABx9MhUy-3kng.png"&gt;&lt;br&gt;Ionic 5 React Full App in Capacitor from Enappd&lt;h3 class="graf graf--h3 graf-after--figure"&gt;Ionic Capacitor Full App (Angular)&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;If you need a base to start your next Angular &lt;strong class="markup--strong markup--p-strong"&gt;Capacitor app&lt;/strong&gt;, you can make your next awesome app using &lt;a href="https://store.enappd.com/product/capacitor-full-app-with-ionic-angular/" class="markup--anchor markup--p-anchor" rel="noopener nofollow noopener"&gt;Capacitor Full App&lt;/a&gt;&lt;/p&gt;
&lt;img class="graf-image" alt="Capacitor Full App with huge number of layouts and features" src="https://res.cloudinary.com/practicaldev/image/fetch/s--jbZt2zIJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/0%2AUwSHcofTMStMnzAX.png"&gt;&lt;br&gt;Capacitor Full App with huge number of layouts and features&lt;h3 class="graf graf--h3 graf-after--figure"&gt;Ionic Full App (Angular and Cordova)&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;If you need a base to start your next Ionic 5 app, you can make your next awesome app using &lt;a href="https://store.enappd.com/product/ionic-full-app" class="markup--anchor markup--p-anchor"&gt;Ionic 5 Full App&lt;/a&gt;&lt;/p&gt;
&lt;img class="graf-image" alt="Ionic Full App with huge number of layouts and features" src="https://res.cloudinary.com/practicaldev/image/fetch/s--V1pEO0Mo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/0%2A1ArpKyhiDHZnevwB.jpeg"&gt;&lt;br&gt;Ionic Full App in Cordova, with huge number of layouts and features

</description>
      <category>ionic</category>
      <category>angular</category>
      <category>paypal</category>
      <category>payment</category>
    </item>
    <item>
      <title>Translate in Ionic 5 using apps and PWA</title>
      <dc:creator>Abhijeet Rathore</dc:creator>
      <pubDate>Fri, 31 Jul 2020 18:21:55 +0000</pubDate>
      <link>https://forem.com/enappd/translate-in-ionic-5-using-apps-and-pwa-1j20</link>
      <guid>https://forem.com/enappd/translate-in-ionic-5-using-apps-and-pwa-1j20</guid>
      <description>
&lt;p class="graf graf--p graf-after--figure"&gt;In this post you’ll learn how to translate text in Ionic 5 apps and PWA. You will also learn how to get device specific language and convert your app’s text to the same language / locale.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p is-selected"&gt;Ionic has a variety of app types nowadays (Angular/React/Vue , Cordova/Capacitor). This post will explore the Ionic apps made in Angular Cordova, but the same process can apply in Angular Capacitor apps as well.&lt;/p&gt;
&lt;h3 class="graf graf--h3 graf-after--p"&gt;Translation in Apps — how is it done ?&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;Multi-language translation, OR internationalization is a growing need for every app that wants to target international customers. Till date, majority of apps have been developed in English, no surprise ! But with growing apps users, every app is now focusing on translating to local languages.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;First we need to understand the steps involved in the process. Translations, thanks to Google, look very easy, but they are a bit involved in case of apps and websites, in our case Ionic 5 apps. There are 3 major steps in the translation process in an app —&lt;/p&gt;
&lt;ol class="postList"&gt;
&lt;li class="graf graf--li graf-after--p"&gt;
&lt;strong class="markup--strong markup--li-strong"&gt; 1. Translation Language&lt;/strong&gt; — Detect the language you want to translate into. This can either be done automatically by detecting phone or browser’s language (Globalization), OR, can be done with user actions (say, by using a dropdown).For our use case, we will detect device’s language using both &lt;a href="https://github.com/apache/cordova-plugin-globalization" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener"&gt;Cordova Globalization plugin&lt;/a&gt; and Browser’s Internationalization API.&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;
&lt;strong class="markup--strong markup--li-strong"&gt;2. Prepare Language Text&lt;/strong&gt; — You need to have a pre-translated dictionary (or JSON file) which stores the translations of all your app’s text in the Translation language. There are several ways to do this, as we’ll see in following steps. This is mostly a manual process for smaller apps, but you can use online tools like &lt;a href="https://www.logisticinfotech.com/translate-language-files-online-json/" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener"&gt;this&lt;/a&gt; for quick translations, or like &lt;a href="https://poeditor.com/" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener"&gt;POEditor&lt;/a&gt; for more standardized workflow.&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;
&lt;strong class="markup--strong markup--li-strong"&gt;3. Translate&lt;/strong&gt; — After the above two steps, you finally translate your app’s text to the intended language. We will use &lt;a href="https://github.com/ngx-translate/core" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener"&gt;ngx-translate&lt;/a&gt; library for translating our texts as we are talking about only Angular Ionic apps in this post&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 class="graf graf--h3 graf-after--li"&gt;Structure of the post&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;So the development outline of this blog will be&lt;/p&gt;
&lt;ol class="postList"&gt;
&lt;li class="graf graf--li graf-after--p"&gt;1. Create a starter Ionic 5 tab app&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;2. Prepare multiple language JSON files in assets&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;3. Implement &lt;a href="https://github.com/ngx-translate/core" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener"&gt;ngx-translate&lt;/a&gt; library to detect and translate AND Implement &lt;a href="https://github.com/apache/cordova-plugin-globalization" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener"&gt;Cordova Globalization plugin&lt;/a&gt; or browser Internationalization API to detect device language&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;4. Test translations on browser&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;5. The Directive Gotcha&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;6. Setup stand alone translations&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;7. Test translations on Android / iOS&lt;/li&gt;
&lt;/ol&gt;
&lt;p class="graf graf--p graf-after--li"&gt;We will translate English text in 2 languages — &lt;strong class="markup--strong markup--p-strong"&gt;French &lt;/strong&gt;and&lt;strong class="markup--strong markup--p-strong"&gt; Spanish&lt;/strong&gt;&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;Sounds pretty easy, right ? Well, let’s dive right into it.&lt;/p&gt;
&lt;h3 class="graf graf--h3 graf-after--p"&gt;Step 1— Create a basic Ionic Angular app&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;First you need to make sure you have the latest Ionic CLI. This will ensure you are using everything latest. Ensure latest Ionic CLI installation using&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;$ npm install -g ionic@latest&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;Here’s my environment for this blogpost&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;&lt;strong class="markup--strong markup--pre-strong"&gt;Ionic&lt;/strong&gt;:&lt;br&gt;Ionic CLI                     : 6.10.1 &lt;br&gt;Ionic Framework               : &lt;a href="http://twitter.com/ionic/angular" class="markup--anchor markup--pre-anchor" title="Twitter profile for @ionic/angular" rel="noopener"&gt;@ionic/angular&lt;/a&gt; 5.3.1&lt;br&gt;&lt;a href="http://twitter.com/angular" class="markup--anchor markup--pre-anchor" title="Twitter profile for @angular" rel="noopener"&gt;@angular&lt;/a&gt;-devkit/build-angular : 0.901.12&lt;br&gt;&lt;a href="http://twitter.com/angular" class="markup--anchor markup--pre-anchor" title="Twitter profile for @angular" rel="noopener"&gt;@angular&lt;/a&gt;-devkit/schematics    : 9.1.12&lt;br&gt;&lt;a href="http://twitter.com/angular/cli" class="markup--anchor markup--pre-anchor" title="Twitter profile for @angular/cli" rel="noopener"&gt;@angular/cli&lt;/a&gt;                  : 9.1.12&lt;br&gt;&lt;a href="http://twitter.com/ionic/angular-toolkit" class="markup--anchor markup--pre-anchor" title="Twitter profile for @ionic/angular-toolkit" rel="noopener"&gt;@ionic/angular-toolkit&lt;/a&gt;        : 2.3.0&lt;/pre&gt;
&lt;pre class="graf graf--pre graf-after--pre"&gt;&lt;strong class="markup--strong markup--pre-strong"&gt;Cordova&lt;/strong&gt;:&lt;br&gt;Cordova CLI       : 9.0.0 (&lt;a href="mailto:cordova-lib@9.0.1"&gt;cordova-lib@9.0.1&lt;/a&gt;)&lt;/pre&gt;
&lt;pre class="graf graf--pre graf-after--pre"&gt;&lt;strong class="markup--strong markup--pre-strong"&gt;System&lt;/strong&gt;:&lt;br&gt;Android SDK Tools : 26.1.1 &lt;br&gt;NodeJS            : v12.14.0&lt;br&gt;npm               : 6.13.4&lt;br&gt;OS                : macOS Catalina&lt;br&gt;Xcode             : Xcode 11.5 Build version 11E608c&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;Creating a basic Ionic-Angular app. Start a basic &lt;code class="markup--code markup--p-code"&gt;tabs&lt;/code&gt; starter using&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;$ ionic start ionicTranslate tabs --type=angular --cordova&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;The &lt;code class="markup--code markup--p-code"&gt;--type=angular&lt;/code&gt; told the CLI to create an &lt;strong class="markup--strong markup--p-strong"&gt;Angular&lt;/strong&gt; app, and &lt;code class="markup--code markup--p-code"&gt;--cordova&lt;/code&gt; tells the CLI to integrate Cordova in the app.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;Run the app in browser using&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;$ ionic serve&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;You won’t see much in the homepage created in the starter. I have modified pages ( tab1 and tab2) to align it to our translation functionality.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;My tab pages look like this&lt;/p&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--XiVnpuia--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2ASHE6-PZheRgQkD6tuj9NgQ.png"&gt;&lt;br&gt;Tab UI for translation&lt;p class="graf graf--p graf-after--figure"&gt;HTML and SCSS file code for the above UI, if you want to just get started&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;h3 class="graf graf--h3 graf-after--figure"&gt;Step 2 — Prepare multiple language JSON files in assets&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;We will create these JSON files in &lt;code class="markup--code markup--p-code"&gt;src/assets/i18n&lt;/code&gt; folder. The &lt;code class="markup--code markup--p-code"&gt;assets&lt;/code&gt; folder remains in the root even after a production build, so the path does not break. We will create three JSON files &lt;code class="markup--code markup--p-code"&gt;en.json&lt;/code&gt; (English), &lt;code class="markup--code markup--p-code"&gt;fr.json&lt;/code&gt; (French) and &lt;code class="markup--code markup--p-code"&gt;es.json&lt;/code&gt; (Spanish).&lt;/p&gt;
&lt;h4 class="graf graf--h4 graf-after--p"&gt;Folder structure for i18n files&lt;/h4&gt;
&lt;p class="graf graf--p graf-after--h4"&gt;&lt;code class="markup--code markup--p-code"&gt;&lt;strong class="markup--strong markup--p-strong"&gt;en.json&lt;/strong&gt;&lt;/code&gt;&lt;/p&gt;
&lt;br&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
"TITLE": "Hello sir",
"TITLE_2": "Hello {{value}}",
"description": "Ooohh .... did you just translate this text ?",
"data": {
  "name": "My name is {{name_value}}"}
}
&lt;/code&gt;&lt;/pre&gt;


&lt;p class="graf graf--p graf-after--pre"&gt;&lt;code class="markup--code markup--p-code"&gt;&lt;strong class="markup--strong markup--p-strong"&gt;fr.json&lt;/strong&gt;&lt;/code&gt;&lt;/p&gt;



&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
"TITLE": "Bonjour Monsieur",
"TITLE_2": "Bonjour {{value}}",
"description": "Ooohh .... vous venez de traduire ce texte?",
"data" :{
  "name": "je m'appelle {{name_value}}"}
}
&lt;/code&gt;&lt;/pre&gt;



&lt;p class="graf graf--p graf-after--pre"&gt;&lt;code class="markup--code markup--p-code"&gt;&lt;strong class="markup--strong markup--p-strong"&gt;es.json&lt;/strong&gt;&lt;/code&gt;&lt;/p&gt;



&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
"TITLE": "Hola señor",
"TITLE_2": "Hola {{value}}",
"description": "Ooohh .... acabas de traducir este texto?",
"data": {
  "name": "Me llamo {{name_value}}"}
}
&lt;/code&gt;&lt;/pre&gt;



&lt;p class="graf graf--p graf-after--pre"&gt;&lt;strong class="markup--strong markup--p-strong"&gt;Note&lt;/strong&gt;, the &lt;code class="markup--code markup--p-code"&gt;value&lt;/code&gt; and &lt;code class="markup--code markup--p-code"&gt;name_value&lt;/code&gt; are kind of variable/constants we can pass from our component. This can be used to&lt;/p&gt;
&lt;ul class="postList"&gt;
&lt;li class="graf graf--li graf-after--p"&gt;Replace the variable with a user input or a value depending on the situation OR&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;To give translations not supported by the library OR&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Keep a word constant across translations&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 class="graf graf--h3 graf-after--li"&gt;STEP 3: Implement ngx-translate library and Cordova Globalization plugin&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;Cordova globalization plugin is used to detect device’s default language/locale. Unfortunately, this plugin is deprecated, but it is still supported by Ionic. Hence, you can opt to use it. However, the latest way of detecting the language / locale of the browser is by using browsers’s &lt;a href="https://cordova.apache.org/news/2017/11/20/migrate-from-cordova-globalization-plugin.html" class="markup--anchor markup--p-anchor" rel="noopener"&gt;default Internationalization API.&lt;/a&gt;&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;Install Cordova globalization Plugin using&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;$ ionic cordova plugin add cordova-plugin-globalization&lt;/pre&gt;
&lt;pre class="graf graf--pre graf-after--pre"&gt;$ npm install @ionic-native/globalization&lt;/pre&gt;
&lt;h4 class="graf graf--h4 graf-after--pre"&gt;Install &lt;strong class="markup--strong markup--h4-strong"&gt;ngx-translate &lt;/strong&gt;library&lt;/h4&gt;
&lt;p class="graf graf--p graf-after--h4"&gt;&lt;strong class="markup--strong markup--p-strong"&gt;ngx-translate&lt;/strong&gt; is the internationalization (i18n) library for Angular. Since our app has Angular under the hood, we can use this library for app as well as progressive web apps.&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;// Install core library&lt;br&gt;npm install --save @ngx-translate/core&lt;/pre&gt;
&lt;pre class="graf graf--pre graf-after--pre"&gt;// Install http loader&lt;br&gt;npm install @ngx-translate/http-loader --save&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;&lt;strong class="markup--strong markup--p-strong"&gt;http-loader &lt;/strong&gt;is used for loading the translation files (JSONs in our case) via Angular’s HttpClient module.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;Note the versions of ngx-translate you should have as per your Angular version&lt;/p&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--F5KdC3Mt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AAesnbxaXR-zE-qXYC4G4YQ.png"&gt;&lt;br&gt;Use appropriate version of ngx-translate based on your Angular version&lt;h4 class="graf graf--h4 graf-after--figure"&gt;Setup the translation library and http-loader&lt;/h4&gt;
&lt;p class="graf graf--p graf-after--h4"&gt;We need to define a function that loads the external JSON files to the app using http-loader. Add the following function to &lt;code class="markup--code markup--p-code"&gt;app.module.ts&lt;/code&gt;&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;export function HttpLoaderFactory(http: HttpClient) {&lt;br&gt;  return new TranslateHttpLoader(http, "./assets/i18n/", ".json");&lt;br&gt;}&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;where we have provided the external path of our JSON files to the function.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;We need to add the &lt;strong class="markup--strong markup--p-strong"&gt;translation&lt;/strong&gt; and &lt;strong class="markup--strong markup--p-strong"&gt;http-loader &lt;/strong&gt;modules in our root module &lt;code class="markup--code markup--p-code"&gt;app.module.ts&lt;/code&gt;. This is how the file looks after setup.&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;p class="graf graf--p graf-after--figure"&gt;Pay attention to &lt;code class="markup--code markup--p-code"&gt;TranslateModule.forRoot()&lt;/code&gt; This is used in case of a Tabbed application, or general non lazy-loaded module. For a tab child, however, we will have to use &lt;code class="markup--code markup--p-code"&gt;TranslateModule.forChild()&lt;/code&gt; . We will see later how this will affect our functionality.&lt;/p&gt;
&lt;h4 class="graf graf--h4 graf-after--p"&gt;Setup the translate library in child component&lt;/h4&gt;
&lt;p class="graf graf--p graf-after--h4"&gt;Let’s say, we want to implement the translation in &lt;strong class="markup--strong markup--p-strong"&gt;Tab1. &lt;/strong&gt;As mentioned previously, &lt;code class="markup--code markup--p-code"&gt;src/app/tab1&lt;/code&gt; folder contains all the files for this page. We will import the &lt;code class="markup--code markup--p-code"&gt;translationService&lt;/code&gt; in &lt;code class="markup--code markup--p-code"&gt;tab1.page.ts&lt;/code&gt; file using&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;import { TranslateService } from '@ngx-translate/core';&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;The completed &lt;code class="markup--code markup--p-code"&gt;tab1.page.ts&lt;/code&gt; file will look like this&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;p class="graf graf--p graf-after--figure"&gt;Let’s break down the code to understand a bit more&lt;/p&gt;
&lt;ul class="postList"&gt;
&lt;li class="graf graf--li graf-after--p"&gt;On page load we check if we have default browser internationalization API by checking &lt;code class="markup--code markup--li-code"&gt;window.Intl&lt;/code&gt; . We then get default browser language using &lt;code class="markup--code markup--li-code"&gt;navigator.language&lt;/code&gt; . We also set a fall back on Cordova globalization plugin (deprecated) and set a default language if neither browser nor Cordova plugin works.&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Then we use &lt;code class="markup--code markup--li-code"&gt;this._translate.use(this.language)&lt;/code&gt; to tell the translation service which language to translate to. If the app has just loaded, it should default to your browser’s default language OR &lt;code class="markup--code markup--li-code"&gt;en&lt;/code&gt; (english)&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;
&lt;strong class="markup--strong markup--li-strong"&gt;Important: &lt;/strong&gt;Use&lt;code class="markup--code markup--li-code"&gt;this._translate.get('TITLE').subscribe()&lt;/code&gt; function from &lt;code class="markup--code markup--li-code"&gt;translateService&lt;/code&gt; to asynchronously fetch translations. Here,- &lt;code class="markup--code markup--li-code"&gt;get()&lt;/code&gt; is the function to fetch translations.- &lt;code class="markup--code markup--li-code"&gt;TITLE&lt;/code&gt; is the key to search for in the JSON files. If the data is in a nested JSON, then we use the dot notation to fetch e.g. &lt;code class="markup--code markup--li-code"&gt;data.name&lt;/code&gt;- &lt;code class="markup--code markup--li-code"&gt;subscribe&lt;/code&gt; is used for asynchronous fetching (no need to use timeouts)&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;
&lt;code class="markup--code markup--li-code"&gt;changeLanguage&lt;/code&gt; is called from user action. This function will use the previous two steps to translate to the intended language&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 class="graf graf--h3 graf-after--li"&gt;Step 4— Test translations on browser&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;Run the app on browser using &lt;code class="markup--code markup--p-code"&gt;ionic serve&lt;/code&gt; and test the translations using the dropdown. Here’s a GIF to show the functionality on browser&lt;/p&gt;
&lt;img class="graf-image" alt="Translate in Ionic 5 using ngx-translate" src="https://res.cloudinary.com/practicaldev/image/fetch/s--b20BL2H2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AGuMnfaPGW82fSOfmo8TfDg.gif"&gt;&lt;br&gt;Translate in Ionic 5 using ngx-translate&lt;p class="graf graf--p graf-after--figure"&gt;Notice that the text loads in English by default in my browser. You can change your browser language from browser settings and check if the initial text loads in your default language. For chrome, the settings can be found here&lt;/p&gt;
&lt;img class="graf-image" alt="Change your browser language to load app text in default language" src="https://res.cloudinary.com/practicaldev/image/fetch/s--GERZJcXL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2Ah_vLfApAfs38WU0Wn_MMrg.png"&gt;&lt;br&gt;Change your browser language to load app text in default language&lt;p class="graf graf--p graf-after--figure"&gt;And now my text loads default in French …. Bonjour !!&lt;/p&gt;
&lt;h3 class="graf graf--h3 graf-after--p"&gt;Step 5 — The Directive GOTCHA 😎&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;If you have followed the above steps exactly, you might not get the exact result as shown in the above GIF.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;You will realize that the &lt;strong class="markup--strong markup--p-strong"&gt;translation works&lt;/strong&gt; in places where you have used&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;this._translate.get('TITLE').subscribe((res: string) =&amp;gt; {           &lt;br&gt;this.title = res;&lt;br&gt;});&lt;br&gt;this._translate.get('description').subscribe((res: string) =&amp;gt; {           &lt;br&gt;this.description = res;&lt;br&gt;});&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;to get the translation, and shown it in the HTML using the local variable like this&lt;/p&gt;



&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;h1&amp;gt;{{ title }}&amp;lt;/h1&amp;gt;&amp;lt;p&amp;gt;{{ description }}&amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;



&lt;p class="graf graf--p graf-after--pre"&gt;BUT, the &lt;strong class="markup--strong markup--p-strong"&gt;translation does not work&lt;/strong&gt; in places where you have used a &lt;code class="markup--code markup--p-code"&gt;directive&lt;/code&gt; like either of the following&lt;/p&gt;



&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;h1 translate&amp;gt;TITLE&amp;lt;/h1&amp;gt;&amp;lt;p [translate]="'description'"&amp;gt;&amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;



&lt;p class="graf graf--p graf-after--pre"&gt;This is because in our Ionic 5 tab app, the tab pages are lazy-loaded. In lazy-loaded modules, you need to import the translation module in child modules as well for everything to work correctly.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;Let’s go to our &lt;code class="markup--code markup--p-code"&gt;tab1.module.ts&lt;/code&gt; file, and import the translation and http-loader modules similar to our root module. But this time, we will use &lt;code class="markup--code markup--p-code"&gt;TranslateModule.forChild&lt;/code&gt; . The complete module file looks like the following&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;p class="graf graf--p graf-after--figure"&gt;Now, if you run the app again, the &lt;code class="markup--code markup--p-code"&gt;directive&lt;/code&gt; translations will also work fine. 😎 😎 😎&lt;/p&gt;
&lt;blockquote class="graf graf--blockquote graf-after--p"&gt;
&lt;code class="markup--code markup--blockquote-code"&gt;&lt;em class="markup--em markup--blockquote-em"&gt;directive&lt;/em&gt;&lt;/code&gt;&lt;em class="markup--em markup--blockquote-em"&gt; method is preferred for bigger apps with lots of code, since this method results in smaller code size and no need of local variables.&lt;/em&gt;
&lt;/blockquote&gt;
&lt;h3 class="graf graf--h3 graf-after--blockquote"&gt;Step 6— Setup stand alone translations&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;The process of setting up separate language file in &lt;code class="markup--code markup--p-code"&gt;assets&lt;/code&gt; for each language is the standard way of translation in Angular. But sometimes it becomes a little cumbersome, especially when you don’t have that much data to translate.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;In case you want to quickly translate in the component itself, so that there is no spill over on other components, you can declare the variables in the components itself instead of reading them from the JSON files from &lt;code class="markup--code markup--p-code"&gt;assets&lt;/code&gt;&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;Let’s do these changes in &lt;strong class="markup--strong markup--p-strong"&gt;tab2, &lt;/strong&gt;so it doesn’t affect the global translations in &lt;strong class="markup--strong markup--p-strong"&gt;tab1&lt;/strong&gt;&lt;/p&gt;
&lt;h4 class="graf graf--h4 graf-after--p"&gt;HTML and SCSS&lt;/h4&gt;
&lt;p class="graf graf--p graf-after--h4"&gt;Similar to &lt;code class="markup--code markup--p-code"&gt;tab1.page.html&lt;/code&gt; , just remove the usage of variable &lt;code class="markup--code markup--p-code"&gt;data&lt;/code&gt; from the HTML. You can keep the styling same&lt;/p&gt;
&lt;h4 class="graf graf--h4 graf-after--p"&gt;tab2.page.ts&lt;/h4&gt;
&lt;p class="graf graf--p graf-after--h4"&gt;Stays pretty much same as &lt;code class="markup--code markup--p-code"&gt;tab1.page.ts&lt;/code&gt; . Just add the following in the constructor&lt;/p&gt;



&lt;pre class="highlight plaintext"&gt;&lt;code&gt;_translate.setTranslation('en', {
 "TITLE": "Bye sir",
 "TITLE_2": "Bye {{value}}",
 "description": "Thanks for translating this text"
});
_translate.setTranslation('fr', {
 "TITLE": "Au revoir Monsieur",
 "TITLE_2": "Au revoir  {{value}}",
 "description": "Merci d'avoir traduit ce texte"
});
_translate.setTranslation('es', {
 "TITLE": "Adiós señor",
 "TITLE_2": "Adiós {{value}}",
 "description": "Gracias por traducir este texto"
});
&lt;/code&gt;&lt;/pre&gt;




&lt;p class="graf graf--p graf-after--pre"&gt;Here, you are defining the translations locally in your component itself. Also, to let angular know that these are standalone translations, you use &lt;code class="markup--code markup--p-code"&gt;isolate:true&lt;/code&gt; in your &lt;code class="markup--code markup--p-code"&gt;tab2.module.ts&lt;/code&gt;&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;....&lt;br&gt;TranslateModule.forChild({&lt;br&gt; loader: {&lt;br&gt;  provide: TranslateLoader,&lt;br&gt;  useFactory: HttpLoaderFactory,&lt;br&gt;  deps: [HttpClient]&lt;br&gt; },&lt;br&gt; &lt;strong class="markup--strong markup--pre-strong"&gt;isolate: true&lt;/strong&gt;&lt;br&gt;}),&lt;br&gt;....&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;Now run the app in browser and test translations. Your translations will be picked from the local component itself&lt;/p&gt;
&lt;img class="graf-image" alt="Translation in Ionic 5 apps using component level translations" src="https://res.cloudinary.com/practicaldev/image/fetch/s--GUbAH26s--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AtX8q68qoJg9nzrPaJjdYbA.gif"&gt;&lt;br&gt;Translation in Ionic 5 apps using component level translations&lt;p class="graf graf--p graf-after--figure"&gt;Notice, the &lt;code class="markup--code markup--p-code"&gt;directive&lt;/code&gt; method and &lt;code class="markup--code markup--p-code"&gt;variable&lt;/code&gt; also work well with the local definitions.&lt;/p&gt;
&lt;h3 class="graf graf--h3 graf-after--p"&gt;Step 7 — Test translations in iOS/Android&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;To build the app on android, run the following commands one after another&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;$ ionic cordova platform add android&lt;/pre&gt;
&lt;pre class="graf graf--pre graf-after--pre"&gt;$ ionic cordova run android&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;The final command will run the app on either default emulator, or an android device attached to your system. Here’s the translation running on my android device&lt;/p&gt;
&lt;img class="graf-image" alt="Ionic 5 Angular app — Translation and Globalization" src="https://res.cloudinary.com/practicaldev/image/fetch/s--ecdGDAsu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AN4bM3_7dTU5VQEhmsmo7-w.gif"&gt;&lt;br&gt;Ionic 5 Angular app — Translation and Globalization&lt;p class="graf graf--p graf-after--figure"&gt;&lt;strong class="markup--strong markup--p-strong"&gt;Interesting fact: &lt;/strong&gt;In device, the language id may be different from browser. For me&lt;br&gt;- Device default language comes out to be &lt;code class="markup--code markup--p-code"&gt;en-US&lt;/code&gt;&lt;br&gt;- Browser’s default language comes out to be &lt;code class="markup--code markup--p-code"&gt;en&lt;/code&gt;&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;Hence, you need to be careful to detect all variations of a language. Accordingly, you’ll need to have JSON file named accordingly.&lt;/p&gt;
&lt;h3 class="graf graf--h3 graf-after--p"&gt;Conclusion&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;In this post we learnt how to detect device / browser language, create multiple language files, and implement translation using different methods in Ionic 5 apps.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p graf--trailing"&gt;The only limitation of using the &lt;strong class="markup--strong markup--p-strong"&gt;ngx-translate &lt;/strong&gt;library is that you will need to define your language texts on each page of your application beforehand. These will be stored as country code titled JSON files (i.e. en.json, jp.json, it.json etc) within the &lt;strong class="markup--strong markup--p-strong"&gt;src/assets/i18n/&lt;/strong&gt; directory. You can’t dynamically generate the language translation on the fly using this library so if you require that type of functionality you’ll need to look into using the Google Translate API or something similar.&lt;/p&gt;

&lt;h3 class="graf graf--h3 graf--leading"&gt;Next Steps&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;If you liked this blog, you will also find the following Ionic blogs interesting and helpful. Feel free to ask any questions in the comment section&lt;/p&gt;
&lt;ul class="postList"&gt;
&lt;li class="graf graf--li graf-after--p"&gt;Ionic Payment Gateways — &lt;a href="https://enappd.com/blog/ionic-4-stripe-payment-integration-with-firebase-for-apps-and-pwa/17" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;Stripe&lt;/a&gt; | &lt;a href="https://enappd.com/blog/ionic-4-paypal-payment-integration-for-apps-and-pwa/16" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;PayPal&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-integrate-apple-pay-in-ionic-4-apps/21" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;Apple Pay&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-integrate-razorpay-in-ionic-4-apps-and-pwa/20" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;RazorPay&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Ionic Charts with — &lt;a href="https://enappd.com/blog/ionic-4-charts-using-google-charts/66" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;Google Charts &lt;/a&gt;| &lt;a href="https://enappd.com/blog/adding-charts-in-ionic-4-apps-and-pwa-part-3/60" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;HighCharts&lt;/a&gt; | &lt;a href="https://enappd.com/blog/adding-charts-in-ionic-4-apps-and-pwa-part-2/54" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;d3.js&lt;/a&gt; | &lt;a href="https://enappd.com/blog/charts-in-ionic-4-apps-and-pwa-part-1/52" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;Chart.js&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Ionic Social Logins — &lt;a href="https://enappd.com/blog/facebook-login-in-ionic-4-apps-using-firebase/25" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;Facebook&lt;/a&gt; | &lt;a href="https://enappd.com/blog/google-login-in-ionic-4-apps-using-firebase/39" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;Google&lt;/a&gt; | &lt;a href="https://enappd.com/blog/twitter-login-in-ionic-4-apps-using-firebase/24" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;Twitter&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Ionic Authentications — &lt;a href="https://enappd.com/blog/email-authentication-with-firebase-in-ionic-4/38" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;Via Email&lt;/a&gt; | &lt;a href="https://enappd.com/blog/firebase-anonymous-login-in-ionic-4/37" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;Anonymous&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Ionic Features — &lt;a href="https://enappd.com/blog/using-geolocation-geocoding-and-reverse-geocoding-in-ionic-4/45" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;Geolocation&lt;/a&gt; | &lt;a href="https://enappd.com/blog/qr-code-scanning-and-optical-character-recognition-ocr-in-ionic-4/9" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;QR Code reader &lt;/a&gt;| &lt;a href="https://enappd.com/blog/best-fitness-plugins-for-ionic-4-how-to-use-pedometer/15" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;Pedometer&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Media in Ionic — &lt;a href="https://enappd.com/blog/spotify-like-music-in-ionic-4-apps/48" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;Audio&lt;/a&gt; | &lt;a href="https://enappd.com/blog/adding-video-player-in-ionic-4-app/64" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;Video&lt;/a&gt; | &lt;a href="https://enappd.com/blog/image-picker-in-ionic-4-app/67" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;Image Picker&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-add-image-cropper-in-ionic-4-app/68" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;Image Cropper&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Ionic Essentials — &lt;a href="https://enappd.com/blog/ionic-4-save-and-retrieve-data-locally-on-device/59" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;Native Storage&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-translate-in-ionic-4-globalization-internationalization-and-localization/11" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;Translations&lt;/a&gt; | &lt;a href="https://enappd.com/blog/rtl-right-to-left-use-in-ionic-4/50" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;RTL&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Ionic messaging — &lt;a href="https://enappd.com/blog/implement-ionic-4-firebase-push/34" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;Firebase Push&lt;/a&gt; | &lt;a href="https://enappd.com/blog/automatically-read-sms-in-ionic-4-apps/42" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;Reading SMS&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li graf--trailing"&gt;Ionic with Firebase — &lt;a href="https://enappd.com/blog/how-to-integrate-firebase-in-ionic-4-apps/23" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;Basics&lt;/a&gt; | &lt;a href="https://enappd.com/blog/firebase-with-ionic-4-hosting-auth-and-db-connection/58" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;Hosting and DB&lt;/a&gt; | &lt;a href="https://enappd.com/blog/firebase-cloud-functions-in-ionic-4-complete-guide/32" class="markup--anchor markup--li-anchor" rel="noopener nofollow noopener noopener noopener noopener noopener noopener noopener"&gt;Cloud functions&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 class="graf graf--h3 graf--leading"&gt;Ionic React Full App with Capacitor&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;If you need a base to start your next Ionic 5 React Capacitor app, you can make your next awesome app using &lt;a href="https://store.enappd.com/product/ionic-react-full-app-capacitor/" class="markup--anchor markup--p-anchor" rel="noopener"&gt;Ionic 5 React Full App in Capacitor&lt;/a&gt;&lt;/p&gt;
&lt;img class="graf-image" alt="Ionic 5 React Full App in Capacitor from Enappd" src="https://res.cloudinary.com/practicaldev/image/fetch/s--Z0sRDsyI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AG3yOFVX4oABx9MhUy-3kng.png"&gt;&lt;br&gt;Ionic 5 React Full App in Capacitor from Enappd&lt;h3 class="graf graf--h3 graf-after--figure"&gt;Ionic Capacitor Full App (Angular)&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;If you need a base to start your next Angular &lt;strong class="markup--strong markup--p-strong"&gt;Capacitor app&lt;/strong&gt;, you can make your next awesome app using &lt;a href="https://store.enappd.com/product/capacitor-full-app-with-ionic-angular/" class="markup--anchor markup--p-anchor" rel="noopener nofollow noopener noopener noopener"&gt;Capacitor Full App&lt;/a&gt;&lt;/p&gt;
&lt;img class="graf-image" alt="Capacitor Full App with huge number of layouts and features" src="https://res.cloudinary.com/practicaldev/image/fetch/s--jbZt2zIJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/0%2AUwSHcofTMStMnzAX.png"&gt;&lt;br&gt;Capacitor Full App with huge number of layouts and features&lt;h3 class="graf graf--h3 graf-after--figure"&gt;Ionic Full App (Angular and Cordova)&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;If you need a base to start your next Ionic 5 app, you can make your next awesome app using &lt;a href="https://store.enappd.com/product/ionic-full-app" class="markup--anchor markup--p-anchor" rel="noopener"&gt;Ionic 5 Full App&lt;/a&gt;&lt;/p&gt;
&lt;img class="graf-image" alt="Ionic Full App with huge number of layouts and features" src="https://res.cloudinary.com/practicaldev/image/fetch/s--V1pEO0Mo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/0%2A1ArpKyhiDHZnevwB.jpeg"&gt;&lt;br&gt;Ionic Full App in Cordova, with huge number of layouts and features

</description>
      <category>translate</category>
      <category>ionic</category>
      <category>localization</category>
      <category>angular</category>
    </item>
    <item>
      <title>Implement AdMob in Ionic React Capacitor Apps</title>
      <dc:creator>Abhijeet Rathore</dc:creator>
      <pubDate>Sun, 19 Apr 2020 19:07:04 +0000</pubDate>
      <link>https://forem.com/enappd/implement-admob-in-ionic-react-capacitor-apps-5g36</link>
      <guid>https://forem.com/enappd/implement-admob-in-ionic-react-capacitor-apps-5g36</guid>
      <description>
&lt;blockquote class="graf graf--blockquote graf-after--figure"&gt;This post is done on a special request from one of our thousands readers. If you have more requests, let me know in the comments&lt;/blockquote&gt;
&lt;p class="graf graf--p graf-after--blockquote"&gt;In this post, you will learn how to implement &lt;strong class="markup--strong markup--p-strong"&gt;AdMob functionality, &lt;/strong&gt;i.e. Google advertisements, in Ionic React Capacitor apps. We will implement this in a simple Ionic App and test on iOS simulator and Android device.&lt;/p&gt;
&lt;h3 class="graf graf--h3 graf-after--p"&gt;What is Admob?&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;As we all know, advertisements are the major source of income for all tech giants like Google, Facebook, Twitter etc. Google ads are one of the most popular ads out there, and the mobile version of Google ads is what they call AdMob.&lt;/p&gt;
&lt;img class="graf-image" alt="An example of Google AdMob ad. The ad is prompting user to install certain app" src="https://res.cloudinary.com/practicaldev/image/fetch/s--vDshULUC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AaD95WfvKex9OdEP0B6GWqg.jpeg"&gt;&lt;br&gt;An example of Google AdMob ad. The ad is prompting user to install certain app&lt;h4 class="graf graf--h4 graf-after--figure"&gt;Type of AdMob ads&lt;/h4&gt;
&lt;p class="graf graf--p graf-after--h4"&gt;&lt;strong class="markup--strong markup--p-strong"&gt;Banner&lt;/strong&gt;: A basic ad format that appears at the top &amp;amp; bottom of the device screen.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;&lt;strong class="markup--strong markup--p-strong"&gt;Interstitial&lt;/strong&gt;: Full-page ads appear at natural breaks &amp;amp; transitions, such as level completion. Supports video content.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;&lt;strong class="markup--strong markup--p-strong"&gt;Rewarded&lt;/strong&gt;: Full page Ads reward users for watching short videos and interacting with playable ads and surveys. Good for monetizing free-to-play users. Supports video content.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;&lt;strong class="markup--strong markup--p-strong"&gt;Native&lt;/strong&gt;: Customizable ad format that matches the look &amp;amp; feel of your app. Ads appear inline with app content. Supports video content. For now, Native ads are only possible in Native apps, not in hybrid apps like the ones based on Ionic or React Native.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;Let us look at the underlying frameworks for this post. &lt;strong class="markup--strong markup--p-strong"&gt;If you are conversant with Ionic and Capacitor, skip these sections and go to the code segment of the post.&lt;/strong&gt;&lt;/p&gt;
&lt;h3 class="graf graf--h3 graf-after--p"&gt;Disclaimer&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;Since this post is a mix of three frameworks, it is possible you landed here by mistake. If you are looking for AdMob login in&lt;/p&gt;
&lt;ul class="postList"&gt;
&lt;li class="graf graf--li graf-after--p"&gt;React Native — Please check &lt;a href="https://enappd.com/blog/implement-admob-in-react-native-with-firebase/133" class="markup--anchor markup--li-anchor" rel="noopener"&gt;this post&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Ionic React (Capacitor) apps — Continue reading 😎&lt;/li&gt;
&lt;/ul&gt;
&lt;p class="graf graf--p graf-after--li"&gt;As you can see from above, there are more than one options available for Hybrid app development these days, and it is easy to get confused between them. This post is focussed on &lt;strong class="markup--strong markup--p-strong"&gt;Ionic framework&lt;/strong&gt; with &lt;strong class="markup--strong markup--p-strong"&gt;React&lt;/strong&gt; as the front-end framework, and &lt;a href="https://capacitor.ionicframework.com/docs/" class="markup--anchor markup--p-anchor" rel="noopener nofollow noopener noopener"&gt;&lt;strong class="markup--strong markup--p-strong"&gt;Capacitor&lt;/strong&gt;&lt;/a&gt; as runtime and build environment.&lt;/p&gt;
&lt;blockquote class="graf graf--blockquote graf-after--p"&gt;
&lt;strong class="markup--strong markup--blockquote-strong"&gt;&lt;em class="markup--em markup--blockquote-em"&gt;Code for this tutorial is available on Github repo &lt;/em&gt;&lt;/strong&gt;&lt;a href="https://github.com/enappd/ionic-react-admob" class="markup--anchor markup--blockquote-anchor" rel="noopener"&gt;&lt;strong class="markup--strong markup--blockquote-strong"&gt;&lt;em class="markup--em markup--blockquote-em"&gt;ionic-react-capacitor-admob&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt;
&lt;/blockquote&gt;
&lt;p class="graf graf--p graf-after--blockquote"&gt;Let’s see a brief intro to each of the included frameworks:&lt;/p&gt;
&lt;ol class="postList"&gt;
&lt;li class="graf graf--li graf-after--p"&gt;Ionic&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Capacitor&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 class="graf graf--h3 graf-after--li"&gt;What is Ionic ?&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;You probably already know about Ionic, but I’m putting it here just for the sake of beginners. &lt;strong class="markup--strong markup--p-strong"&gt;Ionic&lt;/strong&gt; is a hybrid mobile app development SDK. It provides tools and services for developing hybrid mobile apps using Web technologies like CSS, HTML5, and Sass. In other words — If you create Native apps in Android, you code in Java. If you create Native apps in iOS, you code in Obj-C or Swift. Both of these are powerful but complex languages. &lt;strong class="markup--strong markup--p-strong"&gt;With Cordova (and Ionic) you can write a single piece of code for your app that can run on both iOS and Android &lt;/strong&gt;(and windows!), that too with the simplicity of HTML, CSS, and JS.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;It is important to note the contribution of Cordova/Capacitor in this. Ionic is only a UI wrapper made up of HTML, CSS and JS. So, by default, Ionic cannot run as an app in an iOS or Android device. Cordova/Capacitor is the build environment that containerizes (sort of) this Ionic web app and converts it into a device installable app, along with providing this app access to native APIs like Camera etc.&lt;/p&gt;
&lt;h3 class="graf graf--h3 graf-after--p"&gt;Capacitor — How is it different from Cordova ?&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;This section is relevant to only those who have been working with Ionic / Cordova for some time. Cordova has been the only choice available for Ionic app developers for quite some time. Cordova helps build Ionic web app into a device installable app.&lt;/p&gt;
&lt;blockquote class="graf graf--blockquote graf-after--p"&gt;&lt;strong class="markup--strong markup--blockquote-strong"&gt;&lt;em class="markup--em markup--blockquote-em"&gt;Capacitor is very similar to Cordova, but with some key differences in the app workflow&lt;/em&gt;&lt;/strong&gt;&lt;/blockquote&gt;
&lt;p class="graf graf--p graf-after--blockquote"&gt;Here are the differences between Cordova and Capacitor (You’ll appreciate these only if you have been using Cordova earlier, otherwise you can just skip)&lt;/p&gt;
&lt;ol class="postList"&gt;
&lt;li class="graf graf--li graf-after--p"&gt;Capacitor considers each platform project a &lt;em class="markup--em markup--li-em"&gt;source asset&lt;/em&gt; instead of a &lt;em class="markup--em markup--li-em"&gt;build time asset&lt;/em&gt;. That means, Capacitor wants you to keep the platform source code in the repository, unlike Cordova which always assumes that you will generate the platform code on build time&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Because of the above, Capacitor does not use &lt;code class="markup--code markup--li-code"&gt;config.xml&lt;/code&gt; or a similar custom configuration for platform settings. Instead, configuration changes are made by editing &lt;code class="markup--code markup--li-code"&gt;AndroidManifest.xml&lt;/code&gt; for Android and &lt;code class="markup--code markup--li-code"&gt;Info.plist&lt;/code&gt; for Xcode&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Capacitor does not “run on device” or emulate through the command line. Instead, such operations occur through the platform-specific IDE. So you cannot run an Ionic-capacitor app using a command like &lt;code class="markup--code markup--li-code"&gt;ionic run ios&lt;/code&gt; . You will have to run iOS apps using Xcode, and Android apps using Android studio&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Since platform code is not a &lt;em class="markup--em markup--li-em"&gt;source asset, &lt;/em&gt;you can directly change the native code using Xcode or Android Studio. This give more flexibility to developers&lt;/li&gt;
&lt;/ol&gt;
&lt;p class="graf graf--p graf-after--li"&gt;In essence, Capacitor is like a fresh, more flexible version of Cordova.&lt;/p&gt;
&lt;h3 class="graf graf--h3 graf-after--p"&gt;Plugins&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;Cordova and &lt;a href="https://ionicframework.com/docs/native" class="markup--anchor markup--p-anchor" rel="noopener nofollow noopener noopener"&gt;Ionic Native&lt;/a&gt; plugins can be used in Capacitor environment. However, there are certain Cordova plugins which are known to be &lt;a href="https://capacitor.ionicframework.com/docs/cordova/known-incompatible-plugins/" class="markup--anchor markup--p-anchor" rel="noopener nofollow noopener noopener"&gt;incompatible with Capacitor.&lt;/a&gt; For Admob functionality, we’ll use the &lt;a href="https://github.com/rahadur/capacitor-admob" class="markup--anchor markup--p-anchor" rel="noopener"&gt;Capacitor Admob plugin&lt;/a&gt;&lt;/p&gt;
&lt;h3 class="graf graf--h3 graf-after--p"&gt;Post structure&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;We will go in a step-by-step manner to explore the AdMob feature implementation. This is my break-down of the blog&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;&lt;strong class="markup--strong markup--p-strong"&gt;STEPS&lt;/strong&gt;&lt;/p&gt;
&lt;ol class="postList"&gt;
&lt;li class="graf graf--li graf-after--p"&gt;Create a basic Ionic Capacitor app with React&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Build the app in Android with Capacitor&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Setup your AdMob account&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Setup AdMob plugin&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Implement different types of Ads in your App&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Build the app on iOS simulator and test&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Build the app on Android device and test&lt;/li&gt;
&lt;/ol&gt;
&lt;p class="graf graf--p graf-after--li"&gt;So let’s dive right in!&lt;/p&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--TIhme6S0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AERffcqfeSC19qC5l50L94w.gif"&gt;&lt;br&gt;I made you laugh … didn’t I ? 😆&lt;h3 class="graf graf--h3 graf-after--figure"&gt;Step 1 — Create a basic Ionic Capacitor app with React&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;Create a basic app from Ionic starters itself.&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;$ ionic start ionic-react-admob tabs --type=react&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;This will create a basic Ionic app in React. I have chosen &lt;code class="markup--code markup--p-code"&gt;tabs&lt;/code&gt; starter so I can use different tabs for different Ad types.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;We’ll create a simple UI with few buttons that will trigger Ads. For interstitial ads, these triggers are generally completion of a level in a game app etc. Banner ads are generally triggered on page load itself. Reward ads are shown where user can earn a reward by watching the ads.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;My basic UI for the ad pages looks like this&lt;/p&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--1rAnJWaU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AeiMj9wkMmso_r_pfT8QEMw.png"&gt;&lt;br&gt;Basic UI for AdMob implementation in Ionic React Capacitor Apps — iOS&lt;h3 class="graf graf--h3 graf-after--figure"&gt;Step 2 — Build the app in Android with Capacitor&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;To build the apps for device / emulator, we need to attach capacitor to the app. Run&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;$ ionic integrations enable capacitor&lt;/pre&gt;
&lt;blockquote class="graf graf--blockquote graf-after--pre"&gt;&lt;strong class="markup--strong markup--blockquote-strong"&gt;&lt;em class="markup--em markup--blockquote-em"&gt;At the time of this post, I have node 12.14.0 and I have opted for Capacitor 1.x, although Capacitor 2.0 is also released. The reason is to avoid updating Xcode to read apps made by Capacitor 2.0. Although I have tested the functionality in Capacitor 2.0 with Android and it works&lt;/em&gt;&lt;/strong&gt;&lt;/blockquote&gt;
&lt;p class="graf graf--p graf-after--blockquote"&gt;By default if you run the above command, it will install Capacitor 2.0. Apps built with Capacitor 2.0 will require latest Android Studio and latest Xcode. If you have these, perfect ! But if you don’t, stick to Capacitor 1.x for the tutorial and you can update later. I have used &lt;code class="markup--code markup--p-code"&gt;“@capacitor/core”: “1.2.0”,&lt;/code&gt; and &lt;code class="markup--code markup--p-code"&gt;“@capacitor/cli”: “1.2.0”&lt;/code&gt; for this post.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;Add platforms and build the app in device as a test&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;// Add android platform&lt;br&gt;$ &lt;strong class="markup--strong markup--pre-strong"&gt;npx cap add android&lt;br&gt;&lt;/strong&gt;// Add iOS platform&lt;br&gt;$ &lt;strong class="markup--strong markup--pre-strong"&gt;npx cap add ios&lt;br&gt;&lt;/strong&gt;// Build web assets to copy to platforms&lt;br&gt;$ &lt;strong class="markup--strong markup--pre-strong"&gt;ionic build&lt;br&gt;&lt;/strong&gt;// copy the build assets to platforms&lt;br&gt;$ &lt;strong class="markup--strong markup--pre-strong"&gt;npx cap copy&lt;br&gt;&lt;/strong&gt;// open android studio to build app&lt;br&gt;$ &lt;strong class="markup--strong markup--pre-strong"&gt;npx cap open android&lt;br&gt;&lt;/strong&gt;// open xcode to build app&lt;br&gt;$ &lt;strong class="markup--strong markup--pre-strong"&gt;npx cap open ios&lt;/strong&gt;&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;At this point, you can run the app in either iOS / Android device or simulator using Xcode / Android Studio . You’ll see the UI running fine in the device.&lt;/p&gt;
&lt;h3 class="graf graf--h3 graf-after--p"&gt;Step 3 — Setup your Admob account&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;This step is common for any app. Since Admob is a Google service, independent of app platform, you can have one account and use it in every type of app. I use the same AdMob app in every AdMob example post.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;Follow these steps to create your Admob account and Admob app&lt;/p&gt;
&lt;ul class="postList"&gt;
&lt;li class="graf graf--li graf-after--p"&gt;Signup then Sign in to your AdMob account at &lt;a href="https://apps.admob.com/?utm_source=internal%26utm_medium=et%26utm_campaign=helpcentrecontextualopt%26utm_term=http://goo.gl/6Xkfcf%26subid=ww-ww-et-amhelpv4" class="markup--anchor markup--li-anchor" rel="noopener noreferrer noopener noopener noopener"&gt;&lt;/a&gt;&lt;a href="https://apps.admob.com"&gt;https://apps.admob.com&lt;/a&gt;.&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Click &lt;strong class="markup--strong markup--li-strong"&gt;Apps&lt;/strong&gt; in the sidebar.&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Click &lt;strong class="markup--strong markup--li-strong"&gt;Add app&lt;/strong&gt; to add a new app or click &lt;strong class="markup--strong markup--li-strong"&gt;View all apps&lt;/strong&gt; to search a list of all of the apps you’ve added to AdMob.&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;In the &lt;strong class="markup--strong markup--li-strong"&gt;App Settings &lt;/strong&gt;options, you can see your &lt;strong class="markup--strong markup--li-strong"&gt;App ID&lt;/strong&gt;. This is the ID you will need to connect your app to Google AdMob in your app.&lt;/li&gt;
&lt;/ul&gt;
&lt;img class="graf-image" alt="Note down your App ID from App Setting in Google AdMob" src="https://res.cloudinary.com/practicaldev/image/fetch/s--gLy9TuA0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AJoDnyDkki68npDr77EitSw.png"&gt;&lt;br&gt;Note down your App ID from App Setting in Google AdMob&lt;ul class="postList"&gt;&lt;li class="graf graf--li graf-after--figure"&gt;In the &lt;strong class="markup--strong markup--li-strong"&gt;Ad Units &lt;/strong&gt;section, you can add multiple types of Ad units. For more details on adding Ad Units, check out the following detailed step-by-step instructions for&lt;/li&gt;&lt;/ul&gt;
&lt;p class="graf graf--p graf-after--li"&gt;— &lt;a href="https://support.google.com/admob/answer/7311346?hl=en" class="markup--anchor markup--p-anchor" rel="noopener"&gt;Banner Ads&lt;/a&gt;&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;&lt;a href="https://support.google.com/admob/answer/7311435?hl=en%26ref_topic=7382891" class="markup--anchor markup--p-anchor" rel="noopener"&gt;— Interstitial Ads&lt;/a&gt;&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;— &lt;a href="https://support.google.com/admob/answer/7311747?hl=en%26ref_topic=7382891" class="markup--anchor markup--p-anchor" rel="noopener"&gt;Reward Ads&lt;/a&gt;&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p is-selected"&gt;AdMob has a ton of other settings for how, when and where your ads should show up, but all that for later. In this post, we’ll limit the discussion to &lt;strong class="markup--strong markup--p-strong"&gt;“How to display basic ad units in a Ionic React Capacitor app”&lt;/strong&gt;&lt;/p&gt;
&lt;h3 class="graf graf--h3 graf-after--p"&gt;Step 4 — Setup AdMob plugin&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;For this post, as I explained earlier, we are using &lt;a href="https://github.com/rahadur/capacitor-admob" class="markup--anchor markup--p-anchor" rel="noopener"&gt;Capacitor Admob plugin&lt;/a&gt;. Also, since capacitor does not inject necessary platform specific variables while building the app, we’ll have to make small changes when we build apps&lt;/p&gt;
&lt;h4 class="graf graf--h4 graf-after--p"&gt;4.1 Install Capacitor AdMob plugin&lt;/h4&gt;
&lt;p class="graf graf--p graf-after--h4"&gt;In your existing app, add the plugin using&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;&lt;strong class="markup--strong markup--pre-strong"&gt;$ npm install --save capacitor-admob&lt;/strong&gt;&lt;/pre&gt;
&lt;h4 class="graf graf--h4 graf-after--pre"&gt;4.2 Build in Android&lt;/h4&gt;
&lt;p class="graf graf--p graf-after--h4"&gt;Since we have only added a plugin, just sync the dependencies using&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;// copy the build assets to platforms&lt;br&gt;$ &lt;strong class="markup--strong markup--pre-strong"&gt;npx cap sync&lt;/strong&gt;&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;In Android Studio, open your &lt;code class="markup--code markup--p-code"&gt;AndroidManifest.xml&lt;/code&gt; file and add this &lt;code class="markup--code markup--p-code"&gt;meta-data&lt;/code&gt; line and replace the value by the actual &lt;strong class="markup--strong markup--p-strong"&gt;App ID&lt;/strong&gt; of your app&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;&amp;lt;application&amp;gt;&lt;br&gt;  &amp;lt;!-- this line needs to be added (replace the value!) --&amp;gt;&lt;br&gt;  &lt;strong class="markup--strong markup--pre-strong"&gt;&amp;lt;meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="ca-app-pub-3940256099942544~3347511713" /&amp;gt;&lt;/strong&gt;&lt;br&gt;  &amp;lt;activity&amp;gt;.....&amp;lt;/activity&amp;gt;&lt;br&gt;&amp;lt;/application&amp;gt;&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;Open your Ionic Capacitor App in Android Studio, Now open &lt;code class="markup--code markup--p-code"&gt;MainActivity.java&lt;/code&gt; of your app and Register AdMob Capacitor Plugin.&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;// Other imports...&lt;br&gt;&lt;strong class="markup--strong markup--pre-strong"&gt;import app.xplatform.capacitor.plugins.AdMob;&lt;br&gt;&lt;/strong&gt;public class MainActivity extends BridgeActivity {&lt;br&gt;  @Override&lt;br&gt;  public void onCreate(Bundle savedInstanceState) {&lt;br&gt;    super.onCreate(savedInstanceState);&lt;br&gt;this.init(savedInstanceState, new ArrayList&amp;lt;Class&amp;lt;? extends Plugin&amp;gt;&amp;gt;() &lt;code&gt;{{&amp;lt;br&amp;gt;      &amp;lt;strong class="markup--strong markup--pre-strong"&amp;gt;add(AdMob.class);&amp;lt;/strong&amp;gt;  // Add AdMob as a Capacitor Plugin&amp;lt;br&amp;gt;    }}&lt;/code&gt;);&lt;br&gt;  }&lt;br&gt;}&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;Build the app once on device. If there is no error, your Android app is ready to show ads&lt;/p&gt;
&lt;h4 class="graf graf--h4 graf-after--p"&gt;4.3 Build in iOS&lt;/h4&gt;
&lt;p class="graf graf--p graf-after--h4"&gt;Once again, just sync the dependencies using&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;// copy the build assets to platforms&lt;br&gt;$ &lt;strong class="markup--strong markup--pre-strong"&gt;npx cap sync&lt;/strong&gt;&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;Open your &lt;code class="markup--code markup--p-code"&gt;App/App/Info.plist&lt;/code&gt; file and add this &lt;code class="markup--code markup--p-code"&gt;plist value&lt;/code&gt; line and replace the value by the actual App ID of your app&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;&lt;strong class="markup--strong markup--pre-strong"&gt;&amp;lt;key&amp;gt;GADIsAdManagerApp&amp;lt;/key&amp;gt;&lt;br&gt;&amp;lt;true/&amp;gt;&lt;br&gt;&amp;lt;key&amp;gt;GADApplicationIdentifier&amp;lt;/key&amp;gt;&lt;br&gt;&lt;/strong&gt;&amp;lt;!-- replace this value with your App ID key--&amp;gt;&lt;br&gt;&lt;strong class="markup--strong markup--pre-strong"&gt;&amp;lt;string&amp;gt;ca-app-pub-6564742920318187~7217030993&amp;lt;/string&amp;gt;&lt;/strong&gt;&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;Build the app once on device/simulator. If there is no error, your iOS app is ready to show ads.&lt;/p&gt;
&lt;h3 class="graf graf--h3 graf-after--p"&gt;Step 5 — Implement different types of Ads in the app&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;Once everything is setup, let us implement different types of Ads in the app. For all types of Ads, you’ll need to import the plugin and initialize.&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;import { AdOptions, AdSize, AdPosition } from 'capacitor-admob';&lt;br&gt;const { AdMob, Toast } = Plugins;&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;In the constructor, initialize AdMob using&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;// replace with your own App ID&lt;br&gt;AdMob.initialize('ca-app-pub-3940256099942544~3347511713');&lt;/pre&gt;
&lt;h4 class="graf graf--h4 graf-after--pre"&gt;Banner Ad&lt;/h4&gt;
&lt;p class="graf graf--p graf-after--h4"&gt;Banner ads are implemented in Tab1. You’ll also need an &lt;code class="markup--code markup--p-code"&gt;Ad Unit ID&lt;/code&gt; for the banner ad from your AdMob account.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;Once you have the UI in &lt;code class="markup--code markup--p-code"&gt;Tab1.tsx&lt;/code&gt; file, we’ll implement four methods&lt;/p&gt;
&lt;ul class="postList"&gt;
&lt;li class="graf graf--li graf-after--p"&gt;showBanner&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;pauseBanner&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;resumeBanner&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;removeBanner&lt;/li&gt;
&lt;/ul&gt;
&lt;p class="graf graf--p graf-after--li"&gt;The names of the methods are self-explanatory. The code for the full page will look like this&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
Banner ad implementation in Ionic React Capacitor app
&lt;blockquote class="graf graf--blockquote graf-after--figure"&gt;&lt;strong class="markup--strong markup--blockquote-strong"&gt;You can get test ad IDs from Google for testing as well. DO NOT use a test ID in your production app, and DO NOT use your production Ad Unit ID while developing the app&lt;/strong&gt;&lt;/blockquote&gt;
&lt;h4 class="graf graf--h4 graf-after--blockquote"&gt;Interstitial Ad&lt;/h4&gt;
&lt;p class="graf graf--p graf-after--h4"&gt;Interstitial Ads work on a trigger. Because these are full page ads, they are not always visible as Banner Ads.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;To implement interstitial ads, import the plugin, initialize and follow the code below&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
Interstitial ad implementation in Ionic React Capacitor app
&lt;p class="graf graf--p graf-after--figure"&gt;Interstitial ads need to &lt;code class="markup--code markup--p-code"&gt;load&lt;/code&gt; before they can be shown. In you productions apps, it would be a good practice to load these ads on page load itself, and then show whenever required.&lt;/p&gt;
&lt;h4 class="graf graf--h4 graf-after--p"&gt;Reward Ad&lt;/h4&gt;
&lt;p class="graf graf--p graf-after--h4"&gt;Again, reward Ads are similar to interstitial ads in the trigger mechanism. To implement, import the required dependency and follow the code below&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
Reward ad implementation in Ionic React Capacitor app
&lt;p class="graf graf--p graf-after--figure"&gt;Again, &lt;code class="markup--code markup--p-code"&gt;TestIds.REWARDED&lt;/code&gt; is a test ID. Replace it with production Ad ID when releasing the app.&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;&lt;code class="markup--code markup--p-code"&gt;.prepareRewardVideoAd()&lt;/code&gt; method loads the ad. This ad takes some time in loading. That is why &lt;code class="markup--code markup--p-code"&gt;.showRewardVideoAd()&lt;/code&gt; should be called after a delay, or on success of loading.&lt;/p&gt;
&lt;h3 class="graf graf--h3 graf-after--p"&gt;Step 6: Testing the app on an iOS simulator&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;To build the code on iOS, just run these&lt;/p&gt;
&lt;pre class="graf graf--pre graf-after--p"&gt;$ ionic build&lt;br&gt;$ npx cap copy&lt;/pre&gt;
&lt;p class="graf graf--p graf-after--pre"&gt;Once done, build your app from Xcode, and run the app. Let’s see how the ads will look in iOS.&lt;/p&gt;
&lt;h4 class="graf graf--h4 graf-after--p"&gt;Banner Ad&lt;/h4&gt;
&lt;p class="graf graf--p graf-after--h4"&gt;The resulting ad looks like this on iOS&lt;/p&gt;
&lt;img class="graf-image" alt="AdMob Banner ads in iOS — Ionic React Capacitor app" src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ez2-hXaK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2Ap3J6eokJ00Qq5xAgV6uX5Q.gif"&gt;&lt;br&gt;AdMob Banner ads in iOS — Ionic React Capacitor app&lt;h4 class="graf graf--h4 graf-after--figure"&gt;Interstitial Ad&lt;/h4&gt;
&lt;p class="graf graf--p graf-after--h4"&gt;The ad on full screen looks like following on iOS&lt;/p&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--_BN78skt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2ANHIfY-6xNNUL8VCdvsr43g.gif"&gt;&lt;br&gt;AdMob Interstitial ads in iOS — Ionic React Capacitor app&lt;h4 class="graf graf--h4 graf-after--figure"&gt;Reward Ad&lt;/h4&gt;
&lt;p class="graf graf--p graf-after--h4"&gt;The reward ad will look like this on iOS&lt;/p&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--61E99Uy6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AtTq2GKkpODRvgR83nyc2Hw.gif"&gt;&lt;br&gt;AdMob Reward ads in iOS — Ionic React Capacitor app&lt;h3 class="graf graf--h3 graf-after--figure"&gt;Step 7: Testing the app on an Android device&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;Just like iOS, the same code will show ads in Android as well. This video link &lt;a href="https://youtu.be/XHzwraE4hYc" class="markup--anchor markup--p-anchor" rel="noopener"&gt;here&lt;/a&gt; will show how the ads will show up on android device (just for the sake of completion of the post)&lt;/p&gt;
&lt;p class="graf graf--p graf-after--p"&gt;Tada ! You have learnt how to implement AdMob ads in your Ionic React Capacitor app. 🎉&lt;/p&gt;
&lt;h3 class="graf graf--h3 graf-after--p"&gt;Conclusion&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;In this blog, we learned how to implement Google AdMob functionality in Ionic React Capacitor app. AdMob functionality is a must for an app where user wants to earn some revenue from ad clicks. This comes in handy when your app has a large number of users, and you do not charge users for anything in the app. So ads become your direct revenue source. You can also combine the interstitial ads and rewards ads with in-app rewards like a level up in a game, extra lives etc.&lt;/p&gt;
&lt;blockquote class="graf graf--blockquote graf-after--p"&gt;
&lt;strong class="markup--strong markup--blockquote-strong"&gt;&lt;em class="markup--em markup--blockquote-em"&gt;Code for this tutorial is available on Github repo &lt;/em&gt;&lt;/strong&gt;&lt;a href="https://github.com/enappd/ionic-react-admob" class="markup--anchor markup--blockquote-anchor" rel="noopener"&gt;&lt;strong class="markup--strong markup--blockquote-strong"&gt;&lt;em class="markup--em markup--blockquote-em"&gt;ionic-react-capacitor-admob&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt;
&lt;/blockquote&gt;
&lt;h3 class="graf graf--h3 graf-after--blockquote"&gt;Next Steps&lt;/h3&gt;
&lt;p class="graf graf--p graf-after--h3"&gt;Now that you have learnt about setting up AdMob in Ionic React Capacitor apps, here are some other topics you can look into&lt;/p&gt;
&lt;h4 class="graf graf--h4 graf-after--p"&gt;Ionic React Capacitor&lt;/h4&gt;
&lt;ul class="postList"&gt;
&lt;li class="graf graf--li graf-after--h4"&gt;&lt;a href="https://enappd.com/blog/facebook-login-in-ionic-react-capacitor-apps/118" class="markup--anchor markup--li-anchor" rel="noopener"&gt;Facebook Login in Ionic React Capacitor apps&lt;/a&gt;&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;&lt;a href="https://enappd.com/blog/twitter-login-in-ionic-react-capacitor-app/121" class="markup--anchor markup--li-anchor" rel="noopener"&gt;Twitter Login in Ionic React Capacitor apps&lt;/a&gt;&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;&lt;a href="https://enappd.com/blog/google-login-in-ionic-react-capacitor-apps/122" class="markup--anchor markup--li-anchor" rel="noopener"&gt;Google Login in Ionic React Capacitor apps&lt;/a&gt;&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;&lt;a href="https://enappd.com/blog/how-to-make-ionic-apps-in-react-using-capacitor/26" class="markup--anchor markup--li-anchor" rel="noopener"&gt;How to make basic apps in ionic-react-capacitor&lt;/a&gt;&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;&lt;a href="https://enappd.com/blog/camera-and-gallery-in-ionic-react-app-using-capacitor/110" class="markup--anchor markup--li-anchor" rel="noopener"&gt;Camera and Image gallery in Ionic-React-Capacitor&lt;/a&gt;&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;&lt;a href="https://enappd.com/blog/firebase-push-notification-in-ionic-react-capacitor/111" class="markup--anchor markup--li-anchor" rel="noopener"&gt;Push notification in Ionic-React-Capacitor apps&lt;/a&gt;&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;&lt;a href="https://enappd.com/blog/icon-splash-in-ionic-react-capacitor-apps/114" class="markup--anchor markup--li-anchor" rel="noopener"&gt;Adding Icon and Splash in Ionic React Capacitor apps&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p class="graf graf--p graf-after--li"&gt;If you need a base to start your next &lt;strong class="markup--strong markup--p-strong"&gt;Ionic 4 React app&lt;/strong&gt;, you can make your next awesome app using &lt;a href="https://store.enappd.com/product/ionic-react-full-app-capacitor/" class="markup--anchor markup--p-anchor" rel="noopener"&gt;Ionic React Full App&lt;/a&gt;&lt;/p&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--xeLiw-Wl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/0%2AAxzmDBUVguZ1kw_i.jpeg"&gt;&lt;br&gt;Ionic 4 React Full App with huge number of layouts and features&lt;h4 class="graf graf--h4 graf-after--figure"&gt;Ionic Angular Capacitor&lt;/h4&gt;
&lt;ul class="postList"&gt;
&lt;li class="graf graf--li graf-after--h4"&gt;&lt;a href="https://enappd.com/blog/play-music-in-ionic-capacitor-apps/112" class="markup--anchor markup--li-anchor" rel="noopener"&gt;Music Player&lt;/a&gt;&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;&lt;a href="https://enappd.com/blog/html5-games-in-ionic-capacitor-using-phaser/115" class="markup--anchor markup--li-anchor" rel="noopener"&gt;Create HTML5 games in Ionic Capacitor apps using Phaser&lt;/a&gt;&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;&lt;a href="https://enappd.com/blog/qr-code-and-barcode-scanning-with-ionic-capacitor/127" class="markup--anchor markup--li-anchor" rel="noopener"&gt;Barcode and QR code scanning in Ionic Capacitor apps&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p class="graf graf--p graf-after--li"&gt;If you need a base to start your next &lt;strong class="markup--strong markup--p-strong"&gt;Capacitor app&lt;/strong&gt;, you can make your next awesome app using &lt;a href="https://store.enappd.com/product/capacitor-full-app-with-ionic-angular/" class="markup--anchor markup--p-anchor" rel="noopener"&gt;Capacitor Full App&lt;/a&gt;&lt;/p&gt;
&lt;img class="graf-image" alt="Capacitor Full App with huge number of layouts and features" src="https://res.cloudinary.com/practicaldev/image/fetch/s--uodOg6-X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2A9eKBtNJaAYPMzyZvyifWIQ.png"&gt;&lt;br&gt;Capacitor Full App with huge number of layouts and features&lt;h4 class="graf graf--h4 graf-after--figure"&gt;Ionic Angular Cordova&lt;/h4&gt;
&lt;ul class="postList"&gt;
&lt;li class="graf graf--li graf-after--h4"&gt;Ionic Payment Gateways — &lt;a href="https://enappd.com/blog/ionic-4-stripe-payment-integration-with-firebase-for-apps-and-pwa/17" class="markup--anchor markup--li-anchor" rel="noopener"&gt;Stripe&lt;/a&gt; | &lt;a href="https://enappd.com/blog/ionic-4-paypal-payment-integration-for-apps-and-pwa/16" class="markup--anchor markup--li-anchor" rel="noopener"&gt;PayPal&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-integrate-apple-pay-in-ionic-4-apps/21" class="markup--anchor markup--li-anchor" rel="noopener"&gt;Apple Pay&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-integrate-razorpay-in-ionic-4-apps-and-pwa/20" class="markup--anchor markup--li-anchor" rel="noopener"&gt;RazorPay&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Ionic Charts with — &lt;a href="https://enappd.com/blog/ionic-4-charts-using-google-charts/66" class="markup--anchor markup--li-anchor" rel="noopener"&gt;Google Charts &lt;/a&gt;| &lt;a href="https://enappd.com/blog/adding-charts-in-ionic-4-apps-and-pwa-part-3/60" class="markup--anchor markup--li-anchor" rel="noopener"&gt;HighCharts&lt;/a&gt; | &lt;a href="https://enappd.com/blog/adding-charts-in-ionic-4-apps-and-pwa-part-2/54" class="markup--anchor markup--li-anchor" rel="noopener"&gt;d3.js&lt;/a&gt; | &lt;a href="https://enappd.com/blog/charts-in-ionic-4-apps-and-pwa-part-1/52" class="markup--anchor markup--li-anchor" rel="noopener"&gt;Chart.js&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Ionic Social Logins — &lt;a href="https://enappd.com/blog/facebook-login-in-ionic-4-apps-using-firebase/25" class="markup--anchor markup--li-anchor" rel="noopener"&gt;Facebook&lt;/a&gt; | &lt;a href="https://enappd.com/blog/google-login-in-ionic-4-apps-using-firebase/39" class="markup--anchor markup--li-anchor" rel="noopener"&gt;Google&lt;/a&gt; | &lt;a href="https://enappd.com/blog/twitter-login-in-ionic-4-apps-using-firebase/24" class="markup--anchor markup--li-anchor" rel="noopener"&gt;Twitter&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Ionic Authentications — &lt;a href="https://enappd.com/blog/email-authentication-with-firebase-in-ionic-4/38" class="markup--anchor markup--li-anchor" rel="noopener"&gt;Via Email&lt;/a&gt; | &lt;a href="https://enappd.com/blog/firebase-anonymous-login-in-ionic-4/37" class="markup--anchor markup--li-anchor" rel="noopener"&gt;Anonymous&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Ionic Features — &lt;a href="https://enappd.com/blog/using-geolocation-geocoding-and-reverse-geocoding-in-ionic-4/45" class="markup--anchor markup--li-anchor" rel="noopener"&gt;Geolocation&lt;/a&gt; | &lt;a href="https://enappd.com/blog/qr-code-scanning-and-optical-character-recognition-ocr-in-ionic-4/9" class="markup--anchor markup--li-anchor" rel="noopener"&gt;QR Code reader &lt;/a&gt;| &lt;a href="https://enappd.com/blog/best-fitness-plugins-for-ionic-4-how-to-use-pedometer/15" class="markup--anchor markup--li-anchor" rel="noopener"&gt;Pedometer&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Media in Ionic — &lt;a href="https://enappd.com/blog/spotify-like-music-in-ionic-4-apps/48" class="markup--anchor markup--li-anchor" rel="noopener"&gt;Audio&lt;/a&gt; | &lt;a href="https://enappd.com/blog/adding-video-player-in-ionic-4-app/64" class="markup--anchor markup--li-anchor" rel="noopener"&gt;Video&lt;/a&gt; | &lt;a href="https://enappd.com/blog/image-picker-in-ionic-4-app/67" class="markup--anchor markup--li-anchor" rel="noopener"&gt;Image Picker&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-add-image-cropper-in-ionic-4-app/68" class="markup--anchor markup--li-anchor" rel="noopener"&gt;Image Cropper&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Ionic Essentials — &lt;a href="https://enappd.com/blog/ionic-4-save-and-retrieve-data-locally-on-device/59" class="markup--anchor markup--li-anchor" rel="noopener"&gt;Native Storage&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-translate-in-ionic-4-globalization-internationalization-and-localization/11" class="markup--anchor markup--li-anchor" rel="noopener"&gt;Translations&lt;/a&gt; | &lt;a href="https://enappd.com/blog/rtl-right-to-left-use-in-ionic-4/50" class="markup--anchor markup--li-anchor" rel="noopener"&gt;RTL&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Ionic messaging — &lt;a href="https://enappd.com/blog/implement-ionic-4-firebase-push/34" class="markup--anchor markup--li-anchor" rel="noopener"&gt;Firebase Push&lt;/a&gt; | &lt;a href="https://enappd.com/blog/automatically-read-sms-in-ionic-4-apps/42" class="markup--anchor markup--li-anchor" rel="noopener"&gt;Reading SMS&lt;/a&gt;
&lt;/li&gt;
&lt;li class="graf graf--li graf-after--li"&gt;Ionic with Firebase — &lt;a href="https://enappd.com/blog/how-to-integrate-firebase-in-ionic-4-apps/23" class="markup--anchor markup--li-anchor" rel="noopener"&gt;Basics&lt;/a&gt; | &lt;a href="https://enappd.com/blog/firebase-with-ionic-4-hosting-auth-and-db-connection/58" class="markup--anchor markup--li-anchor" rel="noopener"&gt;Hosting and DB&lt;/a&gt; | &lt;a href="https://enappd.com/blog/firebase-cloud-functions-in-ionic-4-complete-guide/32" class="markup--anchor markup--li-anchor" rel="noopener"&gt;Cloud functions&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p class="graf graf--p graf-after--li"&gt;If you need a base to start your next &lt;strong class="markup--strong markup--p-strong"&gt;Ionic 5 Angular app&lt;/strong&gt;, you can make your next awesome app using &lt;a href="https://store.enappd.com/product/ionic-4-full-app" class="markup--anchor markup--p-anchor" rel="noopener"&gt;Ionic 5 Full App&lt;/a&gt;&lt;/p&gt;
&lt;img class="graf-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--OjyjeGrP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/0%2AlqQcM0JyxN7nFQdL.jpeg"&gt;&lt;br&gt;Ionic 5 Full App with huge number of layouts and features

</description>
      <category>ionic</category>
      <category>react</category>
      <category>capacitor</category>
      <category>admob</category>
    </item>
    <item>
      <title>Implement AdMob in React Native with Firebase</title>
      <dc:creator>Abhijeet Rathore</dc:creator>
      <pubDate>Tue, 14 Apr 2020 03:04:21 +0000</pubDate>
      <link>https://forem.com/enappd/implement-admob-in-react-native-with-firebase-3e38</link>
      <guid>https://forem.com/enappd/implement-admob-in-react-native-with-firebase-3e38</guid>
      <description>
&lt;blockquote&gt;This post is done on a special request from one of our thousands readers. If you have more requests, let me know in the comments&lt;/blockquote&gt;
&lt;p&gt;In this post, you will learn how to implement &lt;strong&gt;AdMob functionality, &lt;/strong&gt;i.e. Google advertisements, in React Native apps. We will implement this in a simple React Native app and test on iOS simulator.&lt;/p&gt;
&lt;p&gt;As we all know, advertisements are the major source of income for all tech giants like Google, Facebook, Twitter etc. Google ads are one of the most popular ads out there, and the mobile version of Google ads is what they call AdMob.&lt;/p&gt;
&lt;img alt="An example of Google AdMob ad. The ad is prompting user to install certain app" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AaD95WfvKex9OdEP0B6GWqg.jpeg"&gt;&lt;br&gt;An example of Google AdMob ad. The ad is prompting user to install certain app&lt;h4&gt;Type of AdMob ads&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;Banner&lt;/strong&gt;: A basic ad format that appears at the top &amp;amp; bottom of the device screen.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Interstitial&lt;/strong&gt;: Full-page ads appear at natural breaks &amp;amp; transitions, such as level completion. Supports video content.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Rewarded&lt;/strong&gt;: Full page Ads reward users for watching short videos and interacting with playable ads and surveys. Good for monetizing free-to-play users. Supports video content.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Native&lt;/strong&gt;: Customizable ad format that matches the look &amp;amp; feel of your app. Ads appear inline with app content. Supports video content. For now, Native ads are only possible in Native apps, not in hybrid apps like the ones based on Ionic or React Native.&lt;/p&gt;
&lt;p&gt;Let us look at the underlying frameworks for this post. &lt;strong&gt;If you are conversant with React Native and Firebase, skip these sections and go to the code segment of the post.&lt;/strong&gt;&lt;/p&gt;
&lt;h3&gt;What is React-Native&lt;/h3&gt;
&lt;p&gt;Before we move into the blog, let’s first clarify what framework we are using. We are using React Native, which is one among many hybrid app frameworks available. The closest rivals of React Native are Flutter and Ionic.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;TLDR;&lt;/strong&gt; — React Native (RN) apps are more “native” than web-view apps made by Cordova / Ionic. React Native crates actual Java and Swift codes for apps, unlike the web-view apps which essentially run in a … web-view.&lt;/p&gt;
&lt;p&gt;React Native is a JavaScript framework for writing natively rendering mobile applications. It’ is based on React, Facebook’s JavaScript library for building user interfaces, but instead of targeting the browser, it targets mobile platforms. Because most of the code you write can be shared between platforms, React Native makes it easy to simultaneously develop for both Android and iOS.&lt;/p&gt;
&lt;p&gt;React Native applications render using real mobile UI components, &lt;em&gt;not&lt;/em&gt; web-views, and will look and feel like any other native mobile application. React Native also exposes JavaScript interfaces for platform APIs, so your React Native apps can access platform features like the phone camera, or the user’s location. &lt;a href="http://bit.ly/1YipO7A" rel="noopener nofollow noreferrer"&gt;Facebook&lt;/a&gt;, &lt;a href="http://bit.ly/1PPEiZH" rel="noopener nofollow noreferrer"&gt;Palantir&lt;/a&gt;, &lt;a href="http://bit.ly/1PPEjNg" rel="noopener nofollow noreferrer"&gt;TaskRabbit&lt;/a&gt; etc are already using it in production for user-facing applications.&lt;/p&gt;
&lt;h3&gt;What is Firebase&lt;/h3&gt;
&lt;p&gt;If you don’t know much about Firebase … you need to catch up with latest tech news. Firebase is the popular stuff in the market today. One can use Firebase to create quick mobile app back-ends, with a ton of built-in and ready-to-integrate features.&lt;/p&gt;
&lt;p&gt;Some of the quick integrations available with Firebase are&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Email Authentication&lt;/li&gt;
&lt;li&gt;Social logins&lt;/li&gt;
&lt;li&gt;Real-time database&lt;/li&gt;
&lt;li&gt;Analytics&lt;/li&gt;
&lt;li&gt;Crashlytics&lt;/li&gt;
&lt;li&gt;Push notifications&lt;/li&gt;
&lt;li&gt;In-app messages&lt;/li&gt;
&lt;li&gt;Remote config&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;and much more. Firebase is quickly growing to become the most popular mobile app back-end platform.&lt;/p&gt;
&lt;h3&gt;So, why use AdMob with Firebase ?&lt;/h3&gt;
&lt;p&gt;Umm, well it’s not really necessary to use Firebase for AdMob. You can integrate AdMob in your app independent of Firebase. I am using Firebase connected AdMob for two reasons&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;I have been using Invertase React Native Firebase plugin for quite some time. They have great documentations and so, I have trust in their products. Their AdMob dependency, in-turn, depends on React-Native Firebase. Hence.&lt;/li&gt;
&lt;li&gt;With Firebase and AdMob connected, you can view great insights about your AdMob campaign. For explanation refer to the video &lt;a href="https://youtu.be/EPKmYheOmiw" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;As an alternative, you can use other React-Native AdMob dependencies for showing ads in your React Native app. I will probably cover one of those in my blogs later.&lt;/p&gt;
&lt;p&gt;Enough of story-telling, let’s dive into — how to implement AdMob in React Native apps&lt;/p&gt;
&lt;h3&gt;Post structure&lt;/h3&gt;
&lt;p&gt;We will go in a step-by-step manner to explore the AdMob feature implementation. This is my break-down of the blog&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;STEPS&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Create a Firebase project and get required information&lt;/li&gt;
&lt;li&gt;Create a simple React Native app&lt;/li&gt;
&lt;li&gt;Setup your AdMob account&lt;/li&gt;
&lt;li&gt;Setup AdMob dependency&lt;/li&gt;
&lt;li&gt;Implement different types of Ads in your RN App&lt;/li&gt;
&lt;li&gt;Build the app on iOS device and test&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;So let’s dive right in!&lt;/p&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AERffcqfeSC19qC5l50L94w.gif"&gt;&lt;br&gt;I made you laugh … didn’t I ? 😆&lt;h3&gt;Step 1 — Create Firebase project&lt;/h3&gt;
&lt;p&gt;For Admob implementation, all we need from Firebase project is — &lt;code&gt;GoogleService-Info.plist&lt;/code&gt; file (for iOS) or &lt;code&gt;google-services.json&lt;/code&gt; file for Android&lt;/p&gt;
&lt;p&gt;Follow these steps&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Login into &lt;a href="http://console.firebase.google.com" rel="noopener noreferrer"&gt;Firebase Console&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Create Firebase Project&lt;/li&gt;
&lt;li&gt;Add an iOS app (or an Android app), register the Bundle ID, and give your app a name&lt;/li&gt;
&lt;li&gt;Download &lt;code&gt;GoogleService-Info.plist&lt;/code&gt; . We’ll need this file later in the project&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Follow &lt;a href="https://youtu.be/6juww5Lmvgo" rel="noopener noreferrer"&gt;this&lt;/a&gt; video for the above steps if you need.&lt;/p&gt;
&lt;h3&gt;Step 2 — Create basic React Native app&lt;/h3&gt;
&lt;p&gt;First, make sure you have all pre-requisites to create a react-native app as per the &lt;a href="https://facebook.github.io/react-native/docs/getting-started.html" rel="noopener nofollow noreferrer"&gt;official documentation&lt;/a&gt;.&lt;/p&gt;
&lt;blockquote&gt;&lt;strong&gt;&lt;em&gt;At the time of this post, I have React-Native version 0.62 &amp;amp; node 12.14.0&lt;/em&gt;&lt;/strong&gt;&lt;/blockquote&gt;
&lt;p&gt;Create a blank react-native app&lt;/p&gt;
&lt;pre&gt;$ react-native init AdMob&lt;/pre&gt;
&lt;p&gt;This will create a basic React-native app which you can run in a device or simulator. (either Android or iOS)&lt;/p&gt;
&lt;p&gt;We’ll create a simple page with few buttons that will trigger Ads. While banner ad generally doesn’t need a trigger, interstitial ads and reward ads need a trigger. These triggers are generally completion of a level in a game app etc. My basic UI for the ad page looks like this&lt;/p&gt;
&lt;img alt="Basic UI for AdMob implementation in React Native — iOS" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2A8m4Hiq2RE02Q3oAEDUG2uw.png"&gt;&lt;br&gt;Basic UI for AdMob implementation in React Native — iOS&lt;h3&gt;Step 3— Setup your Admob account&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Signup then Sign in to your AdMob account at &lt;a href="https://apps.admob.com/?utm_source=internal%26utm_medium=et%26utm_campaign=helpcentrecontextualopt%26utm_term=http://goo.gl/6Xkfcf%26subid=ww-ww-et-amhelpv4" rel="noopener noreferrer"&gt;&lt;/a&gt;&lt;a href="https://apps.admob.com" rel="noopener noreferrer"&gt;https://apps.admob.com&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Apps&lt;/strong&gt; in the sidebar.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Add app&lt;/strong&gt; to add a new app or click &lt;strong&gt;View all apps&lt;/strong&gt; to search a list of all of the apps you’ve added to AdMob.&lt;/li&gt;
&lt;li&gt;In the &lt;strong&gt;App Settings &lt;/strong&gt;options, you can see your &lt;strong&gt;App ID&lt;/strong&gt;. This is the ID you will need to connect your app to Google AdMob in your React Native app.&lt;/li&gt;
&lt;/ul&gt;
&lt;img alt="Note down your App ID from App Setting in Google AdMob" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AJoDnyDkki68npDr77EitSw.png"&gt;&lt;br&gt;Note down your App ID from App Setting in Google AdMob&lt;ul&gt;&lt;li&gt;In the &lt;strong&gt;Ad Units &lt;/strong&gt;section, you can add multiple types of Ad units. For more details on adding Ad Units, check out the following detailed step-by-step instructions for&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;— &lt;a href="https://support.google.com/admob/answer/7311346?hl=en" rel="noopener noreferrer"&gt;Banner Ads&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;—&lt;a href="https://support.google.com/admob/answer/7311435?hl=en%26ref_topic=7382891" rel="noopener noreferrer"&gt; Interstitial Ads&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;— &lt;a href="https://support.google.com/admob/answer/7311747?hl=en%26ref_topic=7382891" rel="noopener noreferrer"&gt;Reward Ads&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;AdMob has a ton of other settings for how, when and where your ads should show up, but all that for later. In this post, we’ll limit the discussion to &lt;strong&gt;“How to display basic ad units in a React Native app”&lt;/strong&gt;&lt;/p&gt;
&lt;h3&gt;Step 4 — Install AdMob dependency and implement&lt;/h3&gt;
&lt;p&gt;For this post, as I explained earlier, we are using AdMob with Firebase. The dependency we are using for this is &lt;a href="https://invertase.io/oss/react-native-firebase/" rel="noopener noreferrer"&gt;React-Native Firebase&lt;/a&gt;. This main dependency contains several service modules, AdMob is one of them.&lt;/p&gt;
&lt;h4&gt;4.1 Install React-Native Firebase for iOS&lt;/h4&gt;
&lt;p&gt;In your existing React Native app, add the main dependency using&lt;/p&gt;
&lt;pre&gt;&lt;strong&gt;$ yarn add @react-native-firebase/app&lt;br&gt;&lt;/strong&gt;&lt;code&gt;# For iOS&lt;/code&gt; &lt;br&gt;&lt;code&gt;&lt;strong&gt;cd ios &amp;amp;&amp;amp; pod install&lt;/strong&gt;&lt;/code&gt;&lt;strong&gt; &lt;/strong&gt;&lt;/pre&gt;
&lt;h4&gt;4.2 Import Firebase config file in Xcode&lt;/h4&gt;
&lt;p&gt;Next, open the project (&lt;code&gt;/ios/{projectName}.xcworkspace&lt;/code&gt;) in Xcode editor. Add your &lt;code&gt;GoogleService-Info.plist&lt;/code&gt; file to the project by right clicking on the project name and “Add files” to the project, as demonstrated below. Ensure the ‘Copy items if needed’ checkbox is enabled.&lt;/p&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AgGBtQtlVgvtETCZbiXxg4g.png"&gt;&lt;h4&gt;4.3 Initialize Firebase in Xcode&lt;/h4&gt;
&lt;p&gt;Open the AppDelegate file within your project &lt;code&gt;/ios/{projectName}/AppDelegate.m&lt;/code&gt;. At the top of the file import the Firebase module:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#import &amp;lt;Firebase.h&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Within the &lt;code&gt;didFinishLaunchingWithOptions&lt;/code&gt; method, add the &lt;code&gt;configure&lt;/code&gt; method:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {&lt;br&gt;&lt;strong&gt;if ([FIRApp defaultApp] == nil) {&lt;br&gt;  [FIRApp configure];&lt;br&gt;}&lt;/strong&gt;&lt;/code&gt;&lt;strong&gt; &lt;/strong&gt;&lt;br&gt;....&lt;/pre&gt;
&lt;p&gt;Rebuild your project by running commands&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ cd ios/&lt;br&gt;$ pod install --repo-update&lt;/code&gt;&lt;/pre&gt;
&lt;h4&gt;4.4 Install AdMob dependency&lt;/h4&gt;
&lt;p&gt;Install the module using&lt;/p&gt;
&lt;pre&gt;$ yarn add @react-native-firebase/admob&lt;br&gt;&lt;code&gt;# For iOS&lt;br&gt;cd ios/ &amp;amp;&amp;amp; pod install&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Once completed, re-run your project in iOS device using&lt;/p&gt;
&lt;pre&gt;$ react-native run-ios&lt;/pre&gt;
&lt;p&gt;or run using Xcode.&lt;/p&gt;
&lt;p&gt;The above steps often lead to some small mistake. If the app doesn’t start up fine, check these&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Clean your project and build again&lt;/li&gt;
&lt;li&gt;Make sure you have latest CocoaPods version&lt;/li&gt;
&lt;li&gt;Make sure your PodFile mentions the dependency as&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;pod ‘RNFBAdMob’, :path =&amp;gt; ‘../node_modules/@react-native-firebase/admob’&lt;/pre&gt;
&lt;h4&gt;4.5 &lt;strong&gt;Adding your AdMob App ID&lt;/strong&gt;
&lt;/h4&gt;
&lt;p&gt;The AdMob module needs to be hooked up to your own Google AdMob account using the App ID we noted down in &lt;strong&gt;Step 3&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Add the ID to your root level &lt;code&gt;firebase.json&lt;/code&gt; file (create one) under the &lt;code&gt;react-native&lt;/code&gt; object like following&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;{&lt;br&gt;"react-native": {&lt;br&gt;  "admob_android_app_id": "ca-app-pub-xxxxxxxx~xxxxxxxx",&lt;br&gt;  "admob_ios_app_id": "ca-app-pub-xxxxxxxx~xxxxxxxx"&lt;/code&gt; &lt;br&gt; &lt;code&gt;}&lt;br&gt;}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Rebuild your application for the changes to take effect.&lt;/p&gt;
&lt;h3&gt;Step 5 — Implement different types of Ads in the app&lt;/h3&gt;
&lt;p&gt;Once everything is setup, let us implement different types of Ads in the app.&lt;/p&gt;
&lt;h4&gt;Banner Ad&lt;/h4&gt;
&lt;p&gt;Banner ads are implemented as a &lt;code&gt;&amp;lt;BannerAd&amp;gt;&lt;/code&gt; tag itself. You can place it in your React Native app just like any other tag. Make sure you import the dependency&lt;/p&gt;
&lt;pre&gt;import { TestIds, BannerAd, BannerAdSize} from '@react-native-firebase/admob';&lt;/pre&gt;
&lt;p&gt;I imported the Banner ad at the bottom of the page, in a &lt;code&gt;View&lt;/code&gt; positioned &lt;code&gt;absolute&lt;/code&gt; as follows&lt;/p&gt;
&lt;pre&gt;&amp;lt;&lt;strong&gt;BannerAd&lt;/strong&gt;&lt;br&gt; unitId={TestIds.BANNER}&lt;br&gt; size={BannerAdSize.SMART_BANNER}&lt;br&gt; requestOptions=&lt;code&gt;{{&amp;lt;br&amp;gt; requestNonPersonalizedAdsOnly: true,}}&lt;/code&gt;&lt;br&gt; onAdLoaded={() =&amp;gt; {&lt;br&gt; console.log('Advert loaded');}}&lt;br&gt; onAdFailedToLoad={(error) =&amp;gt; {&lt;br&gt; console.error('Advert failed to load: ', error);}}&lt;br&gt;/&amp;gt;&lt;/pre&gt;
&lt;p&gt;Here, I have used a test ID &lt;code&gt;TestIds.BANNER&lt;/code&gt; . This uses a default test ID provided by AdMob. You will replace this with your production Ad unit ID when you release the app&lt;/p&gt;
&lt;blockquote&gt;&lt;strong&gt;DO NOT use the test ID in your production app, and DO NOT use your production Ad Unit ID while developing the app&lt;/strong&gt;&lt;/blockquote&gt;
&lt;p&gt;The resulting ad looks like this&lt;/p&gt;
&lt;img alt="AdMob Banner Ad in React Native app" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AD7RwqLBPwxWjaDlgDoSfaQ.png"&gt;&lt;br&gt;AdMob Banner Ad in React Native app&lt;h4&gt;Interstitial Ad&lt;/h4&gt;
&lt;p&gt;Interstitial Ads work on a trigger. Because these are full page ads, they are not always visible as Banner Ads.&lt;/p&gt;
&lt;p&gt;To implement interstitial ads, import the required dependency and follow the code below&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
Interstitial Admob Ads in react native app
&lt;p&gt;Again, &lt;code&gt;TestIds.INTERSTITIAL&lt;/code&gt; is a test ID. Replace it with production Ad ID when releasing the app.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;.load()&lt;/code&gt; method loads the ad. This ad takes some time in loading. That is why &lt;code&gt;.show()&lt;/code&gt; is called on the &lt;code&gt;LOADED&lt;/code&gt; event. If you call the &lt;code&gt;.show()&lt;/code&gt; method immediately after &lt;code&gt;.load()&lt;/code&gt; the app with crash.&lt;/p&gt;
&lt;p&gt;Finally &lt;code&gt;.show()&lt;/code&gt; shows the ad on full screen, like following&lt;/p&gt;
&lt;img alt="Admob interstitial ad in React Native app" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AUWEB_sg7FfKntt8d5xmfZQ.png"&gt;&lt;br&gt;Admob interstitial ad in React Native app&lt;h4&gt;Reward Ad&lt;/h4&gt;
&lt;p&gt;Again, reward Ads are similar to interstitial ads in the trigger mechanism. To implement, import the required dependency and follow the code below&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;p&gt;Again, &lt;code&gt;TestIds.REWARDED&lt;/code&gt; is a test ID. Replace it with production Ad ID when releasing the app.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;.load()&lt;/code&gt; method loads the ad. This ad takes some time in loading. That is why &lt;code&gt;.show()&lt;/code&gt; is called on the &lt;code&gt;LOADED&lt;/code&gt; event. If you call the &lt;code&gt;.show()&lt;/code&gt; method immediately after &lt;code&gt;.load()&lt;/code&gt; the app with crash.&lt;/p&gt;
&lt;p&gt;Reward Ads also have a &lt;code&gt;.EARNED_REWARD&lt;/code&gt; event, which is called when the reward ad throws a callback (generally when user has seen the required length of the ad). After this callback, you can provide user with the reward.&lt;/p&gt;
&lt;p&gt;Finally &lt;code&gt;.show()&lt;/code&gt; shows the ad on full screen. The reward ad will look like this&lt;/p&gt;
&lt;img alt="Admob reward ads in React native app" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2A96WzM5SBJ8a4GDQQCQte-g.gif"&gt;&lt;br&gt;Admob reward ads in React native app&lt;h3&gt;Step 6: Testing the app on a device&lt;/h3&gt;
&lt;p&gt;To run the iOS app, you should specify simulator&lt;/p&gt;
&lt;pre&gt;$ react-native run-ios --simulator=”iPhone X”&lt;/pre&gt;
&lt;p&gt;To run Android app, you should start emulator first (or connect a device), either via Android Studio or &lt;code&gt;adb&lt;/code&gt; , then call&lt;/p&gt;
&lt;pre&gt;$ react-native run-android&lt;/pre&gt;
&lt;p&gt;Tada ! You have learnt how to implement AdMob ads in your React Native app. 🎉&lt;/p&gt;
&lt;h3&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;In this blog, we learned how to implement Google AdMob functionality in React Native app. AdMob functionality is a must for an app where user wants to earn some revenue from ad clicks. This comes in handy when your app has a large number of users, and you do not charge users for anything in the app. So ads become your direct revenue source. You can also combine the interstitial ads and rewards ads with in-app rewards like a level up in a game, extra lives etc.&lt;/p&gt;
&lt;blockquote&gt;
&lt;strong&gt;&lt;em&gt;Complete source code of this tutorial is available in the &lt;/em&gt;&lt;/strong&gt;&lt;a href="https://github.com/rathoreabhijeet/react-native-admob" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;react-native-admob&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt;
&lt;/blockquote&gt;
&lt;h3&gt;Next Steps&lt;/h3&gt;
&lt;p&gt;Now that you have learnt about setting up AdMob in React Native apps, here are some other topics you can look into&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Firebase — &lt;a href="https://enappd.com/blog/intergrate-firebase-in-react-native-app/73" rel="noopener nofollow noreferrer"&gt;Integrate Firebase&lt;/a&gt; | &lt;a href="https://enappd.com/blog/firebase-analytics-in-react-native-app/101" rel="noopener noreferrer"&gt;Analytics&lt;/a&gt; | &lt;a href="https://enappd.com/blog/react-native-firebase-crud-image-upload-and-phone-authentication/86" rel="noopener nofollow noreferrer"&gt;Push notifications&lt;/a&gt; | &lt;a href="https://enappd.com/blog/react-native-firebase-crud-image-upload-and-phone-authentication/86" rel="noopener nofollow noreferrer"&gt;Firebase CRUD&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;How To in React Native — &lt;a href="https://enappd.com/blog/geolocation-geocoding-react-native-apps/84" rel="noopener nofollow noreferrer"&gt;Geolocation&lt;/a&gt; | &lt;a href="https://enappd.com/blog/react-native-life-cycle-hooks/79" rel="noopener nofollow noreferrer"&gt;Life cycle hooks&lt;/a&gt; | &lt;a href="https://enappd.com/blog/pick-images-from-camera-gallery-in-react-native-app/78" rel="noopener nofollow noreferrer"&gt;Image Picker&lt;/a&gt; | &lt;a href="https://enappd.com/blog/redux-in-react-native-app/92" rel="noopener nofollow noreferrer"&gt;Redux implementation&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-make-api-calls-in-react-native-apps/125" rel="noopener noreferrer"&gt;Make API calls&lt;/a&gt; | &lt;a href="https://enappd.com/blog/navigations-in-react-native-app/124" rel="noopener noreferrer"&gt;Navigation&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-translate-in-react-native-app-globalization-internationalization-and-text-to-speech/120" rel="noopener noreferrer"&gt;Translation&lt;/a&gt; | &lt;a href="https://enappd.com/blog/react-native-qr-code-scanning-using-react-native-camera/117" rel="noopener noreferrer"&gt;Barcode &amp;amp; QR code scan&lt;/a&gt; | &lt;a href="https://enappd.com/blog/send-read-and-delete-sms-in-react-native/107" rel="noopener noreferrer"&gt;Send &amp;amp; Read SMS&lt;/a&gt; | &lt;a href="https://enappd.com/blog/google-vision-with-react-native/96" rel="noopener noreferrer"&gt;Google Vision&lt;/a&gt; | &lt;a href="https://enappd.com/blog/refreshcontrol-pull-to-refresh-in-react-native-apps/130" rel="noopener noreferrer"&gt;Pull to Refresh&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Payments — &lt;a href="https://enappd.com/blog/implement-apple-pay-in-react-native-apps/93" rel="noopener noreferrer"&gt;Apple Pay&lt;/a&gt; | &lt;a href="https://enappd.com/blog/stripe-integration-in-react-native-apps-using-firebase/108" rel="noopener noreferrer"&gt;Stripe payments&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Authentication — &lt;a href="https://enappd.com/blog/google-login-in-react-native-android-apps-with-firebase/90" rel="noopener nofollow noreferrer"&gt;Google Login&lt;/a&gt;| &lt;a href="https://enappd.com/blog/facebook-login-in-react-native-apps/89" rel="noopener nofollow noreferrer"&gt;Facebook login&lt;/a&gt; | &lt;a href="https://enappd.com/blog/react-native-firebase-crud-image-upload-and-phone-authentication/86" rel="noopener nofollow noreferrer"&gt;Phone Auth&lt;/a&gt; | &lt;a href="https://enappd.com/blog/twitter-login-in-react-native-apps-using-firebase/95" rel="noopener noreferrer"&gt;Twitter login&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://enappd.com/blog/how-to-make-stories-ui-like-instagram-and-whatsapp-in-react-native/123" rel="noopener noreferrer"&gt;Create Instagram / Whatsapp Story Feature in React Native&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://enappd.com/blog/react-native-life-cycle-hooks/79" rel="noopener nofollow noreferrer"&gt;React Native life cycle hooks&lt;/a&gt; | &lt;a href="https://enappd.com/blog/redux-in-react-native-app/92" rel="noopener noreferrer"&gt;Implement Redux&lt;/a&gt; | &lt;a href="https://enappd.com/blog/async-actions-with-redux-thunk-middleware-in-react-native-apps-1/100" rel="noopener noreferrer"&gt;Async actions with Redux&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://enappd.com/blog/guide-on-react-native-full-app/53" rel="noopener nofollow noreferrer"&gt;Create Awesome Apps in React Native&lt;/a&gt; using Full App&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you need a base to start your next React Native app, you can make your next awesome app using &lt;a href="https://store.enappd.com/product/react-native-full-app/" rel="noopener nofollow noreferrer"&gt;React Native Full App&lt;/a&gt;&lt;/p&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2A50h94UU2H2pkisje.jpeg"&gt;

</description>
      <category>reactnative</category>
      <category>admob</category>
      <category>firebase</category>
    </item>
    <item>
      <title>Implement Local Notifications in Ionic 5 with Capacitor</title>
      <dc:creator>Abhijeet Rathore</dc:creator>
      <pubDate>Tue, 14 Apr 2020 02:36:24 +0000</pubDate>
      <link>https://forem.com/enappd/implement-local-notifications-in-ionic-5-with-capacitor-2c1a</link>
      <guid>https://forem.com/enappd/implement-local-notifications-in-ionic-5-with-capacitor-2c1a</guid>
      <description>
&lt;blockquote&gt;
&lt;strong&gt;For an Ionic 4 Cordova implementation of Local Notifications, check out &lt;/strong&gt;&lt;a href="https://enappd.com/blog/local-notifications-in-ionic-4/69" rel="noopener noreferrer"&gt;&lt;strong&gt;this blog&lt;/strong&gt;&lt;/a&gt;
&lt;/blockquote&gt;
&lt;p&gt;Ionic 5 is here ! And so is Capacitor 2.0 (beta). In this post you are going to learn how to implement local notifications in Ionic 5 app with Capacitor. We will see a variety of notification types that can be generated using Local Notifications. We will use a simple Cordova plugin, that works for Capacitor as well, and test the functionality on an Android and iOS app.&lt;/p&gt;
&lt;blockquote&gt;
&lt;strong&gt;Complete code of this blog post can be found at this github repo —&lt;/strong&gt;&lt;a href="https://github.com/enappd/ionic-5-capacitor-local-notification" rel="noopener noreferrer"&gt;&lt;strong&gt; ionic-5-local-notifications&lt;/strong&gt;&lt;/a&gt;
&lt;/blockquote&gt;
&lt;h3&gt;What is Local Notification ?&lt;/h3&gt;
&lt;p&gt;We have all heard of notifications, and push notifications mostly. These are the notifications app servers send to apps for regular reminders. For example, a chat app server sends notification to user to update of a latest message. These notifications are received in closed app, minimized app or open app.&lt;/p&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2A9_TQhgUm16ISGuqQkAcoSQ.gif"&gt;&lt;br&gt;`Push notifications ….. necessary evil&lt;p&gt;Push notifications cause burden on Server, as well as, cost you money if you are using a service like &lt;a href="https://onesignal.com" rel="noopener noreferrer"&gt;OneSignal&lt;/a&gt; etc. Hence, for each action or reminder, you might not want the server to send push notifications to all users. Especially if you have millions of users.&lt;/p&gt;
&lt;p&gt;This is where &lt;strong&gt;Local Notifications&lt;/strong&gt; come in handy. These look and feel exactly like push notifications, but are not sent from server. Instead, they are generated locally on your device. E.g. If you want an app to remind you of your tasks at a certain time of the day, it makes sense that the app does so using the in-built clock or timer in the device. The app then sends you Local Notification, which looks same as a push.&lt;/p&gt;
&lt;blockquote&gt;You don’t feel the difference between Local and Push notification, and the server saves a lot of overhead.&lt;/blockquote&gt;
&lt;p&gt;In this post, we will learn how to implement Local notifications features in Ionic 5apps. First, let’s see what Ionic 5 is all about.&lt;/p&gt;
&lt;h3&gt;What is Ionic?&lt;/h3&gt;
&lt;p&gt;You probably already know about Ionic, but I’m putting it here just for the sake of beginners. &lt;strong&gt;Ionic&lt;/strong&gt; is a complete open-source SDK for hybrid mobile app development created by &lt;a href="https://medium.com/u/a76fa51de1ba?source=post_page---------------------------" rel="noopener noreferrer"&gt;Max Lynch&lt;/a&gt;, &lt;a href="https://medium.com/u/14b1be5c1354?source=post_page---------------------------" rel="noopener noreferrer"&gt;Ben Sperry&lt;/a&gt; and Adam Bradley of Drifty Co. in 2013. Ionic provides tools and services for developing hybrid mobile apps using Web technologies like CSS, HTML5, and Sass. Apps can be built with these Web technologies and then distributed through native app stores to be installed on devices by leveraging Cordova.&lt;/p&gt;
&lt;p&gt;So, in other words — If you create Native apps in Android, you code in Java. If you create Native apps in iOS, you code in Obj-C or Swift. Both of these are powerful but complex languages. &lt;strong&gt;With Cordova (and Ionic) you can write a single piece of code for your app that can run on both iOS and Android &lt;/strong&gt;(and windows!), that too with the simplicity of HTML, CSS, and JS.&lt;/p&gt;
&lt;p&gt;Ionic’s latest version — Ionic 5, was released in March 2020, and is what we are using for this blog post.&lt;/p&gt;
&lt;h3&gt;Capacitor — How is it different from Cordova ?&lt;/h3&gt;
&lt;p&gt;Cordova helps build Ionic web app into a mobile device installable app. But there are some limitations of Cordova, which Capacitor tries to overcome with a new App workflow.&lt;/p&gt;
&lt;p&gt;Here are the differences between Cordova and Capacitor&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Capacitor considers each platform project a &lt;em&gt;source asset&lt;/em&gt; instead of a &lt;em&gt;build time asset&lt;/em&gt;. That means, Capacitor wants you to keep the platform source code in the repository, unlike Cordova which always assumes that you will generate the platform code on build time&lt;/li&gt;
&lt;li&gt;Because of the above, Capacitor does not use &lt;code&gt;config.xml&lt;/code&gt; or a similar custom configuration for platform settings. Instead, configuration changes are made by editing &lt;code&gt;AndroidManifest.xml&lt;/code&gt; for Android and &lt;code&gt;Info.plist&lt;/code&gt; for Xcode&lt;/li&gt;
&lt;li&gt;Capacitor does not “run on device” or emulate through the command line. Instead, such operations occur through the platform-specific IDE. So you cannot run an Ionic-capacitor app using a command like &lt;code&gt;ionic run ios&lt;/code&gt; . You will have to run iOS apps using Xcode, and Android apps using Android studio&lt;/li&gt;
&lt;li&gt;Since platform code is not a &lt;em&gt;source asset, &lt;/em&gt;you can directly change the native code using Xcode or Android Studio. This give more flexibility to developers&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;In essence, Capacitor is like a fresh, more flexible version of Corodva.&lt;/p&gt;
&lt;h3&gt;Plugins&lt;/h3&gt;
&lt;p&gt;Cordova and &lt;a href="https://ionicframework.com/docs/native" rel="noopener nofollow noreferrer"&gt;Ionic Native&lt;/a&gt; plugins can be used in Capacitor environment. However, there are certain Cordova plugins which are known to be &lt;a href="https://capacitor.ionicframework.com/docs/cordova/known-incompatible-plugins/" rel="noopener nofollow noreferrer"&gt;incompatible with Capacitor.&lt;/a&gt; For Local Notification functionality, we’ll use the &lt;a href="https://github.com/katzer/cordova-plugin-local-notifications" rel="noopener noreferrer"&gt;cordova-plugin-local-notifications&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;Structure of the post&lt;/h3&gt;
&lt;p&gt;I will go ahead in step-by-step fashion so you can follow easily&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Create a basic Ionic 5 Capacitor app&lt;/li&gt;
&lt;li&gt;Install Local Notification plugin and make imports&lt;/li&gt;
&lt;li&gt;Implement your first Local Notification, use data from notification&lt;/li&gt;
&lt;li&gt;Build your app on iOS and Android and test&lt;/li&gt;
&lt;li&gt;Implement various types of Local Notifications&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Let’s start with creating a simple Ionic 5 app&lt;/p&gt;
&lt;h3&gt;Step 1 — Create a basic Ionic 5 app&lt;/h3&gt;
&lt;p&gt;To create a basic Ionic 5 Capacitor app, follow these steps&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Make sure you have node installed in the system (I used V10.15.3 at the time of this blog post, but latest stable version is 12.x)&lt;/li&gt;
&lt;li&gt;Install &lt;strong&gt;ionic cli &lt;/strong&gt;using &lt;strong&gt;npm&lt;/strong&gt; (my Ionic CLI version is 5.3.0 and Ionic Framework is V5.0.5)&lt;/li&gt;
&lt;li&gt;Create an Ionic app using &lt;code&gt;ionic start&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can create a &lt;code&gt;blank&lt;/code&gt; starter for the sake of this tutorial. On running &lt;code&gt;ionic start ionic-5-local-notifications blank —-capacitor&lt;/code&gt; , node modules will be installed. Once the installation is done, run your app on browser using&lt;/p&gt;
&lt;pre&gt;$ ionic serve&lt;/pre&gt;
&lt;p&gt;The app will launch on browser. You can go to &lt;strong&gt;Inspect → Device Mode&lt;/strong&gt; to see the code in a mobile layout.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;--capacitor&lt;/code&gt; flag attaches Capacitor to your Ionic app automatically. If you forget to do it while creating the app, you can do it later by running&lt;/p&gt;
&lt;pre&gt;$ ionic integrations enable capacitor&lt;/pre&gt;
&lt;p&gt;You can create a basic layout for triggering Local Notifications. All the real action will happen when we build the app for device (iOS).&lt;/p&gt;
&lt;blockquote&gt;
&lt;strong&gt;The layout here is taken from &lt;/strong&gt;&lt;a href="https://store.enappd.com/product/ionic-full-app/" rel="noopener noreferrer"&gt;&lt;strong&gt;Ionic 5 Full App&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt; from Enappd &lt;em&gt;🙏&lt;/em&gt;&lt;/strong&gt;
&lt;/blockquote&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AE75ByHlGcKDn5ZUjM4z5Dw.png"&gt;&lt;p&gt;Next we’ll add the Local Notifications plugin to our app.&lt;/p&gt;
&lt;h3&gt;Step 2 — Install Local Notification plugin and make imports&lt;/h3&gt;
&lt;p&gt;To implement Local Notifications you need to add &lt;code&gt;cordova-plugin-local-notifications&lt;/code&gt; plugin to the app. Add the plugin using&lt;/p&gt;
&lt;pre&gt;$ ionic cordova plugin add cordova-plugin-local-notification &lt;br&gt;$ npm install @ionic-native/local-notifications&lt;/pre&gt;
&lt;p&gt;This will install the plugin in your app. Next, import the plugin in &lt;code&gt;app.module.ts&lt;/code&gt; and in the pages you want to use it.&lt;/p&gt;
&lt;pre&gt;import { LocalNotifications} from '@ionic-native/local-notifications/ngx'&lt;/pre&gt;
&lt;p&gt;Also, include &lt;code&gt;LocalNotifications&lt;/code&gt; in &lt;code&gt;@ngModule&lt;/code&gt; &lt;strong&gt;providers&lt;/strong&gt; list.&lt;/p&gt;
&lt;pre&gt;@NgModule({&lt;br&gt;....,&lt;br&gt;providers: [&lt;br&gt;...,&lt;br&gt;LocalNotifications,&lt;br&gt;...],&lt;br&gt;})&lt;/pre&gt;
&lt;p&gt;Now you are ready to implement Local notifications in your Ionic 5 app.&lt;/p&gt;
&lt;h3&gt;Step 3 — Implement your first Local Notification&lt;/h3&gt;
&lt;p&gt;Local Notification implementation is very easy once you import the plugin correctly. Head to your &lt;code&gt;home.page.ts&lt;/code&gt; created with the app. Create a function to &lt;code&gt;schedule&lt;/code&gt; your first local notification like this&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;p&gt;Super easy, right ? This will create a local notification and it will appear in your device’s status bar as an icon. You can check the full notification in your device’s notification tray.&lt;/p&gt;
&lt;img alt="Local notification in Ionic 5 app — Android implementation" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AG5QHHU19lZ6qXYrhi8AklQ.gif"&gt;&lt;br&gt;Local notification in Ionic 5 app — Android implementation&lt;p&gt;Let’s dive deeper into the details of the notification object, and learn what all options are available&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;id&lt;/strong&gt; — ID of the notifications&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;title&lt;/strong&gt; — Title of the notification, shown in larger font. If no &lt;code&gt;title&lt;/code&gt; is provided, app’s name is shown as &lt;code&gt;title&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;text&lt;/strong&gt; — Message of the notification. Shown in smaller font. It can be of multiple lines as well. Can be an array of messages as well. We’ll see that in later section&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;sound&lt;/strong&gt; — location of sound file to be played with notification&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;data&lt;/strong&gt; — additional data you can send along with notification in JSON format&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;icon&lt;/strong&gt; — location or URL of icon shown with the notification&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;silent&lt;/strong&gt; — (boolean) whether notification should be silent or not&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;trigger&lt;/strong&gt; — custom trigger time of notification, can be given in various formats. We’ll see this in later section&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;attachments&lt;/strong&gt; — Attached images to be sent with notification&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;progressBar&lt;/strong&gt; — progress-bar options for Local notifications&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;group&lt;/strong&gt; — define the group name to group similar notifications together&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;summary&lt;/strong&gt; — summary of grouped notifications&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;smallIcon&lt;/strong&gt; — Small icon shown for group notifications or custom notifications&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;sticky&lt;/strong&gt; — whether the notification should be sticky or dismissible&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;autoClear&lt;/strong&gt; — If yes, make the notification automatically dismissed when the user touches it (Android only)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;lockscreen&lt;/strong&gt; — If set to &lt;code&gt;true&lt;/code&gt; the notification will be shown in its entirety on all lock-screens. If set to &lt;code&gt;false&lt;/code&gt; it will not be revealed on a secure lock-screen. (Android only)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;channel&lt;/strong&gt; — Specifies the channel the notification should be delivered on (Android only)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;foreground&lt;/strong&gt; — If the notification should show up on app’s foreground&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;timeoutAfter&lt;/strong&gt; — Specifies a duration in milliseconds after which this notification should be canceled, if it is not already canceled (Android only)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;launch&lt;/strong&gt; — Specifies whether a click on the notification causes the app to open in foreground&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;priority&lt;/strong&gt; — Integers between -2 and 2, whereas -2 is minimum and 2 is maximum priority&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;led&lt;/strong&gt; — to set LED options of the device. You can set &lt;code&gt;color&lt;/code&gt; , &lt;code&gt;on&lt;/code&gt; and &lt;code&gt;off&lt;/code&gt; properties&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;vibrate — &lt;/strong&gt;(boolean) — Whether notification should vibrate the device&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;color&lt;/strong&gt; — RGB value for the background color of the smallIcon (Android only)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;badge&lt;/strong&gt; — The number currently set as the badge of the app icon in Springboard (iOS) or at the right-hand side of the local notification (Android). Default: 0 (which means don’t show a number)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;… and few more options. That’s a lot !!!&lt;/p&gt;
&lt;p&gt;This is a really powerful and detailed plugin. You can make very good use of the plugin to supplement push notifications, and make your app interactive.&lt;/p&gt;
&lt;h3&gt;Step 4 — Build your app on Android and test&lt;/h3&gt;
&lt;p&gt;If you have carried out the above steps correctly, Android build should be a breeze.&lt;/p&gt;
&lt;p&gt;Run the following command to create Android platform&lt;/p&gt;
&lt;pre&gt;$ ionic cordova platform add android&lt;/pre&gt;
&lt;p&gt;Once platform is added, run the app on device (Make sure you have a device attached to the system).&lt;/p&gt;
&lt;pre&gt;$ ionic cordova run android&lt;/pre&gt;
&lt;p&gt;Once your app is up and running on the device, you can start testing all the functions. The GIF shown above is taken from a real Android device 😎&lt;/p&gt;
&lt;h3&gt;Step 5 — Implement various types of Local Notifications&lt;/h3&gt;
&lt;p&gt;The GIF in previous section might not have impressed you a lot. So let’s have a look at the variety of notifications and actions you can perform with this plugin&lt;/p&gt;
&lt;h4&gt;Local notification in foreground&lt;/h4&gt;
&lt;p&gt;Just add &lt;code&gt;foreground:true&lt;/code&gt; in notification trigger call, and your notification will show up in the foreground, just like Whatsapp !&lt;/p&gt;
&lt;img alt="Foreground Local Notification in Ionic 5 app — Android" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AGrZEhZcNsZ-vpFeDAq7WEg.gif"&gt;&lt;br&gt;Foreground Local Notification in Ionic 5 app — Android&lt;img alt="Foreground Local Notification in Ionic 5 app — iOS" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AuYmIQKs-ME2Y4O7Y1ZAK8A.png"&gt;&lt;br&gt;Foreground Local Notification in Ionic 5 app — iOS&lt;h4&gt;Get Data from Notification Click&lt;/h4&gt;
&lt;p&gt;As we saw earlier, the &lt;code&gt;data&lt;/code&gt; field of notification contains certain data in JSON format. We can extract this data using notification &lt;code&gt;events&lt;/code&gt; . For our purpose, we will use &lt;code&gt;click&lt;/code&gt; event.&lt;/p&gt;
&lt;p&gt;I will subscribe to the &lt;code&gt;click&lt;/code&gt; event before scheduling the notification. Then on clicking the notification, the &lt;code&gt;event&lt;/code&gt; will be triggered and we will get data in console. I will also show the data in an alert, just for demo. After the alert, we will unsubscribe from the listener. The complete code for this will be&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;p&gt;The sequence will look like this&lt;/p&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2Ao-u8MunpkgGo4In-W2bg4Q.gif"&gt;&lt;br&gt;Local notification with event triggered on click&lt;h4&gt;Multiple Notification at once&lt;/h4&gt;
&lt;p&gt;Just send multiple local notifications in an array inside the &lt;code&gt;schedule&lt;/code&gt;&lt;/p&gt;
&lt;img alt="Multiple Local notification at once — Ionic 5 Capacitor Android app" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2A3YZyyGBhfO8XiWMi19fpnQ.gif"&gt;&lt;br&gt;Multiple Local notification at once — Ionic 5 Capacitor Android app&lt;h4&gt;Delayed Local Notifications&lt;/h4&gt;
&lt;p&gt;You can also delay a notification or send it at a particular time. This way, you can even schedule notifications daily, weekly etc.&lt;/p&gt;
&lt;p&gt;E.g. For demo purpose, we’ll trigger a notification after 5000 ms of button click, but it will be taken as a date object. Just add the following option in notification options&lt;/p&gt;
&lt;pre&gt;trigger: { at: new Date(new Date().getTime() + 5000) },&lt;/pre&gt;
&lt;img alt="Notification shows up after 5 second — Ionic 5 Capacitor Android app" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AVqnwVIpdP0H1EwLm_iGRjw.gif"&gt;&lt;br&gt;Notification shows up after 5 second — Ionic 5 Capacitor Android app&lt;img alt="Notification shows up after 5 second — Ionic 5 Capacitor iOS app" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AgxAQSSTwgaDEfAAN3WAmFA.gif"&gt;&lt;br&gt;Notification shows up after 5 second — Ionic 5 Capacitor iOS app&lt;h4&gt;Local Notification with Progress Bar&lt;/h4&gt;
&lt;p&gt;You can also display a local notification with a progress bar. This is useful in cases like when you are performing a long background task.&lt;/p&gt;
&lt;p&gt;Just add following to notification options object (will show a 20% progress)&lt;/p&gt;
&lt;pre&gt;progressBar: { value: 20 }&lt;/pre&gt;
&lt;img alt="Local notification with progress bar — Ionic 5 Capacitor Android app" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2ALLxVErTzbfprbJ_GCwDR9A.gif"&gt;&lt;br&gt;Local notification with progress bar — Ionic 5 Capacitor Android app&lt;p&gt;iOS progress bar notification are not that impressive though&lt;/p&gt;
&lt;img alt="Local notification with progress bar — Ionic 5 Capacitor iOS app" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2ArAVnyjXNt-dV6fT-KUC7sw.png"&gt;&lt;br&gt;Local notification with progress bar — iOS&lt;h4&gt;Local Notification with multi-line message&lt;/h4&gt;
&lt;p&gt;You can make the notification message multi-line by adding new line characters. E.g.&lt;/p&gt;
&lt;pre&gt;text: '4:15 - 5:15 PM\nBig Conference Room'&lt;/pre&gt;
&lt;img alt="Local Notification with Multi-line message — Ionic 5 Capacitor Android app" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AQ4MrgHUZzYNl9Jjzrp8xXA.jpeg"&gt;&lt;br&gt;Local Notification with Multi-line message —Android&lt;img alt="Local Notification with Multi-line message — Ionic 5 Capacitor iOS app" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AjtIWdSCt_2KIHgOTjiE2IA.png"&gt;&lt;br&gt;Local Notification with Multi-line message —iOS&lt;h4&gt;Local Notification with Image and Action buttons&lt;/h4&gt;
&lt;p&gt;To add a large image, you can add this to the notification options (yes, kitten photo 😛&lt;/p&gt;
&lt;pre&gt;attachments: ['&lt;a href="http://placekitten.com/g/300/200'" rel="noopener noreferrer"&gt;http://placekitten.com/g/300/200'&lt;/a&gt;]&lt;/pre&gt;
&lt;p&gt;For action buttons, you can add this to the options&lt;/p&gt;
&lt;pre&gt;actions: [&lt;br&gt;{ id: 'yes', title: 'Yes' },&lt;br&gt;{ id: 'no', title: 'No' }&lt;br&gt;]&lt;/pre&gt;
&lt;p&gt;An action generally has the following structure —&lt;/p&gt;
&lt;pre&gt;id?: string;&lt;br&gt;title?: string;&lt;br&gt;foreground?: boolean;&lt;br&gt;launch?: boolean;&lt;br&gt;ui?: string;&lt;br&gt;needsAuth?: boolean;&lt;br&gt;icon?: string;&lt;br&gt;choices?: string[];&lt;br&gt;editable?: boolean;&lt;br&gt;submitTitle?: string;&lt;br&gt;type?: ILocalNotificationActionType;&lt;/pre&gt;
&lt;p&gt;This will create a notification with YES and NO buttons&lt;/p&gt;
&lt;img alt="Local Notification with Action buttons and Image — Ionic 5 Capacitor Android app" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2A5iymLC7NAwPQGvOzGIatGw.jpeg"&gt;&lt;br&gt;Local Notification with Action buttons and Image — Android&lt;p&gt;I was not able to get the photo in iOS, probably because of &lt;code&gt;http&lt;/code&gt;, though the action buttons do appear and work&lt;/p&gt;
&lt;img alt="Local Notification with Action buttons and Image — Ionic 5 Capacitor iOS app" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2ADf_mdCfZlIxgquy-2LD_Lw.png"&gt;&lt;br&gt;Local Notification with Action buttons — iOS&lt;h4&gt;Local Notifications with Input&lt;/h4&gt;
&lt;p&gt;You can also generate local notification accepting input text in notification tray itself. This comes in handy in chat applications. This is all you need to add to the notification options&lt;/p&gt;
&lt;pre&gt;actions: [{&lt;br&gt;id: 'reply',&lt;br&gt;type: ILocalNotificationActionType.INPUT,&lt;br&gt;title: 'Reply'&lt;br&gt;}]&lt;/pre&gt;
&lt;p&gt;To use &lt;code&gt;ILocalNotificationActionType&lt;/code&gt; , you will have to import it first in the page using&lt;/p&gt;
&lt;pre&gt;import { ILocalNotificationActionType } from '@ionic-native/local-notifications/ngx';&lt;/pre&gt;
&lt;p&gt;The result will look like this&lt;/p&gt;
&lt;img alt="Local notification with Input text- Ionic 5 Capacitor Android app" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2Ah_9yNSiCMTtczPByr7-zmQ.gif"&gt;&lt;br&gt;Local notification with Input text— Android&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2ANco8OgEptrpqr3vQvPefvQ.png"&gt;&lt;br&gt;Local notification with Input text —iOS&lt;h4&gt;Local Notifications with Grouping&lt;/h4&gt;
&lt;p&gt;At times, you receive many notifications from the same app. E.g. your email app, or chat app. You would like to group these together so as to not take a lot of space in notification tray. You can do this easily with local notifications using the following option&lt;/p&gt;
&lt;pre&gt;this.localNotifications.schedule([&lt;br&gt;{ id: 0, title: 'Design team meeting' },&lt;br&gt;{ id: 1, summary: '&lt;a href="mailto:me@gmail.com"&gt;me@gmail.com&lt;/a&gt;', group: 'email', groupSummary: true },&lt;br&gt;{ id: 2, title: 'Please take all my money', group: 'email' },&lt;br&gt;{ id: 3, title: 'A question regarding this plugin', group: 'email'},&lt;br&gt;{ id: 4, title: 'Wellcome back home', group: 'email' }&lt;br&gt;]);&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;group:'email'&lt;/code&gt; creates a group with similar notifications which have &lt;code&gt;group:email&lt;/code&gt; . Here’s how it looks&lt;/p&gt;
&lt;img alt="Local notification with grouped notifications — Ionic 5 Capacitor Android app" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2ADpbcOWxCo7ks_PVhTARw7Q.jpeg"&gt;&lt;br&gt;Local notification with grouped notifications —Android&lt;p&gt;You see the four emails grouped together, with one as a header. Other notification is shown as separate notification. Same for iOS&lt;/p&gt;
&lt;img alt="Local notification with grouped notifications — Ionic 5 Capacitor iOS app" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AEyNBHVWMYsAkc8qY7hyxGQ.png"&gt;&lt;br&gt;Local notification with grouped notifications —iOS&lt;p&gt;The group notification do come in annoyingly though in iOS 🙈&lt;/p&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AQerSt1tx0RacAOTKtyhMiw.gif"&gt;&lt;br&gt;Grouped notification in iOS come one after another&lt;h3&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;In this post, we learnt how to use Local Notification in Ionic 5 Capacitor apps to generate a lot of different types of notifications. These include action buttons, input text, images, multiple notifications, grouping etc. With local notifications, you can save a lot on server push notifications. Plus it gives you the ability to schedule regular notifications as well.&lt;/p&gt;
&lt;p&gt;We tested the apps on Android device and iOS simulator to validate the working. I think this is an awesome plugin, and you should definitely use it in your apps if possible.&lt;/p&gt;
&lt;blockquote&gt;
&lt;strong&gt;Complete code of this blog post can be found at this github repo — &lt;/strong&gt;&lt;a href="https://github.com/enappd/ionic-5-capacitor-local-notification" rel="noopener noreferrer"&gt;&lt;strong&gt;ionic-5-local-notifications&lt;/strong&gt;&lt;/a&gt;
&lt;/blockquote&gt;
&lt;h3&gt;Next Steps&lt;/h3&gt;
&lt;p&gt;Now that you have learned the implementation of Local Notifications in Ionic 5, you can also try following blogs. These are written for Ionic 4, but will work nicely for Ionic 5 as well.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Ionic 4 Payment Gateways — &lt;a href="https://enappd.com/blog/ionic-4-stripe-payment-integration-with-firebase-for-apps-and-pwa/17" rel="noopener noreferrer"&gt;Stripe&lt;/a&gt; | &lt;a href="https://enappd.com/blog/ionic-4-paypal-payment-integration-for-apps-and-pwa/16" rel="noopener noreferrer"&gt;PayPal&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-integrate-apple-pay-in-ionic-4-apps/21" rel="noopener noreferrer"&gt;Apple Pay&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-integrate-razorpay-in-ionic-4-apps-and-pwa/20" rel="noopener noreferrer"&gt;RazorPay&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Ionic 4 Charts with — &lt;a href="https://enappd.com/blog/ionic-4-charts-using-google-charts/66" rel="noopener noreferrer"&gt;Google Charts &lt;/a&gt;| &lt;a href="https://enappd.com/blog/adding-charts-in-ionic-4-apps-and-pwa-part-3/60" rel="noopener noreferrer"&gt;HighCharts&lt;/a&gt; | &lt;a href="https://enappd.com/blog/adding-charts-in-ionic-4-apps-and-pwa-part-2/54" rel="noopener noreferrer"&gt;d3.js&lt;/a&gt; | &lt;a href="https://enappd.com/blog/charts-in-ionic-4-apps-and-pwa-part-1/52" rel="noopener noreferrer"&gt;Chart.js&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Ionic 4 Social Logins — &lt;a href="https://enappd.com/blog/facebook-login-in-ionic-4-apps-using-firebase/25" rel="noopener noreferrer"&gt;Facebook&lt;/a&gt; | &lt;a href="https://enappd.com/blog/google-login-in-ionic-4-apps-using-firebase/39" rel="noopener noreferrer"&gt;Google&lt;/a&gt; | &lt;a href="https://enappd.com/blog/twitter-login-in-ionic-4-apps-using-firebase/24" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Ionic 4 Authentications — &lt;a href="https://enappd.com/blog/email-authentication-with-firebase-in-ionic-4/38" rel="noopener noreferrer"&gt;Via Email&lt;/a&gt; | &lt;a href="https://enappd.com/blog/firebase-anonymous-login-in-ionic-4/37" rel="noopener noreferrer"&gt;Anonymous&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Ionic 4 Features — &lt;a href="https://enappd.com/blog/using-geolocation-geocoding-and-reverse-geocoding-in-ionic-4/45" rel="noopener noreferrer"&gt;Geolocation&lt;/a&gt; | &lt;a href="https://enappd.com/blog/qr-code-scanning-and-optical-character-recognition-ocr-in-ionic-4/9" rel="noopener noreferrer"&gt;QR Code reader &lt;/a&gt;| &lt;a href="https://enappd.com/blog/best-fitness-plugins-for-ionic-4-how-to-use-pedometer/15" rel="noopener noreferrer"&gt;Pedometer&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Media in Ionic 4 — &lt;a href="https://enappd.com/blog/spotify-like-music-in-ionic-4-apps/48" rel="noopener noreferrer"&gt;Audio&lt;/a&gt; | &lt;a href="https://enappd.com/blog/adding-video-player-in-ionic-4-app/64" rel="noopener noreferrer"&gt;Video&lt;/a&gt; | &lt;a href="https://enappd.com/blog/image-picker-in-ionic-4-app/67" rel="noopener noreferrer"&gt;Image Picker&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-add-image-cropper-in-ionic-4-app/68" rel="noopener noreferrer"&gt;Image Cropper&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Ionic 4 Essentials — &lt;a href="https://enappd.com/blog/ionic-4-save-and-retrieve-data-locally-on-device/59" rel="noopener noreferrer"&gt;Native Storage&lt;/a&gt; | &lt;a href="https://enappd.com/blog/how-to-translate-in-ionic-4-globalization-internationalization-and-localization/11" rel="noopener noreferrer"&gt;Translations&lt;/a&gt; | &lt;a href="https://enappd.com/blog/rtl-right-to-left-use-in-ionic-4/50" rel="noopener noreferrer"&gt;RTL&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Ionic 4 messaging — &lt;a href="https://enappd.com/blog/implement-ionic-4-firebase-push/34" rel="noopener noreferrer"&gt;Firebase Push&lt;/a&gt; | &lt;a href="https://enappd.com/blog/automatically-read-sms-in-ionic-4-apps/42" rel="noopener noreferrer"&gt;Reading SMS&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Ionic 4 with Firebase — &lt;a href="https://enappd.com/blog/how-to-integrate-firebase-in-ionic-4-apps/23" rel="noopener noreferrer"&gt;Basics&lt;/a&gt; | &lt;a href="https://enappd.com/blog/firebase-with-ionic-4-hosting-auth-and-db-connection/58" rel="noopener noreferrer"&gt;Hosting and DB&lt;/a&gt; | &lt;a href="https://enappd.com/blog/firebase-cloud-functions-in-ionic-4-complete-guide/32" rel="noopener noreferrer"&gt;Cloud functions&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you need a base to start your next Ionic 5 app, you can make your next awesome app using &lt;a href="https://store.enappd.com/product/ionic-full-app/" rel="noopener noreferrer"&gt;Ionic 5 Full App&lt;/a&gt;&lt;/p&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2A1ArpKyhiDHZnevwB.jpeg"&gt;&lt;br&gt;Ionic 5 Full App starter from Enappd

</description>
      <category>ionic</category>
      <category>notifications</category>
      <category>capacitor</category>
      <category>angular</category>
    </item>
  </channel>
</rss>
