flutter_branch_sdk icon indicating copy to clipboard operation
flutter_branch_sdk copied to clipboard

No data from the deep link from the listenSession stream [iOS]

Open Hozefa04 opened this issue 1 year ago • 4 comments

Describe the bug I had integrated flutter_branch_sdk in my flutter app a while ago and everything was working fine until couple of weeks ago when on iOS, flutter branch sdk suddenly stopped working. The app is in production and I have literally changed nothing to my code or branch setup. When I validate my integration on iOS, it gives me the dialog [screenshot below] with URI mismatch error. I contacted branch io team and provided them with necessary code and screenshots and they confirmed that my setup looks correct. They asked me to use the latest version of flutter_branch_sdk so I upgraded the sdk but still facing the same issue.

Screenshots image

Smartphone (Please complete the following information. remove session if not platform):

  • Flutter: version: 3.19.5
  • Package version: 7.3.0
  • OS: iOS 17.4
  • Device: iPhone 12, iPhone 13, Simulator iPhone 15 Pro Max

My info.plist config:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>CADisableMinimumFrameDurationOnPhone</key>
    <true/>
    <key>CFBundleDevelopmentRegion</key>
    <string>$(DEVELOPMENT_LANGUAGE)</string>
    <key>CFBundleDisplayName</key>
    <string>ShotCaller</string>
    <key>CFBundleExecutable</key>
    <string>$(EXECUTABLE_NAME)</string>
    <key>CFBundleIdentifier</key>
    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>ShotCaller</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>$(MARKETING_VERSION)</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleURLTypes</key>
    <array>
      <dict>
        <key>CFBundleURLName</key>
        <string>com.app.shotcaller</string>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>shotcaller</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>playshotcaller</string>
        </array>
        <key>CFBundleURLName</key>
        <string>io.Branch.Playshotcaller</string>
      </dict>
      <dict>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>...</string>
          <string>...</string>
          <string>...</string>
          <string>...</string>
        </array>
      </dict>
      <dict>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLName</key>
        <string>com.playshotcaller.shotcaller.payments</string>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>com.playshotcaller.shotcaller.payments</string>
        </array>
      </dict>
    </array>
    <key>CFBundleVersion</key>
    <string>$(CURRENT_PROJECT_VERSION)</string>
    <key>FacebookAppID</key>
    <string>...</string>
    <key>FacebookClientToken</key>
    <string>...</string>
    <key>FacebookDisplayName</key>
    <string>ShotCaller</string>
    <key>ITSAppUsesNonExemptEncryption</key>
    <false/>
    <key>LSApplicationQueriesSchemes</key>
    <array>
      <string>metamask</string>
      <string>fbapi</string>
      <string>fbapi20130214</string>
      <string>fbapi20130410</string>
      <string>fbapi20130702</string>
      <string>fbapi20131010</string>
      <string>fbapi20131219</string>
      <string>fbapi20140410</string>
      <string>fbapi20140116</string>
      <string>fbapi20150313</string>
      <string>fbapi20150629</string>
      <string>fbapi20160328</string>
      <string>fbauth</string>
      <string>fb-messenger-share-api</string>
      <string>fbauth2</string>
      <string>fbshareextension</string>
      <string>metamask</string>
      <string>instagram</string>
      <string>fb</string>
      <string>facebook-reels</string>
      <string>facebook-stories</string>
      <string>fb-messenger</string>
      <string>tg</string>
      <string>whatsapp</string>
      <string>twitter</string>
      <string>instagram-stories</string>
      <string>facebook</string>
      <string>whatsapp</string>
      <string>tiktokopensdk</string>
      <string>tiktoksharesdk</string>
      <string>snssdk1180</string>
      <string>snssdk1233</string>
    </array>
    <key>TikTokAppID</key>
    <string>...</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>NSAppleMusicUsageDescription</key>
    <string>This permission is not needed by the app, but it is required by an underlying API. If you see this dialog, contact us.</string>
    <key>NSBluetoothAlwaysUsageDescription</key>
    <string>This permission is not needed by the app, but it is required by an underlying API. If you see this dialog, contact us.</string>
    <key>NSBluetoothPeripheralUsageDescription</key>
    <string>This permission is not needed by the app, but it is required by an underlying API. If you see this dialog, contact us.</string>
    <key>NSCalendarsUsageDescription</key>
    <string>This permission is not needed by the app, but it is required by an underlying API. If you see this dialog, contact us.</string>
    <key>NSCameraUsageDescription</key>
    <string>Allow access to camera to capture photos to change profile image</string>
    <key>NSContactsUsageDescription</key>
    <string>This permission is not needed by the app, but it is required by an underlying API. If you see this dialog, contact us.</string>
    <key>EnableBackgroundLocationUpdates</key>
    <true/>
    <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
    <string>App requires location to show relevant contest in user&apos;s region</string>
    <key>NSLocationAlwaysUsageDescription</key>
    <string>App requires location to show relevant contest in user&apos;s region</string>
    <key>NSLocationWhenInUseUsageDescription</key>
    <string>App requires location to show relevant contest in user&apos;s region</string>
    <key>NSMicrophoneUsageDescription</key>
    <string>Allow access to microphone</string>
    <key>NSMotionUsageDescription</key>
    <string>This permission is not needed by the app, but it is required by an underlying API. If you see this dialog, contact us.</string>
    <key>NSPhotoLibraryUsageDescription</key>
    <string>Allow access to photo library to choose photo to change profile image</string>
    <key>NSPhotoLibraryAddUsageDescription</key>
    <string>Allow access to photo library to save rank photos</string>
    <key>NSRemindersUsageDescription</key>
    <string>This permission is not needed by the app, but it is required by an underlying API. If you see this dialog, contact us.</string>
    <key>NSSpeechRecognitionUsageDescription</key>
    <string>This permission is not needed by the app, but it is required by an underlying API. If you see this dialog, contact us.</string>
    <key>UIApplicationSupportsIndirectInputEvents</key>
    <true/>
    <key>UIBackgroundModes</key>
    <array>
      <string>fetch</string>
      <string>location</string>
      <string>remote-notification</string>
    </array>
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>UIMainStoryboardFile</key>
    <string>Main</string>
    <key>UISupportedInterfaceOrientations</key>
    <array>
      <string>UIInterfaceOrientationPortrait</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
      <string>UIInterfaceOrientationPortrait</string>
      <string>UIInterfaceOrientationPortraitUpsideDown</string>
      <string>UIInterfaceOrientationLandscapeLeft</string>
      <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UIViewControllerBasedStatusBarAppearance</key>
    <false/>
    <key>branch_key</key>
    <string>key_live_lo7cJkaiHyZd...</string>
    <key>branch_universal_link_domains</key>
    <array>
      <string>playshotcaller.app.link</string>
      <string>playshotcaller-alternate.app.link</string>
      <string>playshotcaller.test-app.link</string>
      <string>playshotcaller-alternate.test-app.link</string>
    </array>
    <key>branch_check_pasteboard</key>
    <true/>
    <key>NSBonjourServices</key>
    <array>
      <string>_dartobservatory._tcp</string>
    </array>
  </dict>
</plist>

Hozefa04 avatar Apr 23 '24 05:04 Hozefa04

Hi @Hozefa04

This plugin forms a bridge between Dart/flutter and the Branch SDK.

It calls functions in the native Branch SDK.

Validation of the app's schema is not performed by the flutter plugin, but by the SDK on iOS.

If the validation method is saying that the schema is wrong, it is because the native SDK found an error in INFO.PLIST.

If you check the instructions on this page here: https://help.branch.io/developers-hub/docs/ios-basic-integration#4-configure-infoplist

image

I noticed that your CFBundleURLName key in INFO.PLIST contains one more key than in the example and also in relation to the sample application.

 <dict>
        <key>CFBundleURLName</key>
        <string>com.app.shotcaller</string>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>shotcaller</string>
        </array>
      </dict>

You can check this configuration.

RodrigoSMarques avatar Apr 23 '24 14:04 RodrigoSMarques

@RodrigoSMarques Thanks for the reply. I understand that its not the SDK's fault as it used to work with the current settings before it just stopped working all of a sudden. I will keep looking for a fix and maybe redo the setup once again to see if there's anything new that they have added. I will close this for now but if i find something then I will drop a reply here incase anyone else faces the same issue.

Hozefa04 avatar Apr 24 '24 07:04 Hozefa04

@RodrigoSMarques I re-did the branch io setup and was able to fix the URI mismatch error. Now when I click on a link, I get no data from the links in the listenSession() stream. Here's how my code looks like:

main() code:

await FlutterBranchSdk.init(enableLogging: true);
FlutterBranchSdk.validateSDKIntegration();

in initState:

FlutterBranchSdk.listSession().listen((data) async {
    print("Deep link:: $data");
});

log in the console when I click on a link: Deep link:: {+is_first_session: false, +clicked_branch_link: false}

Attaching the screenshot from the validateSDKIntegration() call Simulator Screenshot - iPhone 15 Pro Max - 2024-04-25 at 15 56 06

Hozefa04 avatar Apr 25 '24 10:04 Hozefa04

This generally occurs when the project is configured with the test key and is tested with production links or configured with the production key and tested with test links.

Check your configuration.

Open the project in XCode and run it.

Check the BranchSDK logs to see which key and URL is being passed to the API.

The FlutterBranchSdk.listSession method show the result of processing the native API call that captures the link and returns the result.

RodrigoSMarques avatar Apr 26 '24 21:04 RodrigoSMarques

@RodrigoSMarques I tried that and all I get in logs is this:

Branch InitSession params: Optional(["+clicked_branch_link": 0, "+is_first_session": 0])

Like I mentioned, the deep links work fine on Android but the issue persists only on iOS. I have also updated the SDK to the latest version (8.0.1)

These are the logs for Branch Initialisation

** Initiating Branch integration verification **
-------------------------------------------------
------ Checking for URI scheme correctness ------
PASS: Dashboard Link Settings page 'playshotcaller://' compared to client side 'playshotcaller://'
-------------------------------------------------
-- Checking for bundle identifier correctness ---
PASS: Dashboard Link Settings page 'com.app.shotcaller' compared to client side 'com.app.shotcaller'
-------------------------------------------------
----- Checking for iOS Team ID correctness ------
PASS: Dashboard Link Settings page 'A5WN3F8742' compared to client side 'A5WN3F8742'
-------------------------------------------------
-------------------------------------------------------------------------------------------------------------------

-----To test your deeplink routing append ?bnc_validate=true to any branch link and click it on your mobile device-----
----------------------------------------------------------------------------
Branch Integration Next Steps:

Great! Remove the 'validateSDKIntegration' line in your app.

Next check your deep link routing.

Append '?bnc_validate=true' to any of your app's Branch links and click on it on your mobile device (not the Simulator!) to start the test.

For instance, to validate a link like:
https://<yourapp>.app.link/NdJ6nFzRbK

click on:
https://<yourapp>.app.link/NdJ6nFzRbK?bnc_validate=true
----------------------------------------------------------------------------

I am seriously stuck bad and I don't know what else to do.

Hozefa04 avatar May 20 '24 07:05 Hozefa04

@RodrigoSMarques I tried that and all I get in logs is this:

Branch InitSession params: Optional(["+clicked_branch_link": 0, "+is_first_session": 0])

Like I mentioned, the deep links work fine on Android but the issue persists only on iOS. I have also updated the SDK to the latest version (8.0.1)

These are the logs for Branch Initialisation

** Initiating Branch integration verification **
-------------------------------------------------
------ Checking for URI scheme correctness ------
PASS: Dashboard Link Settings page 'playshotcaller://' compared to client side 'playshotcaller://'
-------------------------------------------------
-- Checking for bundle identifier correctness ---
PASS: Dashboard Link Settings page 'com.app.shotcaller' compared to client side 'com.app.shotcaller'
-------------------------------------------------
----- Checking for iOS Team ID correctness ------
PASS: Dashboard Link Settings page 'A5WN3F8742' compared to client side 'A5WN3F8742'
-------------------------------------------------
-------------------------------------------------------------------------------------------------------------------

-----To test your deeplink routing append ?bnc_validate=true to any branch link and click it on your mobile device-----
----------------------------------------------------------------------------
Branch Integration Next Steps:

Great! Remove the 'validateSDKIntegration' line in your app.

Next check your deep link routing.

Append '?bnc_validate=true' to any of your app's Branch links and click on it on your mobile device (not the Simulator!) to start the test.

For instance, to validate a link like:
https://<yourapp>.app.link/NdJ6nFzRbK

click on:
https://<yourapp>.app.link/NdJ6nFzRbK?bnc_validate=true
----------------------------------------------------------------------------

I am seriously stuck bad and I don't know what else to do.

If you followed the setup instructions and reviewed it, unfortunately I can't support it.

Configuration validation is performed by the Branch Native SDK on iOS and not by the Dart/Flutter plugin.

The plugin just calls the validation function in the native layer.

I suggest you open an issue in the iOS repository: https://github.com/BranchMetrics/ios-branch-deep-linking-attribution

RodrigoSMarques avatar May 20 '24 16:05 RodrigoSMarques

I am closing this as I found the issue. Some native code from a share package that I am using was somehow conflicting with the SDK. I am still not sure why but after removing that code, deep links are working again!

Hozefa04 avatar May 31 '24 15:05 Hozefa04