<?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 DEV Amarjit Singh Sodhi on Medium]]></title>
        <description><![CDATA[Stories by DEV Amarjit Singh Sodhi on Medium]]></description>
        <link>https://medium.com/@1998.singh.amarjit?source=rss-da46ff0e837b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*3UuZp6z7W3Mb6S34</url>
            <title>Stories by DEV Amarjit Singh Sodhi on Medium</title>
            <link>https://medium.com/@1998.singh.amarjit?source=rss-da46ff0e837b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 20:56:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@1998.singh.amarjit/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[CI CD for Flutter apps (Android and iOS)]]></title>
            <link>https://medium.com/@1998.singh.amarjit/ci-cd-for-flutter-apps-android-and-ios-66145237b10d?source=rss-da46ff0e837b------2</link>
            <guid isPermaLink="false">https://medium.com/p/66145237b10d</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[fastlane]]></category>
            <dc:creator><![CDATA[DEV Amarjit Singh Sodhi]]></dc:creator>
            <pubDate>Thu, 13 Mar 2025 10:56:43 GMT</pubDate>
            <atom:updated>2025-03-13T10:56:43.281Z</atom:updated>
            <content:encoded><![CDATA[<p><em>In the era of automation it is vital to catch up with the new technologies. CI CD (Continuous Integration Continuous Deployment) can be one of them to start with.)</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mdRhQCBC_2tr5PkYAn0lqA.png" /></figure><p>In this article you will get to learn about the forever hot topic CICD in depth.</p><p>Following third parties are involved in the overall flow:</p><ol><li><strong>Bitbucket</strong>: For source code management</li><li><strong>Jenkins</strong>: To provide the virtual environment for the CICD where your build can be build and delivered further on.</li><li><strong>NGROK</strong>: To provide the communication medium between Bitbucket and Jenkins.</li><li><strong>Fastlane</strong>: To take the advantage of the available plugins and Ruby script to actually build the artifacts and process them according to the need.</li></ol><p>For the beginners, it might look complex but at the end of this article you will find it easy enough.</p><p>Grab a cup of coffee before we begin ☕️</p><p>I presume that you have a Flutter project and a Bitbucket repository for it.</p><p>Jenkins is used to automate software building, testing, and deployment tasks. Jenkins has two variants:</p><p>Jenkins LTS: More stable and reliable. Preferred for production.</p><p>Jenkins Weekly: Packed with latest features on weekly update basis. Preferred for learning and experimenting.</p><p>We will use the Jenkins LTS for its stability.</p><p>Jenkins installation is pretty straight forward.</p><p>Follow their <a href="https://www.jenkins.io/download/lts/macos/">guide</a> and you will be just fine.</p><p>After the installation, it’s time to unlock the Jenkins on your local machine.</p><p>When you first access a new Jenkins controller, you are asked to unlock it using an automatically-generated password.</p><ol><li>Browse to http://localhost:8080 (or whichever port you configured for Jenkins when installing it) and wait until the <strong>Unlock Jenkins</strong> page appears.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_shnNZcHM3eUjphS-6WMpQ.png" /></figure><p>2. From the Jenkins console log output, copy the automatically-generated alphanumeric password (between the 2 sets of asterisks).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KrP0Pi-2Is6hpBBEL6PRaw.png" /></figure><p><strong>Note:</strong></p><ol><li>The command: sudo cat /var/lib/jenkins/secrets/initialAdminPassword will print the password at console.</li><li>If you are running Jenkins in Docker using the official jenkins/jenkins image you can use sudo docker exec ${CONTAINER_ID or CONTAINER_NAME} cat /var/jenkins_home/secrets/initialAdminPassword to print the password in the console without having to exec into the container.</li><li>On the <strong>Unlock Jenkins</strong> page, paste this password into the <strong>Administrator password</strong> field and click <strong>Continue</strong>. You will get the access to the Jenkins Dashboard.</li></ol><p>Then we will make a bridge with the Bitbucket and our local machine to observe the push requests made to this repository. For this, we will setup the NGROK.</p><p>Install NGROK via Homebrew with the following command:</p><pre>brew install ngrok</pre><p>After the installation, you need to follow the given instructions to create an account on the <a href="https://dashboard.ngrok.com/get-started/setup/macos">NGROK Dashboard</a> to get the Authtoken.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6c7aUngPuIaci8xhlHd3bw.png" /></figure><p>Copy your Authtoken and use the following command to configure the NGROK on your local machine.</p><pre>ngrok config add-authtoken $YOUR_AUTHTOKEN</pre><p>Run the following command to run the NGROK on your local machine</p><pre>ngrok http http://localhost:8080</pre><p>Note: <em>As of now it will only be discoverable on you local machine since the localhost is being used. If you wish to setup the CICD for a team you will need to replace the localhost url with your domain url.</em></p><p>After the successful execution, it will look something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YYXs-r_o6kKBBgix1bAmBQ.png" /></figure><p>You will need to use the forwarding url (https://52be-2405-201-5015-f81f-fded-8417-5692-62fb.ngrok-free.app) as a web hook for the Bitbucket.</p><p>Copy the localhost url and paste it in the Jenkins URL input field as shown in the image below to complete the Jenkins account creation process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SExSas5IIRLerhdIFeW3JA.png" /></figure><p>Since in our case, the Jenkins and NGROK runs on the localhost with port 8080, Jenkins will receive the web hook updates.</p><p>Navigate to the Dashboard -&gt; Manage Jenkins -&gt; System on the Jenkins Dashboard. And add the webhook url as follow:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oK42rPPN-vgLkJW_159JJg.png" /></figure><p>This will connect your Jenkins with Bitbucket repository and will get the web hook updates whenever the specified event occur on the Bitbucket repository.</p><p>Add the following plugins from the Dashboard -&gt; System -&gt; Plugins.</p><ol><li>Bitbucket Plugin</li><li>Scan Multibranch Pipeline Trigges</li></ol><p>Now navigate back to the Jenkins Dashboard and add new item as your Jenkins project. Selects the “Multibranch Pipeline” as it’s type.</p><p>Provide a name for your project and add your Bitbucket repository to the Branch Sources section. Then add credentials to your repository. Use the App Password generated on your Bitbucket repository as the Password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0H1OwQq0rxOAoObt2yXDJQ.png" /></figure><p>After saving the credentials, select these as the credentials from the dropdown.</p><p>Now add the targeting branch in the Discover Branches section as follow:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dDU4UI-joVys1Ze8BG26xg.png" /></figure><p>Note: To add multiple targeting git branches, use space to separate them. You can also exclude branches which you wish to be ignored by the Jenkins.</p><p>Now enable the Multibranch Pipeline Trigger by selecting the Scan by webhook option to scan the Bitbucket web hook.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8zAy-xWZ7ntjopIbyiwHZA.png" /></figure><p>Create an unique token for the webhook and add it.</p><p>Save the configurations of your Jenkins project.</p><p>Navigate to your Bitbucket repository and go the repository settings. Look for the Webhooks option on the left hand side pane. Add a web hook as follow:</p><pre>https://52be-2405-201-5015-f81f-fded-8417-5692-62fb.ngrok-free.app/multibranch-webhook-trigger/invoke?token=your_custom_token</pre><p>Select the necessary trigger for the web hook, “Push” in our case.</p><p>You can make a push request on the specified branch of your repository and see if your commit appears in the Webhook’s View request logs.</p><p>After that you need to see if your commit appears in the Jenkins Logs(Dashboard -&gt; Manage Jenkins -&gt; System Log).</p><p>Integrate the Jenkins with your project by creating the Jenkinsfile(without any extension) at project root directory which will contain the Jenkins script. Jenkins use Gem to install the necessary plugins in your project.</p><p>For that create a Gemfile(without any extension) at project root directory which will contain the necessary plugins.</p><p>If you make a push request on the Bitbucket repository and go the Jenkins System Log you can notice wether the Jenkins has detected the Jenkinsfile or not.</p><p>At time point you have connect your project with Jenkins and Bitbucket via NGROK’s web hook.</p><p>Now it’s time to introduce the Fastlane.</p><p>Install the Fastlane on your local machine.</p><pre>brew install fastlane</pre><p>Add the Jenkins script in the Jenkinsfile which will install the requireed plugins and access our fastlane scripts.</p><pre>pipeline {<br>  agent any<br><br>  stages {<br>    stage(&#39;Setup&#39;) {<br>      steps {<br>        echo &quot;Setup&quot;<br>        // Configure bundler to use the user&#39;s home directory<br>        sh &quot;bundle config set --local path &#39;vendor/bundle&#39;&quot;<br>        // Install bundler in the user&#39;s home directory<br>        sh &quot;gem install --user-install bundler&quot;<br>        sh &quot;gem install --user-install bundler fastlane&quot;<br>        sh &quot;gem install --user-install bundler cocoapods&quot;<br>        // Ensure gems installed properly<br>        sh &quot;bundle check || bundle install --jobs=4 --retry=3&quot;<br><br>      }<br>    }<br>    stage(&#39;Build Android&#39;) {<br>      steps {<br>        echo &quot;Executing Fastlane: &#39;release&#39; for Android&quot;<br>        // Ensure bundler is available in PATH<br>        dir(&quot;android&quot;) {<br>           sh &#39;echo &quot;Current directory: $(pwd)&quot;&#39;<br>           sh &quot;bundle exec fastlane android release&quot;<br>        }<br>      }<br>    }<br><br>// iOS script will be added later on<br>}</pre><p>Note: Jenkins script is written in a Groovy-based Domain-Specific Language (DSL). However, fastlane script is written in Ruby script.</p><p>Add the following plugins in the Gemfile:</p><pre>source &quot;https://rubygems.org&quot;<br><br>gem &#39;fastlane&#39;<br>gem &quot;fastlane-plugin-flutter_version&quot;</pre><p>First we will configure the Fastlane for android module of our Flutter project. Navigate inside the android directory and run following command to initialize the Fastlane.</p><pre>fastlane init</pre><p>This will create fastlane directory which will contain Fastfile directory.</p><p>Write down the lanes in the Fastfile which can look something like this:</p><pre># Fastlane script is written in Ruby script language<br>default_platform(:android)<br><br>platform :android do<br>  private_lane :setup_variables do<br>    PACKAGE_NAME = ENV[&quot;PACKAGE_NAME&quot;]<br>    BUILD_NUMBER_PATH = ENV[&quot;BUILD_NUMBER_PATH&quot;]<br>    KEYSTORE_PATH = ENV[&#39;KEYSTORE_PATH&#39;]<br>    KEYSTORE_PASSWORD = ENV[&#39;KEYSTORE_PASSWORD&#39;]<br>    KEYSTORE_ALIAS = ENV[&#39;KEYSTORE_ALIAS&#39;]<br>    KEYSTORE_ALIAS_PASSWORD = ENV[&#39;KEYSTORE_ALIAS_PASSWORD&#39;]<br>    JSON_KEY_PATH = ENV[&#39;JSON_KEY_PATH&#39;]<br>    SLACK_WEBHOOK = ENV[&#39;SLACK_WEBHOOK&#39;]<br>    SLACK_CHANNEL_ID = ENV[&#39;SLACK_CHANNEL_ID&#39;]<br>  end<br><br>  before_all do<br>    setup_variables<br>  end<br><br>  lane :release do |options|<br>     verifyPlayConsoleConnection<br><br>     sh &quot;flutter pub get&quot;<br>     <br>     # Creates the appbundle<br>     # Note: Make sure you have configured the app signing data into the app-level Gradle file to sign the release builds.<br>     # In addition, since my project contains different flavors I had to mention the flavor. <br>     sh &quot;flutter build appbundle --flavor prod --release&quot;<br><br>     # Jumps inside the android directory<br>     puts &quot;Current Directory: /android&quot;<br>     version = flutter_version()<br>  <br>     # Uploads the appbundle on the Internal Testing track of the Play Console.<br>     upload_to_play_store(<br>           release_status: &quot;completed&quot;,# defaults to &quot;completed&quot;, needs your app to be reviewed for closed testing (Alpha)<br>           json_key: JSON_KEY_PATH,<br>           track: &quot;internal&quot;,<br>           package_name: PACKAGE_NAME,<br>           aab: &quot;../build/app/outputs/bundle/prodRelease/app-prod-release.aab&quot;,<br>           skip_upload_images: true,<br>           skip_upload_screenshots: true,<br>           skip_upload_apk: true,<br>           version_code: version[&quot;version_code&quot;], # From pubspec.yaml<br>           version_name: version[&quot;version_name&quot;]<br>         )<br><br>         notify_channel<br>  end<br><br># This lane will test the connection between our configured fastlane and the Play Console. <br>  lane :verifyPlayConsoleConnection do<br>     validate_play_store_json_key(<br>       json_key: JSON_KEY_PATH<br>     )<br>  end<br><br># Drops a message in the Slack channel, when the appbundle is uploaded on the Internal Testing track to notify the team members..<br>  lane :notify_channel do<br>     slack(<br>               message: &quot;Android App uploaded on the Play Store for internal testing!&quot;,<br>               channel: SLACK_CHANNEL_ID,  # Optional, by default will post to the default channel configured for the POST URL.<br>               success: true,<br>               slack_url: SLACK_WEBHOOK,<br>               payload: {  # Optional, lets you specify any number of your own Slack attachments.<br>                 &quot;Build Date&quot; =&gt; Time.new.to_s,<br>                 &quot;Built by&quot; =&gt; &quot;Jenkins&quot;,<br>               },<br>             )<br>  end<br>end</pre><p><em>Note: It is worth noting that for release_status, “completed” only works when you either submitted at least one version for production or closed testing track, meaning your app has been reviewed by the Play Console team. If not, you should use “draft” to upload app to the internal testing track, however you will need to publish your builds to Internal testing track manually each time.</em></p><p><strong>Important: </strong>All the variables mentioned in the setup_variables lane, need to be added into either the Jenskins’s Global Properties inside</p><p>Dashboard -&gt; Manage Jenkins -&gt; System or .env file that shall be created inside fastlane directory.</p><p>PACKAGE_NAME -&gt; package name of the android app, can be found in the app-level Gradle file.</p><p>BUILD_NUMBER_PATH -&gt; path of the filename.txt file manually created inside fastlane directory</p><p>KEYSTORE_PATH -&gt; path of the KeyStore.jks file, created for signing the android app. For easy access, place the KeyStore file inside the fastlane directory</p><p>KEYSTORE_PASSWORD -&gt; password added for the KeyStore.jks file</p><p>KEYSTORE_ALIAS -&gt; name of the alias key added in the KeyStore.jks</p><p>KEYSTORE_ALIAS_PASSWORD -&gt; password added for alias key in the KeyStore.jks file</p><p>SLACK_CHANNEL_ID -&gt; Channel ID of the Slack channel to which you need to send a message to.</p><p>SLACK_WEBHOOK -&gt; Signup on the <a href="https://api.slack.com/apps">slack dashboard</a> and create a Slack App. Add a web hook for your slack app and paste it as value of SLACK_WEBHOOK in the .env file. In addition, you need to manually add the Slack app to the channel for once.</p><p>JSON_KEY_PATH -&gt; path of the key file associated with the service account created on the Google Cloud Console. Navigate to the <a href="https://console.cloud.google.com/">Google Cloud Console</a> and select your project if already created before, create the project otherwise. Navigate to the Service Accounts page from the IAM &amp; Admin option. And create a service account. After that create a key (json type) inside that service account and download the key file and place it at secure place.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t9yqS1v1qib2wkhsa8H0sQ.png" /></figure><p>Copy the email ID generated for your service account which can look something like:</p><p><a href="https://console.cloud.google.com/iam-admin/serviceaccounts/details/109732117312830048483?project=cicddemo-452310"><em>fastlane-supply@</em></a><em>your_project_name</em><a href="https://console.cloud.google.com/iam-admin/serviceaccounts/details/109732117312830048483?project=cicddemo-452310"><em>.iam.gserviceaccount.com</em></a></p><p><strong>Link Service Account with Play Console account</strong></p><p>It is mandatory to grant the access of your Play Console account to your service account so that fastlane can access your Android app created on the Play Console.</p><p>Navigate to the User and Permissions section of the Play Console and add the service account email ID as user to grant the access. In addition you need to select your app in App Permission tab and select the Admin in the Account permission tab and tap on the Invite User button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8WPOOCqILvwjBOJiTcW4Sw.png" /></figure><p>At this point you are all set. You can test your fastlane script by using the following command inside android directory:</p><pre>fastlane lane_name</pre><p>If the fastlane script is executed without any error you are good to go.</p><p>Finally make a push request to the specified git branch that will trigger the Jenkins and in turn it will trigger the fastlane to create an appbundle and upload it to the Internal Testing track of the Play Console.</p><p>Well done 👏 , process for Android module is done!</p><p>Now it is time to upload the iOS app on the Test Flight.</p><p>It very critical to carefully manage the app signing of the iOS app manually.</p><p>First, we need to go to the Apple Developer account and navigate to the <a href="https://developer.apple.com/account/resources/certificates/list">Certificates, Identifiers and Profiles</a> section.</p><p>Create a provisioning profile for your iOS app inside Profiles section. Make sure to select the type as App Store for publishing the iOS app on the Test Flight. Further more it is important to carefully select the right Bundle ID and the Certificates.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2g5WHcC2La_y7uQIZ_Z3BQ.png" /></figure><p>After that download the created Provisioning Profile and import it to your iOS project in the XCode.</p><p>Add a file named ExportOption.plist to the Runner through XCode. It can have content similar to following:</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br>&lt;!DOCTYPE plist PUBLIC &quot;-//Apple//DTD PLIST 1.0//EN&quot; &quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&gt;<br>&lt;plist version=&quot;1.0&quot;&gt;<br>&lt;dict&gt;<br> &lt;key&gt;compileBitcode&lt;/key&gt;<br> &lt;false/&gt;<br> &lt;key&gt;destination&lt;/key&gt;<br> &lt;string&gt;export&lt;/string&gt;<br> &lt;key&gt;method&lt;/key&gt;<br> &lt;string&gt;app-store&lt;/string&gt;<br> &lt;key&gt;signingStyle&lt;/key&gt;<br> &lt;string&gt;manual&lt;/string&gt;<br> &lt;key&gt;teamID&lt;/key&gt;<br> &lt;string&gt;your team ID&lt;/string&gt;<br> &lt;key&gt;thinning&lt;/key&gt;<br> &lt;string&gt;&amp;lt;none&amp;gt;&lt;/string&gt;<br> &lt;key&gt;provisioningProfiles&lt;/key&gt;<br> &lt;dict&gt;<br>  &lt;key&gt;your bundle ID&lt;/key&gt;<br>  &lt;string&gt;name of the imported provisioning profile&lt;/string&gt;<br> &lt;/dict&gt;<br> &lt;key&gt;signingCertificate&lt;/key&gt;<br> &lt;string&gt;Apple Distribution&lt;/string&gt;<br> &lt;key&gt;stripSwiftSymbols&lt;/key&gt;<br> &lt;true/&gt;<br> &lt;key&gt;uploadBitcode&lt;/key&gt;<br> &lt;false/&gt;<br> &lt;key&gt;uploadSymbols&lt;/key&gt;<br> &lt;true/&gt;<br>&lt;/dict&gt;<br>&lt;/plist&gt;</pre><p>It will help to sign your IAP manually.</p><p>Go to the <a href="https://appstoreconnect.apple.com/access/integrations/api">Apple Developer account</a>, and create a App Store API Key.</p><p>Now download the p8 file and convert it to the base64 using the following command:</p><pre>cat myfile.p8 | base64</pre><p>It will give you base64 value for the AppStore Key. It is recommended to to use the base64 value for security reasons.</p><p>Note down the following things related to the App Store API Key which will be added to the env file.</p><ol><li>Name</li><li>Issuer ID</li><li>Key ID</li></ol><p>Add these in the .env file for the iOS module so that they can be used in th fastlane file.</p><pre>APPSTORE_CONNECT_API_KEY_BASE64=&quot;&quot;<br>APP_BUNDLE_ID=&quot;&quot;<br>APP_STORE_API_KEY_ID=&quot;&quot;<br>APP_STORE_API_ISSUER_ID=&quot;&quot;<br>TEAM_ID=&quot;&quot;<br>TEAM_NAME=&quot;&quot;<br>SLACK_WEBHOOK=&quot;&quot; # Optional</pre><p>Now create a directory “fastlane” inside ios directory and create a fastfile and add the following script in it.</p><pre>default_platform(:ios)<br><br>platform :ios do<br>  private_lane :setup_variables do<br>    APPSTORE_CONNECT_API_KEY_BASE64 = ENV[&#39;APPSTORE_CONNECT_API_KEY_BASE64&#39;]<br>    APP_BUNDLE_ID = ENV[&#39;APP_BUNDLE_ID&#39;]<br>    APP_STORE_API_KEY_ID = ENV[&#39;APP_STORE_API_KEY_ID&#39;]<br>    APP_STORE_API_ISSUER_ID = ENV[&#39;APP_STORE_API_ISSUER_ID&#39;]<br>    TEAM_ID = ENV[&#39;TEAM_ID&#39;]<br>    TEAM_NAME = ENV[&#39;TEAM_NAME&#39;]<br>    SLACK_WEBHOOK = ENV[&#39;SLACK_WEBHOOK&#39;]<br>  end<br><br>  before_all do<br>    setup_variables<br>  end<br><br>  lane :release do |options|<br>    sh &#39;flutter clean&#39;<br>    sh &#39;flutter pub get&#39;<br>    sh &#39;pod install&#39;<br><br>    Dir.chdir(&quot;..&quot;) do<br>        sh &#39;xcodebuild -workspace Runner.xcworkspace \<br>             -scheme Runner clean archive -configuration release \<br>             -sdk iphoneos -archivePath Runner.xcarchive&#39;<br><br>        sh &#39;xcodebuild -exportArchive -archivePath  Runner.xcarchive \<br>             -exportOptionsPlist  exportOptions.plist \<br>             -exportPath  cicdapp.ipa&#39;<br><br>        app_store_connect_api_key(<br>              key_id: APP_STORE_API_KEY_ID,<br>              issuer_id: APP_STORE_API_ISSUER_ID,<br>              is_key_content_base64: true,<br>              key_content: APPSTORE_CONNECT_API_KEY_BASE64,<br>            )<br><br>        upload_to_testflight(<br>           app_identifier: APP_BUNDLE_ID,<br>           ipa: &#39;ios/cicdapp.ipa/ci_cd_demo.ipa&#39;,<br>           changelog: &#39;Test the build and report the bugs.&#39;,<br>           team_id: TEAM_ID,<br>           team_name: TEAM_NAME<br>        )<br><br>        slack(<br>          message: &quot;CI CD Demo iOS App upload on the Test Flight for testing!&quot;,<br>          #channel: &quot;#channel&quot;,  # Optional, by default will post to the default channel configured for the POST URL.<br>          success: true,        # Optional, defaults to true.<br>          slack_url: SLACK_WEBHOOK,<br>          payload: {  # Optional, lets you specify any number of your own Slack attachments.<br>            &quot;Build Date&quot; =&gt; Time.new.to_s,<br>            &quot;Built by&quot; =&gt; &quot;Jenkins&quot;,<br>          },<br>        )<br>    end<br>  end<br>end</pre><p>Now carefully change the things according to your project. For an instance,</p><pre>sh &#39;xcodebuild -workspace your_project.xcworkspace \<br>             -scheme your_project_scheme clean archive -configuration release \<br>             -sdk iphoneos -archivePath Runner.xcarchive&#39;<br><br>        sh &#39;xcodebuild -exportArchive -archivePath  Runner.xcarchive \<br>             -exportOptionsPlist  exportOptions.plist \<br>             -exportPath  your_app.ipa&#39;</pre><p>First command will build an instance of your project. Second command will export the instance into IPA and sign it using the information mentioned in the ExportOptions.plist file.</p><p>Now to enable the Slack notifications, create an app on the <a href="https://api.slack.com/apps">Slack Dashboard</a> and create a web hook which will drop a slack message via Slack App that you will need to add it in your actual Slack workspace manually.</p><p>Then add the Slack web hook and Channel ID in the .env file.</p><p>Push your code on the specified branch and you will have your iOS app been uploaded on the Test Flight.</p><p>File Structure must be like:</p><pre>root_project_directory<br>  Jenkinsfile<br>  Gemfile<br>  android<br>    fastlane<br>      fastfile<br>      filename.txt<br>      .env<br>  ios<br>    fastlane<br>      fastfile<br>      .env<br>    ExportOptions.plist<br>  lib<br>  .<br>  .<br>  .</pre><p><strong>Bonus:</strong></p><p>Do you still manually select the Encryption algorithm when the iOS app is uploaded but pending on the Test Flight.</p><p>If so just add the following in your info plist file to decide the Encryption algorithm at the compile time. You can predefine the algorithm as per your app’s need.</p><pre>&lt;key&gt;ITSAppUsesNonExemptEncryption&lt;/key&gt;<br>&lt;string&gt;NO&lt;/string&gt;</pre><p>After this your iOS app will be automatically uploaded on the Test Flight and be ready for testing right away.</p><p>Round of applauds for you!!🥳🥳 you have successfully implemented the CICD for Android and iOS as well.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=66145237b10d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[XCode Issue- Flutter not found]]></title>
            <link>https://medium.com/@1998.singh.amarjit/xcode-issue-flutter-not-found-7b2823bf6509?source=rss-da46ff0e837b------2</link>
            <guid isPermaLink="false">https://medium.com/p/7b2823bf6509</guid>
            <category><![CDATA[pods]]></category>
            <category><![CDATA[news]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[xcode]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[DEV Amarjit Singh Sodhi]]></dc:creator>
            <pubDate>Thu, 14 Dec 2023 07:07:48 GMT</pubDate>
            <atom:updated>2023-12-14T07:07:48.749Z</atom:updated>
            <content:encoded><![CDATA[<p>“It is really a nightmare for Flutter Developers to encounter this issue. But worry not let me help you.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pesQ1Ey60Ds-LnlbUJ14hw.png" /><figcaption>Image describing issue “Flutter/Flutter.h” not found</figcaption></figure><p>For new developers, it is very difficult to find the fix for such issues. There are hundreds of solutions that you could come across which adds up the confusion.</p><p><strong>Step 1</strong></p><p>Open the iOS module in the XCode and go the Build Phases section.</p><p><strong>Step 2</strong></p><p>Look out for the Run Script section, and now make sure that the both “<em>For install build only</em>” and “<em>Based on the dependency analysis</em>” options are unticked. And You have added lines in the script.</p><pre>/bin/sh &quot;$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh&quot; build</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nYpybG0k_U967o-_ybXTlA.png" /></figure><p><strong>Step 3</strong></p><p>If the project contains the pods related to the Firebase Crashlytics, go to the Runner Phases and look for the Run Script that looks like the image below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3487zxA-d-u4njOOSyqYKQ.png" /></figure><p>Now make sure that the “<em>For install build only</em>” option is unticked and “Based on the dependency analysis” option is ticked.</p><p><strong>Step 4</strong></p><p>Now use “flutter clean &amp;&amp; flutter pub get &amp;&amp; cd ios &amp;&amp; pod install” at the root of the project. And Run the app, the error will be fixed.</p><p>That’s all!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7b2823bf6509" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Manage multiple Flutter SDKs]]></title>
            <link>https://medium.com/@1998.singh.amarjit/manage-multiple-flutter-sdks-0f0f7349478f?source=rss-da46ff0e837b------2</link>
            <guid isPermaLink="false">https://medium.com/p/0f0f7349478f</guid>
            <category><![CDATA[git]]></category>
            <category><![CDATA[setup]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[sdk]]></category>
            <category><![CDATA[installation]]></category>
            <dc:creator><![CDATA[DEV Amarjit Singh Sodhi]]></dc:creator>
            <pubDate>Mon, 11 Dec 2023 12:41:09 GMT</pubDate>
            <atom:updated>2023-12-11T12:41:09.851Z</atom:updated>
            <content:encoded><![CDATA[<p>“<em>As a developer you might need to work on multiple projects that run on different flutter SDKs, in such scenarios it is important to manage things in an effective way</em>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*waxS8MYNIaF4ApBq4OLrUg.png" /></figure><p>In this article you will learn how to manage multiple Flutter SDKs on a single machine in an effective way.</p><p>Let’s create a scenario first so you can relate better.</p><p>Assume you have two projects one named “project_new” that run on the latest Flutter SDK (3.13.0, latest at that time) and other named “project_old” that run on an older version (3.7.7) of Flutter that apparently is not compatible with the latest version.</p><p>For simpler approach what you can do is install two Flutter SDKs and switch between them by changing the Flutter path. That will work fine but there is more convenient way to handle such case.</p><p><strong>Step 1</strong></p><p>Download a stable version (3.13.0) of the Flutter SDK and install it on your system.</p><p>Note: It is recommended not to keep the downloaded flutter in the Downloads folder, you can copy the flutter folder to somewhere in the User directory.</p><p><strong>Step 2</strong></p><p>Set the flutter path on the system and check if everything works fine.</p><p><strong>Step 3</strong></p><p>Now check the status of the installed Flutter SDK. This shall give you the flutter version that you have installed.</p><pre>flutter doctor -v</pre><p><strong>Step 4</strong></p><p>Now open the terminal and go the path where the flutter folder is placed.</p><p><strong>Step 5</strong></p><p>Till now you system is ready to run the “project_latest”. But if you try to run “project_old” project, you will probably encounter issues related to version incompatibility. This is system telling you to install the older Flutter version.</p><p><strong>Step 6</strong></p><p>Use the git checkout command to go to specific commit of the flutter.</p><pre>git checkout {flutter_version}</pre><p>Note: Flutter team has followed the naming conventions such that they commit the code with exact tag which is it’s version. Replace the {flutter_version} with 3.7.7</p><p><strong>Step 7</strong></p><p>If you notice git will tell you the branch is now detached. To fix this, create a new branch 3.7.7.</p><pre>git checkout -b 3.7.7</pre><p>This will create a new branch locally.</p><p><strong>Step 8</strong></p><p>Check the list of branch that you have using git branch, you can notice there will be two branches stable and 3.7.7.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*qn5iP7-oG2eVURMS2CRwZw.png" /></figure><p><strong>Step 9</strong></p><p>Now if you need to work with “project_old” you can checkout to 3.7.7 branch and use flutter doctor -v command to install the version. And if you need to work with latest version you can checkout to stable branch.</p><p>That’s all, now you can use multiple Flutter SDKs without having to change the Flutter path every time you need to switch.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0f0f7349478f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Product Flavors in Flutter]]></title>
            <link>https://medium.com/@1998.singh.amarjit/product-flavors-in-flutter-21aa940537f7?source=rss-da46ff0e837b------2</link>
            <guid isPermaLink="false">https://medium.com/p/21aa940537f7</guid>
            <category><![CDATA[flavor]]></category>
            <category><![CDATA[environment]]></category>
            <category><![CDATA[xcode]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[DEV Amarjit Singh Sodhi]]></dc:creator>
            <pubDate>Fri, 08 Dec 2023 11:47:54 GMT</pubDate>
            <atom:updated>2023-12-08T11:47:54.515Z</atom:updated>
            <content:encoded><![CDATA[<p>“It’s always good to have separate environments for development and production.”</p><p>Are you also tired of manually configuring your app each and every time you create a build for different environment!</p><p>Well, you come to the right place.</p><p>Here is what you can expect at the end of this article</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iSIoY1k-YpOBXJCocPnR-w.png" /></figure><p>Grab a cup of coffee before we dive in…</p><p>You are going to have separate dart entry files for your project depending on the flavors your app need. Let’s begin</p><h3>Dart Configuration</h3><p><strong>STEP 1</strong></p><p>First of all, create a dart file with name “flavor_config.dart” which is going to define the separate values for separate environments.</p><p>File can look like this</p><pre>enum Flavor {<br>  DEV, STG, PROD<br>}<br><br>class FlavorValues {<br>  final String? appId;<br>  final String? baseUrl;<br>  final String? sentryUrl;<br>  final String? dynamicLinkUrl;<br><br>  FlavorValues({this.appId, this.baseUrl, this.sentryUrl, this.dynamicLinkUrl});<br>}<br><br><br>class FlavorConfig {<br>  final Flavor flavor;<br>  final String name;<br>  final FlavorValues? values;<br>  static FlavorConfig? _instance;<br><br>  factory FlavorConfig({<br>    required Flavor flavor,<br>    required String name,<br>    required FlavorValues values}) {<br>    _instance ??= FlavorConfig._internal(<br>        flavor, name, values);<br>    return _instance!;<br>  }<br><br>  FlavorConfig._internal(this.flavor, this.name, this.values);<br><br>  static FlavorConfig? get instance =&gt; _instance;<br><br>  static bool isDevelopment() =&gt; _instance!.flavor == Flavor.DEV;<br><br>  static bool isProduction() =&gt; _instance!.flavor == Flavor.PROD;<br>}</pre><p>File can include any data that might differ according to the environments. Feel free to add or remove the fields as per your need.</p><p><strong>STEP 2</strong></p><p>Rename the “main.dart” file to something more meaningful let’s say “main_common.dart”, since your project is going to have multiple main entry files. And also rename the “main” function to “mainCommon” function inside the “main_common.dart” file.</p><p><strong>STEP 3</strong></p><p>Now create separate files for separate environments.</p><p>For dev environment, create “main_dev.dart”</p><p>For prod environment, create “main_prod.dart”</p><p>Your lib directory will look like this</p><pre>lib/main_common.dart<br>lib/main_dev.dart<br>lib/main_prod.dart<br>lib/...</pre><p><strong>STEP 4</strong></p><p>Now add the following code to the “main_dev.dart” file.</p><pre><br>void main() {<br>  FlavorConfig(<br>    flavor: Flavor.DEV,<br>    name: &quot;DemoApp DEV&quot;,<br>    values: FlavorValues(<br>        appId: &quot;12345678&quot;,<br>        baseUrl: &#39;https://api.example.com&#39;,<br>        sentryUrl: &#39;&#39;,<br>        dynamicLinkUrl: &#39;&#39;<br>    ),<br>  );<br>  mainCommon();<br>}</pre><p>Similarly do the same for “main_prod.dart” file, but don’t forget to change the values as per your need.</p><p><strong>STEP 5</strong></p><p>Now you need to add the dart configuration files for separate environments.</p><p>For prod environment, provide path for your “main_prod.dart”. Add additional run args “-t lib/main_prod.dart”. Add build flavor “prod”. Do the same for dev environment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2qEQyw0BT3n4S6NVmT5ZoA.png" /><figcaption>figure 1</figcaption></figure><h3><strong>iOS CONFIGURATION</strong></h3><p>You also need to do some configuration for iOS module to do the trick.</p><p><strong>STEP 1</strong></p><p>Open the iOS module in the XCode. Select the Runner file in the left Section, and then again select the Runner under the Project. Now tap on the Info tab and look for the Configuration section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J_N3sQHxrdjm6sQ269j7SA.png" /><figcaption>figure 2</figcaption></figure><p><em>NOTE: You will only see the Debug, Release and Profile configurations.</em></p><p><strong>STEP 2</strong></p><p>For creating configurations for dev environment, tap on the “+” icon to add the duplicate of <em>Debug, Release and Profile configurations. Now rename the duplicate configurations.</em></p><p>Do the same step for prod environment, your configuration section will look like figure 2.</p><p><strong>STEP 3</strong></p><p>Go the Edit Configuration, a window will open.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BATsR71kBJubU4jiyYA3wQ.png" /><figcaption>figure 3</figcaption></figure><p>Now create duplicate scheme for dev and prod environments.</p><p><strong>STEP 4</strong></p><p>Now tap on the Build Configuration, you will see the previously added configurations</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PRpT3j4j18zG1quAadPC3w.png" /></figure><p>Assign the corresponding configurations.</p><p>STEP 4</p><p>Select the Runner under Targets, and go to Build Settings tab. Look for the User-Defined section, in it look for “FLUTTER_TARGET”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pLfABZCKHaIUPRbdhg4NBw.png" /><figcaption>figure 4</figcaption></figure><p>Assign the appropriate dart entry points corresponding to the environments.</p><p><strong>STEP 5</strong></p><p>Create a APP_DISPLAY_NAME inside the User-Defined, and assign the appropriate app names corresponding to your environments.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/968/1*qvn9aRwiD_XP_Uj_IlJgxQ.png" /><figcaption>figure 5</figcaption></figure><p><strong>STEP 6</strong></p><p>Now open the Info.plist file and assign the APP_DISPLAY_NAME to the “Bundle display name”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kz3QiauUEluUjGURuPuVVw.png" /></figure><p>That’s it, if you run your app on iOS device, your device will have environment-based app-name and other data that you mentioned in flavor_config.dart file.</p><p><strong>ANDROID CONFIGURATION</strong></p><p>Android configuration is pretty straght-forward.</p><p>STEP 1</p><p>In the Android module, open the app-level build.gradle file.</p><p>STEP 2</p><p>Add the following code in the “Android” block. This will create a string app_name with multiple values for each environment.</p><pre>flavorDimensions &quot;default&quot;<br>productFlavors {<br>  prod {<br>    dimension &quot;default&quot;<br>    resValue &quot;string&quot;, &quot;app_name&quot;, &quot;Flutter Demo Prod&quot;<br>  }<br>  dev {<br>    dimension &quot;default&quot;<br>    resValue &quot;string&quot;, &quot;app_name&quot;, &quot;Flutter Demo Dev&quot;<br>  }<br>}</pre><p>STEP 3</p><p>Assign the “app_name” in the Manifest file. And your android build will have environment-specific name.</p><pre>&lt;application<br>   android:label=&quot;@string/app_name&quot;<br>   android:name=&quot;${applicationName}&quot;<br>   ...</pre><p>And with that your flutter app will have different configuration for different environment.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=21aa940537f7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Revert commit changes from git]]></title>
            <link>https://medium.com/@1998.singh.amarjit/revert-commit-changes-from-git-5973e601fe25?source=rss-da46ff0e837b------2</link>
            <guid isPermaLink="false">https://medium.com/p/5973e601fe25</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[git-rebase]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[DEV Amarjit Singh Sodhi]]></dc:creator>
            <pubDate>Fri, 08 Dec 2023 10:10:10 GMT</pubDate>
            <atom:updated>2023-12-08T10:10:10.896Z</atom:updated>
            <content:encoded><![CDATA[<p>“<em>If you got here, then I assume you are in trouble…</em>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JqVLz01CXkkTtk6jpTw7iw.png" /></figure><p>It seems you have mistakenly overwritten the code at the wrong branch by adding one or more commits. And now you want to get back the code that resided in the concerned branch before the recent commits.</p><p>To make this easy, let’s create a scenario and at the end of this article try to relate this to your case.</p><p>Let’s assume you have two branches named “feature/profile” &amp; “feature/product”.</p><p>And you have overwritten the code of the “feature/profile” branch with code that shall belong to the “feature/product” branch.</p><p><strong>STEPS TO FOLLOW</strong></p><p>Step 1</p><p>First thing first, take the local backup of your project.</p><p>Step 2</p><p>Open the terminal at the root folder of your project and check for untracked changes with the help of “git status” command. If you see uncommitted changes or untracked files then create a local commit.</p><p>Step 3</p><p>Use “git checkout -b {new_branch_name} {commit_id}”</p><p>NOTE: “new_branch_name” is the name of the branch that will act as the backup branch of the desired code. And “commit_id” is commitId of the last commit that was pushed before the unwanted commits.</p><p>This command will create a new branch that will create the copy of the code from the mentioned commitId.</p><p>Now you have safely extracted the desired code.</p><p>Now it’s important to erase those unwanted commits to avoid any confusion and to make your commit history clean.</p><p>Step 4</p><p>Checkout into the “feature/profile” branch since those commits belong to this branch.</p><p>Step 5</p><p>Use “git reset –hard {commit_id}” to reset the commits to specific commitId. After this you can notice that the changes from the specific commit have come to your local “feature/profile” branch.</p><p>Step 6</p><p>Now you completely erase the unwanted commits from the commit history, use git push command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hXBKkodJS3uoqvYmAEJcQA.png" /></figure><p><strong>Now you can smile because the trouble is long gone!!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5973e601fe25" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Firebase Notifications & Flutter Local Notifications]]></title>
            <link>https://medium.com/@1998.singh.amarjit/firebase-notifications-flutter-local-notifications-a7d894dc60fe?source=rss-da46ff0e837b------2</link>
            <guid isPermaLink="false">https://medium.com/p/a7d894dc60fe</guid>
            <category><![CDATA[push-notification]]></category>
            <category><![CDATA[firebasenotifications]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[notifications]]></category>
            <category><![CDATA[notifications-in-flutter]]></category>
            <dc:creator><![CDATA[DEV Amarjit Singh Sodhi]]></dc:creator>
            <pubDate>Thu, 02 Nov 2023 08:06:09 GMT</pubDate>
            <atom:updated>2025-03-13T11:13:01.372Z</atom:updated>
            <content:encoded><![CDATA[<p>“To be honest, adding Push Notifications in the flutter app is no easy task for beginners.”</p><p>At the end of this article you will be able to easily add the push notifications in your flutter app.</p><p>What you can expect at the end of this article</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*kM_e-Tw88b18WyJnRd3T4w.png" /><figcaption>Notification preview for Android devices</figcaption></figure><p>Grab a cup of coffee and start!</p><h3>Firebase Console Configurations</h3><p>STEP 1</p><p>Create a project on Firebase Console for your flutter project.</p><p>STEP 2</p><p>Create an iOS app in the Firebase project, and add the required info such as Team ID &amp; App ID.</p><p>STEP 3</p><p>Go to the apple developer console, enable the push notification capability and create the p8 file and that store the file and its key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0KKi2uAWvHPkCJ7SbJzlog.png" /><figcaption>Figure 1</figcaption></figure><p><em>NOTE: Make sure to note the key for the p8 file and store the p8 file in secure place.</em></p><p>STEP 4</p><p>Go back to the Firebase Console, and navigate to iOS app, there, upload the p8 file and paste the p8 file’s key that you have copied.</p><h3>PROJECT CONFIGURATION</h3><p>STEP 1</p><p>Download the GoogleServices file and add that file to the Runner through the XCode.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*6qzZIGlcTpaQb7owkKBrXw.png" /><figcaption>Figure 2</figcaption></figure><p>STEP 2</p><p>Create the Android app and add your system’s SHA key and download the Google Services file then add that file in the “{your_project}/android/app/src” location.</p><p>STEP 3</p><p>Open the iOS module in the XCode and add the “Push Notifications” capability.</p><p>Also add the Background Mode capability and tick the “Remote Notifications” &amp; “Background Fetch”.</p><p>STEP 4</p><p>For Android module, add the Post Notifications permission in the Manifest file.</p><pre>&lt;uses-permission android:name=&quot;android.permission.POST_NOTIFICATIONS&quot;/&gt;</pre><p>STEP 5</p><p>Add the notification intent in the Main Activity tag.</p><pre><br>&lt;intent-filter&gt;<br>&lt;action android:name=&quot;FLUTTER_NOTIFICATION_CLICK&quot; /&gt;<br>&lt;category android:name=&quot;android.intent.category.DEFAULT&quot; /&gt;<br>&lt;/intent-filter&gt;</pre><p>Add the meta-data tags in the Manifest file.</p><pre>&lt;meta-data<br><br>android:name=&quot;com.google.firebase.messaging.default_notification_icon&quot;<br><br>android:resource=&quot;@drawable/ic_notification&quot; /&gt;<br><br>&lt;meta-data<br><br>android:name=&quot;com.google.firebase.messaging.default_notification_channel_id&quot;<br><br>android:value=&quot;@string/default_notification_channel_id&quot;/&gt;</pre><p>STEP 6</p><p>Add the drawable in the <em>res/drawable</em> folder with name “ic_notification” for notifications.</p><p>STEP 7</p><p>Add the notification channel in the strings file under /res folder.</p><pre>&lt;string name=&quot;default_notification_channel_id&quot;&gt;my_app_channel&lt;/string&gt;</pre><p>STEP 8</p><p>In the anroid/build.gradle file, add the following classpath</p><pre>classpath &#39;com.google.gms:google-services:4.4.0&#39;</pre><p>STEP 9</p><p>In the android/app/build.gradle file, add the following</p><p>plugin</p><pre>id &#39;com.google.gms.google-services&#39;</pre><p>dependency</p><pre>implementation &#39;com.google.firebase:firebase-messaging:23.3.0&#39;<br>implementation &#39;com.google.firebase:firebase-analytics:21.4.0&#39;</pre><p>That’s it for the iOS &amp; Android Configurations</p><p>Let’s jump to the dart implementation</p><p>STEP 1</p><p>First of all, you need to add the flutter plugin “firebase_messaging”.</p><p>STEP 2</p><ol><li>In the “main.dart” file, initialize the firebase app by adding the following code</li></ol><pre>if(Platform.isAndroid) {<br>  //only for Android<br>  await Firebase.initializeApp(<br>  options: const FirebaseOptions(<br>  apiKey: &#39;AIzaSyDy*****************&#39;,<br>  appId: &#39;1:45120****:android:a586********&#39;,<br>  messagingSenderId: &#39;4512*******&#39;,<br>  projectId: &#39;{firebase_project_name}&#39;));<br>} else {<br>  await Firebase.initializeApp();<br>}</pre><p>NOTE: Apparently, there are some changes in the initialization of the firebase app. For Android module, you need to provide the FirebaseOptions also.</p><p><em>“apiKey”: copy the “current_key” from the GoogleService.json file.</em></p><p><em>“appId”: copy the “mobilesdk_app_id”</em></p><p><em>“messaging SenderId”: copy the “project_number”</em></p><p><em>“projectId”: copy the “project_id”</em></p><p>STEP 2</p><p>Kindly add a function let’s say requestNotificationPermission and invoke that function inside the initState function.</p><pre>@override<br>void initState() {<br>  requestNotificationPermission();<br>  super.initState();<br>}<br><br>void requestNotificationPermission() async {<br>  await FirebaseMessaging.instance.requestPermission(<br>    alert: true,<br>    announcement: false,<br>    badge: true,<br>    carPlay: false,<br>    criticalAlert: false,<br>    provisional: true,<br>    sound: true,<br>  );<br>}</pre><p>Enable the foreground presentation for the push notifications, for iOS.</p><pre>FirebaseMessaging messaging = FirebaseMessaging.instance;<br>messaging.setForegroundNotificationPresentationOptions(<br>  alert: true,<br>  badge: true,<br>  sound: true);</pre><p>At this point, your app shall receive the push notifications for iOS but for Android only in the app-kill state or background state.</p><p><em>NOTE: You need “flutter_local_notifications” plugin to support push notifications in foreground mode for Android.</em></p><h3>Flutter Local Notifications</h3><p>STEP 1</p><p>Add the “flutter_local_notifications” plugin.</p><p>STEP 2</p><p>Create Android notifications channel</p><pre>/*Creating channel for notifications*/<br>static const AndroidNotificationChannel channel =<br>AndroidNotificationChannel(&#39;my_app_channel&#39;, &#39;my_app_channel&#39;,<br>description: &#39;This channel is used for important notifications.&#39;,<br>importance: Importance.high,<br>showBadge: true,<br>enableVibration: true,<br>playSound: true);</pre><p>STEP 3</p><p>Add the notification channel for the Local notification object</p><pre>await notificationsPlugin<br>.resolvePlatformSpecificImplementation&lt;<br>AndroidFlutterLocalNotificationsPlugin&gt;()<br>?.createNotificationChannel(channel);</pre><p>Create the android notifications details.</p><pre>/*Creating notifications details for local notifications*/<br>var android = const AndroidNotificationDetails(<br>&#39;my_app_channel&#39;,<br>&#39;my_app_channel&#39;,<br>channelDescription: &#39;channel description&#39;,<br>importance: Importance.max,<br>priority: Priority.high,<br>ticker: &#39;ticker&#39;,<br>);</pre><p>STEP 4</p><p>For showing notification head-up, use the notifications details object inside the FirebaseMessaging.<em>onMessage</em>.listen</p><pre>if(Platform.isAndroid) {<br>  var platform = NotificationDetails(android: android);<br>  notificationsPlugin.show(<br>    1, <br>    message.notification?.title, <br>    message.notification?.body,<br>   platform);<br>}</pre><p>Thats all, your app shall receive the push notifications in iOS &amp; Android apps.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a7d894dc60fe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Save Password & Autofill Password in Flutter]]></title>
            <link>https://medium.com/@1998.singh.amarjit/save-credentials-autofill-credentials-in-flutter-33058295dd9d?source=rss-da46ff0e837b------2</link>
            <guid isPermaLink="false">https://medium.com/p/33058295dd9d</guid>
            <category><![CDATA[save-password-in-keychain]]></category>
            <category><![CDATA[password-autofill]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[save-password]]></category>
            <category><![CDATA[autofill]]></category>
            <dc:creator><![CDATA[DEV Amarjit Singh Sodhi]]></dc:creator>
            <pubDate>Thu, 02 Nov 2023 06:17:12 GMT</pubDate>
            <atom:updated>2025-03-13T11:03:06.313Z</atom:updated>
            <content:encoded><![CDATA[<h4>Want to know what’s more easy than typing the login credentials every time while logging-in, Autofill Credentials is process you are looking for!</h4><p>What you can expect at the end of the article</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/1*7t4rklBbkdAdl8ffWeoLAQ.jpeg" /><figcaption>Save password prompt for iOS devices</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/603/1*dBsEJW1narbUb-DRwbyqWA.png" /><figcaption>Save password prompt for Android devices</figcaption></figure><h3>ANDROID</h3><p>It’s very straight-forward for the Android part. No configuration is needed to be done in Android module.</p><h3>iOS</h3><p>For iOS module, a little efforts are required to get the job done.</p><p>Lets Start then!</p><p>Assuming you have already created your flutter project.</p><p><strong>STEP 1</strong></p><p>First of all, open the iOS module in the XCode. Then go to the “Signing &amp; Capabilities” section. Add the “AutoFill Credential Provider” and “Keychain Sharing” capabilities.</p><p><strong>STEP 2</strong></p><p>For the “Keychain Sharing” capability, add the keychain group for your project which can be your bundle ID as shown in the figure 1.</p><figure><img alt="Image showing “Keychain Sharing” capability with it’s required Keychain group" src="https://cdn-images-1.medium.com/max/926/1*gAYsccYAuP4JzWaAyGy2Lg.png" /><figcaption>Figure 1</figcaption></figure><p>STEP 3</p><p>Next, add the “Associated Domains” capability which is going to be used for storing user’s credentials in the device’s keychain.</p><p>STEP 4</p><p>For the “Associated Domains” capability, you need to add domains for webcredentials and applinks. Remember to replace the domains shown in the figure 2 with your project’s actual domains.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/934/1*NDLrUupAr5KDmaQAm3Cchw.png" /><figcaption>Figure 2</figcaption></figure><p>NOTE: This domain will be used by the iOS device’s keychain to associate the user’s credentials to your app.</p><p>STEP 5</p><p>Now associated domains needs to be hosted for the apple app site association. For that you need to create a file containing app data in json format.</p><pre>{<br>  &quot;applinks&quot;: {<br>      &quot;details&quot;: [<br>           {<br>             &quot;appIDs&quot;: [ &quot;{teamID}.{bundleID}&quot;, &quot;{teamID}.{bundleID}&quot;],<br>             &quot;components&quot;: [<br>               {<br>                  &quot;#&quot;: &quot;no_universal_links&quot;,<br>                  &quot;exclude&quot;: true,<br>                  &quot;comment&quot;: &quot;Matches any URL with a fragment that equals no_universal_links and instructs the system not to open it as a universal link.&quot;<br>               },<br>               {<br>                  &quot;/&quot;: &quot;/buy/*&quot;,<br>                  &quot;comment&quot;: &quot;Matches any URL with a path that starts with /buy/.&quot;<br>               },<br>               {<br>                  &quot;/&quot;: &quot;/help/website/*&quot;,<br>                  &quot;exclude&quot;: true,<br>                  &quot;comment&quot;: &quot;Matches any URL with a path that starts with /help/website/ and instructs the system not to open it as a universal link.&quot;<br>               },<br>               {<br>                  &quot;/&quot;: &quot;/help/*&quot;,<br>                  &quot;?&quot;: { &quot;articleNumber&quot;: &quot;????&quot; },<br>                  &quot;comment&quot;: &quot;Matches any URL with a path that starts with /help/ and that has a query item with name &#39;articleNumber&#39; and a value of exactly four characters.&quot;<br>               }<br>             ]<br>           }<br>       ]<br>   },<br>   &quot;webcredentials&quot;: {<br>      &quot;apps&quot;: [ &quot;{teamID}.{bundleID}&quot; ]<br>   },<br><br><br>    &quot;appclips&quot;: {<br>        &quot;apps&quot;: [&quot;{teamID}.{bundleID}&quot;]<br>    }<br>}</pre><p>NOTE: Make sure that you replace the {teamID} with your project’s team ID and {bundleID} with your app’s bundleID.</p><p>STEP 6</p><p>After hosting the file, you can check if the file is successfully hosted or not by using the link given below. If the page is successfully loaded then you are good to go.</p><p>For iOS :</p><pre>https://{your domain}/.well-known/apple-app-site-association</pre><p>For Android:</p><pre>https://{your domain}/.well-known/assetlinks.json</pre><p>NOTE: Make sure to replace the {your domain} with domain.</p><p>At this point, your are done with the app configuration.</p><h3>FLUTTER</h3><p>STEP 1</p><p>You are almost there, Now open your login screen, wrap your text fields in a Column widget. And then wrap that “Column” widget with “AutofillGroup” widget.</p><p>STEP 2</p><p>Assuming you have 2 textfields widgets one for username and other is for password. Add the “autofillHints” property AutofillHints.username for the username textfield. Then add the “autofillHints” property AutofillHints.password for the password textfield as shown in Figure 3.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PYdTkOgn6tMk4z51lXrAHw.png" /><figcaption>Figure 3</figcaption></figure><p>NOTE: This save password process will work differently for iOS and Android.</p><p>That’s all, clean your build and run. When user enters the username and password and submitted the textfields, save password prompt will appead to save the password. And you try to login again for next time, you will be suggested to autofill credentials that was added before.</p><p>Happy Coding…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=33058295dd9d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>