<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sapan on Medium]]></title>
        <description><![CDATA[Stories by Sapan on Medium]]></description>
        <link>https://medium.com/@sapanprojects?source=rss-587cd938b197------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by Sapan on Medium</title>
            <link>https://medium.com/@sapanprojects?source=rss-587cd938b197------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 02:36:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sapanprojects/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[App Check Security in React Native]]></title>
            <link>https://medium.com/@sapanprojects/app-check-security-in-react-native-9fdf6d564d8?source=rss-587cd938b197------2</link>
            <guid isPermaLink="false">https://medium.com/p/9fdf6d564d8</guid>
            <dc:creator><![CDATA[Sapan]]></dc:creator>
            <pubDate>Thu, 18 May 2023 12:19:53 GMT</pubDate>
            <atom:updated>2023-05-18T12:49:24.062Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello Welcome back, as you might have seen the previous blog which shows how to achieve the app integrity and app attest for Flutter, which also have the basic step to activate the native modules which is app integrity and app attest.<br>If you have not read it, here is the link refer it for the native implementation:- <a href="https://medium.com/@sapanprojects/flutter-app-security-with-firebase-appcheck-google-play-store-app-integrity-and-apple-app-attest-8d854e49d6e3">App Integrity and ATTest Blog Link</a></p><p>So Lets get Started</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Ff6z5TkrTIBZILYOd1t%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Ff6z5TkrTIBZILYOd1t%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia0.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExaml2MzEyY2NhZ3J4M3BpZnFrZmRnOTc1a2w0MzB3Mm5wMWwzM2lpNyZlcD12MV9naWZzX2dpZklkJmN0PWc%2Ff6z5TkrTIBZILYOd1t%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="435" frameborder="0" scrolling="no"><a href="https://medium.com/media/bfbbcd4a5d3731ea8947a92c56b41650/href">https://medium.com/media/bfbbcd4a5d3731ea8947a92c56b41650/href</a></iframe><p>Reference link of official React Native Firebase Document:- <a href="https://rnfirebase.io/app-check/usage">Link</a></p><p><strong>Step 1:</strong> Installing Dependencies First things first, let’s make sure we have the necessary dependencies installed. Open your project in your favorite code editor and navigate to the root directory using the terminal or command prompt. Now, run the following command to install the dependencies:</p><pre>npm install --save firebase @react-native-firebase/app-check</pre><p><strong>Step 2: </strong>Configuring Firebase To configure Firebase in your React Native app, we need to add a few lines of code. Open your app’s entry file, such as index.js or App.js. At the top of the file, import the required Firebase modules and initialize the Firebase app like this:</p><pre>import Firebase from &#39;@react-native-firebase/app&#39;;<br>import { AppCheck } from &#39;@react-native-firebase/app-check&#39;;<br><br>Firebase.initializeApp();<br><br>const appCheck = AppCheck();</pre><p><strong>Step 3:</strong> Activating App Check Now that Firebase is set up, let’s activate App Check for your app. It’s as simple as calling the activate() method on the appCheck instance. Add the following code snippet after initializing Firebase:</p><pre>appCheck.activate();</pre><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FN2JaONOG63aMM%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FN2JaONOG63aMM%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FN2JaONOG63aMM%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="247" frameborder="0" scrolling="no"><a href="https://medium.com/media/a6dfc77a67f1d6f9899422ea0d4ed9c9/href">https://medium.com/media/a6dfc77a67f1d6f9899422ea0d4ed9c9/href</a></iframe><p><strong>Step 4: Debugging App Check</strong><br> Debugging is essential during development to test and troubleshoot the security integration. Remember, debugging only works on emulators or simulators, not on real devices until the app is live in the stores.</p><p>For Apple Platforms: To enable App Check debug mode for iOS, open the AppDelegate.swift (or AppDelegate.m) file in the ios/Runner directory of your Flutter project. In that file, add the App Check debug provider factory code as described in the official Firebase documentation.</p><p>To enable debug logging in Xcode, follow these steps:</p><ol><li>Open your Xcode project.</li><li>Go to Product &gt; Scheme &gt; Edit Scheme.</li><li>Select “Run” from the left menu and navigate to the “Arguments” tab.</li><li>In the “Arguments Passed on Launch” section, add -FIRDebugEnabled.</li><li>Run your app in the Simulator, and you’ll see a local debug token printed in the debug output when Firebase sends a request to the backend.</li></ol><p>For Android: To activate Firebase App Check debug mode for Android, add the following code snippet in your React Native code(its shows for both the platforms)</p><pre>rnfbProvider = firebase.appCheck().newReactNativeFirebaseAppCheckProvider();<br>rnfbProvider.configure({<br>  android: {<br>    provider: __DEV__ ? &#39;debug&#39; : &#39;playIntegrity&#39;,<br>    debugToken: &#39;some token you have configured for your project firebase web console&#39;,<br>  },<br>  apple: {<br>    provider: __DEV__ ? &#39;debug&#39; : &#39;appAttestWithDeviceCheckFallback&#39;,<br>    debugToken: &#39;some token you have configured for your project firebase web console&#39;,<br>  },<br>});</pre><p>Check the output console for the debug secret. It will look like this: D DebugAppCheckProvider: Enter this debug secret into the allow list in the Firebase Console for your project:<strong> your debug token</strong>.<br>for getting direct log use this command:- adb logcat | grep DebugAppCheckProvider</p><p>Now that you have the debug token, let’s add it to the Firebase console:</p><ol><li>Go to the Firebase console at <a href="https://console.firebase.google.com/">https://console.firebase.google.com/</a> .</li><li>Open the left drawer and navigate to “Build” &gt; “App Check”.</li><li>Find your app in the list and click on the three-dot menu.</li><li>Look for the “Manage Token” option and add your debug token according to your platform.</li></ol><p>For Android, you also need to add the SHA-256 fingerprint of your keystore to the Firebase console. You can get the SHA-256 from the Play Console by going to App Integrity and then App Signing. Add all the SHA-256 keys to your Firebase console.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FKCdrPMXbMHdgU6zLQE%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FKCdrPMXbMHdgU6zLQE%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FKCdrPMXbMHdgU6zLQE%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="435" frameborder="0" scrolling="no"><a href="https://medium.com/media/c365d30dc203d62561f1fa563a438094/href">https://medium.com/media/c365d30dc203d62561f1fa563a438094/href</a></iframe><p>Step 5: Configuring App Check Tokens To configure App Check tokens in your app, we’ll follow these steps:</p><ol><li>Retrieve the App Check token using the getToken() method. This token will verify the authenticity of requests made by your app. Add the following code snippet wherever you need to access the token:</li></ol><pre>const appCheckToken = await appCheck.getToken();</pre><p>2. Once you have the token, you can include it in your API requests to the server. Add it to the headers of your requests using the X-Firebase-AppCheck header key. This ensures that your server can verify the authenticity of the request.</p><p>For example, using the axios package with an interceptor for REST API requests:</p><pre>axiosInstance.interceptors.request.use(<br>  async config =&gt; {<br>    if (store.getState()) {<br>      const {token} = store.getState();<br>      config.headers.Authorization = `Bearer ${token}`;<br>    }<br>    const appCheckToken = await appCheck.getToken();<br>    config.headers[&#39;X-Firebase-AppCheck&#39;] = appCheckToken;<br>    return config;<br>  },<br>  error =&gt; Promise.reject(error),<br>);</pre><p>For the above request i had use the axios package with its interceptor to achieve this.</p><p>For GraphQL API requests with Apollo Client:<strong><br> </strong>Create a extra link for the and then contact it with the request</p><pre>const httpLink = createUploadLink({<br>    uri: &quot;https://Backendurl.com&quot;,<br>    fetchPolicy: &#39;no-cache&#39;,<br>});<br><br>const request = async (operation) =&gt; {<br>    const token = store.getState().token;<br>    operation.setContext({<br>        headers: {<br>            authorization: token ? `Bearer ${token}` : &#39;&#39;,<br>            X-Firebase-AppCheck: await appCheck.getToken(),<br><br>        },<br>    });<br>};<br>const link = ApolloLink.from([apolloLogger, error, requestLink, httpLink]);<br>const client = new ApolloClient({<br>    link,<br>    cache,<br>});</pre><p>Step 6: Verifying Tokens on the Server To fully leverage Firebase App Check, it’s essential to verify tokens on your server. This step ensures that requests coming from your React Native app are legitimate. Refer to the Firebase documentation for your server environment to learn how to verify tokens using the Firebase Admin SDK or a compatible library.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FnT2BHPvnQmT4Y%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FnT2BHPvnQmT4Y%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FnT2BHPvnQmT4Y%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="174" frameborder="0" scrolling="no"><a href="https://medium.com/media/9cf9716461a71c391f925f10899d6898/href">https://medium.com/media/9cf9716461a71c391f925f10899d6898/href</a></iframe><p><strong>Conclusion</strong></p><p>That’s it, my friend! By following these steps, you’ve successfully integrated Firebase App Check into your React Native app, bolstering its security against abuse and unauthorized access. Remember to handle the App Check token securely and verify it on the server side. You’re now on your way to building a more secure and robust React Native application.</p><h3>Happy coding and stay secure!</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FokZ8eqHMUPDdLEAIkf%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FokZ8eqHMUPDdLEAIkf%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia0.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExb2Y3MG1ybmo0ejB2eHk1OTY4eXVkejdqdTlwNmpkbmE5bWhnbHozOCZlcD12MV9naWZzX2dpZklkJmN0PWc%2FokZ8eqHMUPDdLEAIkf%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="246" frameborder="0" scrolling="no"><a href="https://medium.com/media/a37d482680e2efd3e7affab501663aa1/href">https://medium.com/media/a37d482680e2efd3e7affab501663aa1/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9fdf6d564d8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter App Security with Firebase AppCheck, Google Play Store App Integrity, and Apple App Attest]]></title>
            <link>https://medium.com/@sapanprojects/flutter-app-security-with-firebase-appcheck-google-play-store-app-integrity-and-apple-app-attest-8d854e49d6e3?source=rss-587cd938b197------2</link>
            <guid isPermaLink="false">https://medium.com/p/8d854e49d6e3</guid>
            <dc:creator><![CDATA[Sapan]]></dc:creator>
            <pubDate>Thu, 18 May 2023 06:34:40 GMT</pubDate>
            <atom:updated>2023-05-18T12:21:02.210Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Introduction:</strong> Ensuring the security of your Flutter applications is crucial in today’s digital landscape. In this blog post, we will explore how to fortify the security of your Flutter apps by integrating Firebase AppCheck, activating App Integrity in the Google Play Store, and utilizing Apple App Attest. These robust security measures will safeguard your app against unauthorized access, tampering, and abuse, instilling trust in your users and protecting sensitive data.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FUgJggS22eb7xu%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FUgJggS22eb7xu%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FUgJggS22eb7xu%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="325" frameborder="0" scrolling="no"><a href="https://medium.com/media/d7f9858c6719437336ccd6ea60a79807/href">https://medium.com/media/d7f9858c6719437336ccd6ea60a79807/href</a></iframe><h3><strong>Part 1: Activating App Integrity in Google Play Store</strong></h3><p><strong>Step 1:</strong> Enable Play App Signing Before we dive into activating App Integrity, let’s make sure you have Play App Signing enabled for your app. Here’s how you can do it:</p><ol><li>Go to the Google Play Console (<a href="https://play.google.com/apps/publish">https://play.google.com/apps/publish</a>) and sign in using your developer account credentials.</li><li>Select your app from the list of published applications.</li><li>In the left sidebar, click on the “Release” tab.</li><li>Under the “Setup” section, make sure that Play App Signing is enabled for your app. If it’s not, no worries! Just click on “Manage” and follow the instructions to enable it.</li></ol><p><strong>Step 2:</strong> Activate App Integrity Now that Play App Signing is enabled, let’s proceed with activating App Integrity for your app. It’s a straightforward process:</p><ol><li>Head back to the Google Play Console and navigate to the “App Integrity” section.</li><li>Look for the “Activate” button and give it a click to initiate the app integrity setup process.</li><li>You’ll see two options: “Basic” and “Advanced.” If you want enhanced security (which is recommended), go with the “Advanced” option. However, if you prefer a simpler setup, feel free to choose “Basic.”</li><li>Follow the on-screen instructions to complete the activation process. Don’t worry — I’ll be here to guide you through each step and provide any additional information you might need.</li></ol><p>Keep in mind that the activation process may take a little time to complete. Google Play will analyze your app’s security configuration and ensure compatibility with App Integrity</p><p><strong>Step 3:</strong> Monitor App Security Congratulations! You’ve successfully activated App Integrity for your app. Now, here’s the best part: Google Play will continuously monitor your app’s security, guarding it against unauthorized modifications and tampering. It’s like having a dedicated security guard for your app, providing peace of mind for both you and your users.</p><h3><strong>Part 2: App Attest in Apple</strong></h3><p><strong>Step 1: </strong>Enroll in the Apple Developer Program Before we dive into App Attest, let’s get you enrolled in the Apple Developer Program. Here’s how you can do it:</p><ol><li>Head over to the Apple Developer Program website (<a href="https://developer.apple.com/programs/">https://developer.apple.com/programs/</a>) using your web browser.</li><li>Choose the program type that suits you best: “Organization” or “Individual.” Make a choice based on your needs.</li><li>Click on “Start Your Enrollment” and follow the instructions provided.</li><li>Complete the enrollment process by providing the necessary information and payment details. You’re on your way to becoming an official Apple developer!</li></ol><p><strong>Step 2:</strong> Configure App Attest in Xcode Now that you’re enrolled in the Apple Developer Program, let’s configure App Attest in Xcode. Don’t worry, it’s a breeze:</p><ol><li>Open your Flutter project in Xcode.</li><li>From the project navigator, select the target app for which you want to activate App Attest.</li><li>Go to the “Signing &amp; Capabilities” tab.</li><li>Double-check that you have the correct Team and Bundle Identifier selected for your app. This ensures that your app is associated with your Apple Developer account.</li></ol><p>Great job! You’re one step closer to bolstering your app’s security.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FZ0XsLMwQAKBfJv0yRH%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FZ0XsLMwQAKBfJv0yRH%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FZ0XsLMwQAKBfJv0yRH%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/c758e162fd541d88434276627e59d3ef/href">https://medium.com/media/c758e162fd541d88434276627e59d3ef/href</a></iframe><h3><strong>Part 3: Firebase AppCheck Security Integration for Flutter</strong></h3><p><strong>Step 1:</strong> Set up a Firebase Project First things first, let’s set up a Firebase project for your app. Here’s what you need to do:</p><ol><li>Head over to the Firebase console at <a href="https://console.firebase.google.com/">https://console.firebase.google.com/</a> and create a new project or select an existing one.</li><li>Follow the on-screen instructions to set up your project, including providing a project name and accepting the terms and conditions. You’re on your way to Firebase greatness!</li></ol><p><strong>Step 2:</strong> Add Firebase SDK Dependencies Now, let’s add the necessary Firebase SDK dependencies to your Flutter project. It’s super easy:</p><ol><li>Go through the link for updates <a href="https://pub.dev/packages/firebase_app_check">https://pub.dev/packages/firebase_app_check</a></li><li>Open your Flutter project in your favorite code editor.</li><li>Locate the pubspec.yaml file.</li><li>Scroll down to the dependencies section and add the following lines:</li></ol><pre>dependencies:<br>  firebase_core: ^1.0.3<br>  firebase_app_check: ^0.7.0</pre><p>4. Save the pubspec.yaml file and run flutter pub get in the terminal to fetch the new dependencies. We&#39;re almost there!</p><p><strong>Step 3:</strong> Configure Firebase AppCheck Alright, it’s time to configure Firebase AppCheck in your Flutter app. Don’t worry, I’ll guide you through it:</p><ol><li>Open your app’s entry point file, usually main.dart.</li><li>Import the necessary Firebase libraries by adding the following lines at the top:</li></ol><pre>import &#39;package:firebase_core/firebase_core.dart&#39;;<br>import &#39;package:firebase_app_check/firebase_app_check.dart&#39;;</pre><p>3. Initialize Firebase by calling Firebase.initializeApp() before running your app. Make sure to add the following code snippet:</p><p>4. FirebaseAppCheck.instance.activate();</p><pre>import &#39;package:firebase_core/firebase_core.dart&#39;;<br>import &#39;package:firebase_app_check/firebase_app_check.dart&#39;;<br><br>void main() async {<br>  WidgetsFlutterBinding.ensureInitialized();<br>  await Firebase.initializeApp();<br><br>  // Add Firebase AppCheck activation<br>  FirebaseAppCheck.instance.activate();<br><br>  runApp(MyApp());<br>}</pre><p><strong>Step 4: Debug Provider</strong></p><p>let’s talk about debugging Firebase AppCheck in your Flutter app. This is helpful during development when you want to test and troubleshoot the security integration.</p><p><strong>Note:- Run your app on an emulator or simulator (debug mode) since debug mode doesn’t work on real devices until the app is live in the stores.</strong></p><p>Here’s what you need to do:</p><p>For Apple Platforms:</p><ol><li>Open the AppDelegate.swift (or AppDelegate.m) file in the ios/Runner directory of your Flutter project.</li><li>In the file, create and set the App Check debug provider factory for Debug builds. You can find the code and more details in the official Firebase documentation <a href="https://firebase.google.com/docs/app-check/flutter/debug-provider#swift">https://firebase.google.com/docs/app-check/flutter/debug-provider#swift</a> .</li></ol><p>Now, let’s enable debug logging in Xcode:</p><ol><li>Open your Xcode project.</li><li>Go to Product &gt; Scheme &gt; Edit Scheme.</li><li>In the left menu, select “Run” and then go to the “Arguments” tab.</li><li>In the “Arguments Passed on Launch” section, add -FIRDebugEnabled.</li><li>Run your app in the Simulator. You’ll see a local debug token printed in the debug output when Firebase sends a request to the backend. It will look something like this: [Firebase/AppCheck][I-FAA001001] Firebase App Check Debug Token: <strong>your debug</strong> <strong>token</strong>.</li></ol><p>For Android:</p><ol><li>In your Flutter code, add the following code snippet to activate Firebase AppCheck with the debug option:</li></ol><pre>await FirebaseAppCheck.instance.activate(<br>  androidProvider: AndroidProvider.debug,<br>);</pre><p>Check the output console for the debug secret. It will look like this: D DebugAppCheckProvider: Enter this debug secret into the allow list in the Firebase Console for your project:<strong> your debug token</strong>.</p><p>Now that you have the debug token, let’s add it to the Firebase console:</p><ol><li>Go to the Firebase console at <a href="https://console.firebase.google.com/">https://console.firebase.google.com/</a> .</li><li>Open the left drawer and navigate to “Build” &gt; “App Check”.</li><li>Find your app in the list and click on the three-dot menu.</li><li>Look for the “Manage Token” option and add your debug token according to your platform.</li></ol><p>For Android, you also need to add the SHA-256 fingerprint of your keystore to the Firebase console. You can get the SHA-256 from the Play Console by going to App Integrity and then App Signing. Add all the SHA-256 keys to your Firebase console.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FSuEFqeWxlLcvm%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FSuEFqeWxlLcvm%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FSuEFqeWxlLcvm%2Fgiphy.gif&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="435" frameborder="0" scrolling="no"><a href="https://medium.com/media/a72cb0e9b86dba87876311011776178d/href">https://medium.com/media/a72cb0e9b86dba87876311011776178d/href</a></iframe><p><strong>Step 5:</strong> Get the Token to Share with Your Server To share a token with your server, you’ll need to retrieve it from Firebase AppCheck. Here’s how you can do it:</p><ol><li>In your Flutter app, call the getToken() method on the FirebaseAppCheck instance to get the token. It&#39;s as simple as that!</li><li>Once you have the token, you can share it with your backend.</li></ol><pre>import &#39;package:firebase_app_check/firebase_app_check.dart&#39;;<br><br> <br>var token = await FirebaseAppCheck.instance.getToken();</pre><p>3. Once you have the token, you can include it in your API requests to the server. Add it to the headers of your requests using the X-Firebase-AppCheck header key. This ensures that your server can verify the authenticity of the request.</p><p><strong>Add token to your api request for Rest working with dio</strong></p><pre> Future&lt;dynamic&gt; get(String url) async {<br>    var responseJson;<br>    try {<br>      final response = await _dio.get(<br>        url,<br>        options: buildCacheOptions(const Duration(days: 7), forceRefresh: true),<br>        headers: {<br>          &#39;X-Firebase-AppCheck&#39;: await FirebaseAppCheck.instance.getToken(),<br>        },<br>      );<br>      responseJson = _returnResponse(response);<br>    } on DioError catch (e) {<br>      if (e.error is SocketException) {<br>        throw FetchDataException(&#39;No Internet connection&#39;);<br>      }<br>    }<br>    return responseJson;<br>  }<br>}</pre><p><strong>Add token to your api request for Graphql working with dio<br> </strong>Create a extra AuthLink for the App Check Token and then contact it with the HttpLink</p><pre>static baseCall() {<br>    final HttpLink httpLink = HttpLink(<br>        &#39;http://backend.com/&#39;,<br>    );<br><br><br>final AuthLink integrityLink = AuthLink(getToken: () async {<br>      await FirebaseAppCheck.instance.setTokenAutoRefreshEnabled(true);<br>      return await FirebaseAppCheck.instance.getToken(true);<br>    },headerKey: &quot;X-Firebase-AppCheck&quot;);<br><br>    Link link = authLink.concat(httpLink);<br>    link = integrityLink.concat(link);<br><br>return link;<br>}<br><br> static ValueNotifier&lt;GraphQLClient&gt; client = ValueNotifier(<br>    GraphQLClient(<br>      link: baseCall(),<br>      cache: GraphQLCache(),<br>    ),<br>  );</pre><p><strong>Step 6: </strong>Verify Tokens on the Server For full leverage of Firebase AppCheck, it’s crucial to verify tokens on your server. This step ensures that requests coming from your Flutter app are legitimate. Refer to the Firebase documentation for your server environment to learn how to verify tokens using the Firebase Admin SDK or a compatible library.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FdpDaIOfhaJA6g3TfjA%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FdpDaIOfhaJA6g3TfjA%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FdpDaIOfhaJA6g3TfjA%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="435" frameborder="0" scrolling="no"><a href="https://medium.com/media/a979e79a8e76e41476c4e4128b290d02/href">https://medium.com/media/a979e79a8e76e41476c4e4128b290d02/href</a></iframe><blockquote><a href="https://medium.com/@sapanprojects/app-check-security-in-react-native-9fdf6d564d8"><strong>Steps to Achieve app check in React Native (Part 1 and Part 2 will remain same)</strong></a></blockquote><p><strong>Conclusion<br></strong>You’re taking a significant step toward enhancing its security. This blog post has provided you with a beginner-friendly guide to activate Firebase AppCheck, regardless of your experience level. Protect your app from abuse and unauthorized access, and create a trusted environment for your users. With Firebase AppCheck, you can build secure Flutter applications that prioritize data protection and maintain the integrity of your backend systems. Strengthen your app security today and embrace the power of Firebase AppCheck.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FjertcV0Bfk0s8%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FjertcV0Bfk0s8%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FjertcV0Bfk0s8%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/75c860908057c27ccbb0c80beac902c4/href">https://medium.com/media/75c860908057c27ccbb0c80beac902c4/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8d854e49d6e3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CI / CD Integration with fastlane for Mobile]]></title>
            <link>https://medium.com/@sapanprojects/ci-cd-integration-with-fastlane-for-mobile-e2fe0ddbaf7a?source=rss-587cd938b197------2</link>
            <guid isPermaLink="false">https://medium.com/p/e2fe0ddbaf7a</guid>
            <dc:creator><![CDATA[Sapan]]></dc:creator>
            <pubDate>Tue, 09 May 2023 10:54:15 GMT</pubDate>
            <atom:updated>2023-05-09T10:54:15.557Z</atom:updated>
            <content:encoded><![CDATA[<p>Make your app builds live via the pipeline and fast lane<br>It helps us to provide a faster and systematic pattern to provide builds to stores.</p><p>Requirements for working with the CI/CD, you should have the paid version for the gitlab and github otherwise there are some limitation for the in time(hours) that taken by the build, if you don’t want to get the paid version you then you should have the admin access for the platform or you can create your own runner for the implementation but it would restict you to the project specific.</p><p>Steps to achieve the CI/CD.</p><p><strong>Step 1: </strong>Create a .gitlab-ci.yml into your root project <br>These file is where all of your operation to create a build will need to be written.<br>The file will have job and staging as per your requirement.</p><p>A demo file</p><pre>stages:<br>  - build<br>  - clean<br><br>build_android: #Job name<br>  stage: build # Stage related to build <br>  needs: []<br>  before_script:<br>    - flutter clean<br>    - flutter pub get<br>  script:<br>    - flutter build appbundle<br>  artifacts:<br>    paths:<br>      - build/app/outputs/bundle/release/app-release.aab<br>      - android/local.properties<br>    expire_in: 5 hours<br>  only:<br>      - main<br>  tags:<br>    - mobile<br><br>build_ios: #Job name<br>  stage: build # Stage related to build <br>  needs: []<br>  before_script:<br>    - flutter clean<br>    - flutter pub get<br>    - cd ios<br>    - pod install<br>  script:<br>    - fastlane build<br>  artifacts:<br>    paths:<br>      - ios/build/Runner.ipa<br>    expire_in: 5 hours<br>  only:<br>    - main<br>  tags:<br>    - mobile<br><br>upload_to_android_store: #Job name<br>  stage: build # Stage related to build <br>  needs: [build_android] #Job Name that need to be completed before this started <br>  before_script:<br>    - cd android<br>  script:<br>    - fastlane deploy<br>  only:<br>      - main<br>  tags:<br>      - mobile<br><br>upload_to_ios_store: #Job name<br>  stage: build # Stage related to build <br>  needs: [build_ios] #Job Name that need to be completed before this started <br>  before_script:<br>    - cd ios<br>  script:<br>    - fastlane deploy<br>  only:<br>    - main<br>  tags:<br>    - mobile<br><br>clean_build:<br>  stage: clean<br>  script:<br>    - rm -rf /Users/wmtm11/build<br>  only:<br>    - uploadbuild<br>  tags:<br>    - mobile</pre><p>In the above file is use to deploy the flutter builds to both ios and android.<br>At the start of the file the stage names are provided,it a serialised flow so once the first stage is completed then only the next stage will start.<br>Here the job are not serialised but they are dependent on the previous jobs, so as per the limit of the job execution in the runner you created the no of jobs will start, even the runner have empty space but the dependent job is not completed then it will not start the next job.</p><p><strong>Step 2: </strong>Now here comes the fastlane file working <br>To get knowledge of fastlane check out this link :- <a href="https://fastlane.tools/">https://fastlane.tools/</a><br>A Overview of fastlane it help us to create a pathway to upload builds to store.</p><p>Follow the link for the fastlane setup in your system <a href="https://docs.fastlane.tools/">https://docs.fastlane.tools/</a></p><p>It also have some steps step to achieve the pathway <br><strong> Step 2.1: </strong>if you working with the cross platform you have to move to specific platform.<br><strong>Step 2.2: </strong>Run <strong>fastlane init </strong>command to platform specific folder, skip all steps for android and for ios select the manually setup<br><strong>Step 2.3: </strong>Once the setup is done,<strong> </strong>you will have a fastlane folder created with AppFile and FastFile.<br>You can remove the AppFile as we will be not working on it.<br><strong>Step 2.4: </strong>Instead of having the AppFile we will be working on the .env file.<br>to find the value to set in the .env you can use this <strong>fastlane action methodName <br>Step 2.5: </strong>You have to activate the API Access in the play console and get the json key for it from the Google Cloud Console<br>For ios you have redirect to the keys section and active the Appstore connect api.<br>example for android and ios .env</p><p>Andoird/fastlan/.env</p><pre>SUPPLY_PACKAGE_NAME=&quot;com.wmt.android.projectname&quot; # Package Name<br>SUPPLY_TRACK=&quot;internal&quot; # Testing track name<br>SUPPLY_JSON_KEY=&quot;./fastlane/automation_key_playstore.json&quot; # Set name as per you json file name, It can be fetced when you enable the api access in playstore.<br>SUPPLY_AAB=&quot;./../build/app/outputs/bundle/release/app-release.aab&quot; # it will remain the same</pre><p>iOS/fastlane/.env</p><pre>GYM_WORKSPACE=Runner.xcworkspace<br>GYM_CONFIGURATION=Release<br>GYM_SCHEME=Runner<br>GYM_SILENT=true<br>GYM_CLEAN=true<br>GYM_OUTPUT_DIRECTORY=build/<br>GYM_OUTPUT_NAME=Runner.ipa<br>GYM_SDK=&quot;iphoneos16.2&quot;<br>PILOT_IPA=&quot;./build/Runner.ipa&quot;<br><br># Add Your project KeyId, issuer Id , and change AuthKey_value.p8 to your key file<br># To get the P8 you need go to https://appstoreconnect.apple.com/access/api and Select App Store Connect API and then create the key <br><br>APP_STORE_CONNECT_API_KEY_KEY_ID=<br>APP_STORE_CONNECT_API_KEY_ISSUER_ID=<br>APP_STORE_CONNECT_API_KEY_KEY_FILEPATH=./fastlane/AuthKey_xyz.p8<br>APP_STORE_CONNECT_API_KEY_DURATION=1200<br>APP_STORE_CONNECT_API_KEY_IN_HOUSE=false<br><br># change the Method name and file as per requiments<br><br>GYM_EXPORT_METHOD=app-store<br>GYM_EXPORT_OPTIONS=&quot;./fastlane/ExportOptions.plist&quot;</pre><p>For android<br>SUPPLY_JSON_KEY: will the json which you have downloaded <br>SUPPLY_TRACK: the track that you want to upload your build <br>SUPPLY_AAB: the path of the aab file</p><p>For iOS <br>APP_STORE_CONNECT_API_KEY_KEY_ID and APP_STORE_CONNECT_API_KEY_ISSUER_ID will be get from the keys page of AppStore <br>APP_STORE_CONNECT_API_KEY_KEY_FILEPATH: the path to the file you download from the appstore <br>GYM_EXPORT_METHOD: type of upload you want to perform<br>GYM_EXPORT_OPTIONS: ExportOptions.plist file <br>For getting this file you need to have create a build from the xcode and then export the build to your system, so now move to the build folder you will find the exportOptions.plist file there.<br><strong>Step 2.6: </strong>Now it comes FastFile which the main file to start the excution <br>This file will contain the lanes which help to upload our builds to store <br>A dummy file how it will</p><pre># This file contains the fastlane.tools configuration<br># You can find the documentation at https://docs.fastlane.tools<br>#<br># For a list of all available actions, check out<br>#<br>#     https://docs.fastlane.tools/actions<br>#<br># For a list of all available plugins, check out<br>#<br>#     https://docs.fastlane.tools/plugins/available-plugins<br>#<br><br># Uncomment the line if you want fastlane to automatically update itself<br># update_fastlane<br><br>default_platform(:android)<br>fastlane_require &#39;dotenv&#39;<br>before_all do<br>  Dotenv.overload &#39;.env&#39;<br>end<br>platform :android do<br>  desc &quot;Deploy a new version to the Google Play&quot;<br>  lane :deploy do<br>    properties = property_file_read(file: &quot;./local.properties&quot;)<br>    flutter_version_code = properties[&quot;flutter.versionCode&quot;]<br>    flutter_version_name = properties[&quot;flutter.versionName&quot;]<br>    upload_to_play_store(version_name:&quot;#{flutter_version_code}(#{flutter_version_name})&quot;,)<br>  end<br>end</pre><p>Here the fastlane_required is use to load the .env file. i had use the property_file_read for getting the version name and code of the current android version, to add an extra Plugin you have to add the PluginFile into the fastlane folder and set it reference to the Gemfile in the root folder.<br>The lane name is deploy, which we had use in the first step in our .gitlb-ci.yml</p><p><strong>Step 3: </strong>To check if the execution is proper you can direclty run the lane by going to the platform specific folder and run <strong>fastlane laneName.</strong></p><p>This is an overview of how to work with the Ci/Cd pipelines using fastlane for the mobile automation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e2fe0ddbaf7a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dart metric code implementation]]></title>
            <link>https://medium.com/@sapanprojects/dart-metric-code-implementation-7b336b4e6418?source=rss-587cd938b197------2</link>
            <guid isPermaLink="false">https://medium.com/p/7b336b4e6418</guid>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Sapan]]></dc:creator>
            <pubDate>Tue, 09 May 2023 08:55:24 GMT</pubDate>
            <atom:updated>2023-05-09T16:46:13.773Z</atom:updated>
            <content:encoded><![CDATA[<p>Its help to make code look good and formatted, help developer to maintain a common and proper structure, able to set the complexity for the function so looping can be decrease, flexible rules assignment as per your project structure, help to find unused code and imports.</p><p>Steps to integrated dart metric code plugin to flutter</p><p><strong>Step 1: </strong>Add dependency of dart metric code to your project,<br>Plugin Link:- <a href="https://pub.dev/packages/dart_code_metrics">https://pub.dev/packages/dart_code_metrics</a></p><p>Add below code to your pubspec.yaml</p><pre>dev_dependencies:<br>  dart_code_metrics: ^latest_version</pre><p><strong>Step 2:</strong> Create a analysis_options.yaml file in your root directory if the file is alreday created remove the content and add your rules in it.</p><p>Here is the base file for the rules</p><pre>analyzer:<br>  plugins:<br>    - dart_code_metrics<br><br>dart_code_metrics:<br>  metrics:<br>    - cyclomatic-complexity: 20<br>  anti-patterns:<br>    - long-method<br>    - long-parameter-list<br>  extends:<br>    - package:dart_code_metrics/presets/all.yaml<br>  rules:<br>    - avoid-ignoring-return-values: false<br>    - no-magic-number: false<br>    - newline-before-return: false<br>    - member-ordering:<br>        widgets-order:<br>          - init-state-method<br>          - did-change-dependencies-method<br>          - did-update-widget-method<br>          - build-method<br>          - dispose-method<br>    - format-comment:<br>        only-doc-comments: true #i.e. comments starting with ///<br>    - prefer-moving-to-variable:<br>        allowed-duplicated-chains: 4<br>    - prefer-match-file-name:<br>        exclude:<br>          - test/**<br>          - lib/main.dart<br>  metrics-exclude:<br>    - test/**</pre><p><strong>Step 3 : </strong>Restart your IDE and run flutter pub get</p><p><strong>Step 4 : </strong>Now you can visit this link <a href="https://dcm.dev/docs/individuals/configuration/">https://dcm.dev/docs/individuals/configuration/</a> to find more rules according to your requirement, always restart the IDE after the new rule is added.</p><p>when ever the rules are not matching it will show the warning message, some time if don’t understand the warning by the message provide, just google the message which is showing it will give a proper understating of the error, make sure the content you googled is same as the the warning provided by the dart code metric.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7b336b4e6418" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>