Skip to content

Instantly share code, notes, and snippets.

@akifarhan
Last active May 27, 2021 07:05
Show Gist options
  • Save akifarhan/09e0c2dd9e6cb50283cc6f3a249e22cf to your computer and use it in GitHub Desktop.
Save akifarhan/09e0c2dd9e6cb50283cc6f3a249e22cf to your computer and use it in GitHub Desktop.
Flutter branch.io integration using flutter_branch_sdk

Guides for branch.io integration with Flutter

flutter_branch_sdk v1.4.0

Steps

Configure Branch dashboard

  1. Register your app
  2. Complete the Basic integration in Branch dashboard

ps: Apple App Prefix is equivalent to Apple Team ID. You can get the information here

Configure platform project

Android

Follow the steps from this Configure app section only.

  1. Add Branch to your AndroidManifest.xml
<manifest ...>
  <!--...other tags -->
  <application>
        <!--...other tags -->
        <!-- Launcher Activity to handle incoming Branch intents -->
        <activity
            android:name=".LauncherActivity"
            android:launchMode="singleTask"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar">

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

            <!-- Branch URI Scheme -->
            <intent-filter>
                <data android:scheme="<ANDROID_URI_SCHEME>" android:host="open" />
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
            </intent-filter>

            <!-- Branch App Links (optional) -->
            <intent-filter android:autoVerify="true">
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="https" android:host="<DEFAULT_LINK_DOMAIN>" />
                <!-- example-alternate domain is required for App Links when the Journeys/Web SDK and Deepviews are used inside your website.  -->
                <data android:scheme="https" android:host="<ALTERNATE_LINK_DOMAIN>" />
            </intent-filter>
        </activity>

        <!-- Branch init -->
        <meta-data android:name="io.branch.sdk.BranchKey" android:value="<BRANCH_KEY>" />
        <meta-data android:name="io.branch.sdk.BranchKey.test" android:value="<BRANCH_TEST_KEY>" />
        <meta-data android:name="io.branch.sdk.TestMode" android:value="false" /> <!-- Set to true to use Branch_Test_Key (useful when simulating installs and/or switching between debug and production flavors) -->
  </application>
</manifest>

<ANDROID_URI_SCHEME>, <DEFAULT_LINK_DOMAIN> and <ALTERNATE_LINK_DOMAIN> can be obtained from dashboard configuration. <BRANCH_KEY> can be obtained from dashboard account settings. To get the <BRANCH_TEST_KEY>, just switch the enviroment from LIVE to TEST at top left corner of the dashboard.

iOS integration

Follow the steps from this Configure bundle identifier.

Sections included:

  1. Configure bundle identifier
  2. Configure associated domains (Can be obtained from dashboard link domain. Please add both live and test domains.)
  3. Configure entitlements
  4. Configure Info.plist
  5. Confirm app prefix

In Info.plist, dont add branch_key live and test at the same time. Use only branch_key and update as needed.

... TBD Currently the package is clash with local_auth which require FlutterFragmentActivity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment