invertase / react-native-firebase

🔥 A well-tested feature-rich modular Firebase implementation for React Native. Supports both iOS & Android platforms for all Firebase services.
https://rnfirebase.io
Other
11.61k stars 2.19k forks source link

[🐛] 🔥 Snapchat Dynamic Link not resolving properly #6037

Closed evanlarkin10 closed 2 years ago

evanlarkin10 commented 2 years ago

My dynamic links are not working when shared via Snapchat. The same short link shared via any other method of testing (messages, messenger, copied/pasted, etc) works as expected when the app is installed, not installed and used in a web browser. In Snapchat, the link resolves to indicate redirection to our website (the url in the link parameter, not the deep link used when creating the dynamic link in the firebase console) when testing locally. With a standalone build of the app distributed via app stores, the link redirects to the app store even if the app is installed. When sharing to Snapchat via Android, the link remains static text and can't be clicked, but that may be an unrelated issue.

This is how I generate the link, but have tried many other variations including long links:

let link = await dynamicLinks().buildShortLink({
    link: value
      ? 'https://mydomain.com?post_id=${value}' // <---This is where snapchat redirects to, regardless of deep link configuration
      : 'https://mydomain.com',
    ios: {
      bundleId: 'com.mybundle.bundle',
      appStoreId: '1533465376',
    },
    android: {
      packageName: 'com.mybundle.bundle',
    },
    domainUriPrefix: 'https://<myprefixurl>.page.link',
    navigation: {
      forcedRedirectEnabled: true,
    },
  });

Project Files

Javascript

Click To Expand

#### `package.json`: ```json "@react-native-firebase/dynamic-links": "^14.1.0", "@react-native-firebase/app": "^14.1.0", ``` #### `firebase.json` for react-native-firebase v6: ```json # N/A ``` #### `creatingShareableLink.ts`: ```ts const uri = await generatePostLink(post.id, title, message, image); const options = { title, subject: title, message: `${message}`, url: uri, }; await Share.open(options); ```

iOS

Click To Expand

#### `ios/Podfile`: - [ ] I'm not using Pods - [x] I'm using Pods and my Podfile looks like: ```ruby require_relative '../node_modules/react-native/scripts/react_native_pods' require_relative '../node_modules/react-native-unimodules/cocoapods.rb' require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' platform :ios, '11.0' target 'OneSignalNotificationServiceExtension' do pod 'OneSignal', '>= 2.9.3', '< 5.0' # For Simulator Builds # pod 'OneSignalXCFramework' end target 'Dinnerbell' do use_unimodules! # React Native Maps dependencies rn_maps_path = '../node_modules/react-native-maps' pod 'react-native-google-maps', :path => rn_maps_path pod 'GoogleMaps' pod 'Google-Maps-iOS-Utils' #react-native-permissions permissions_path = '../node_modules/react-native-permissions/ios' #pod 'Permission-LocationAlways', :path => "../node_modules/react-native-permissions/ios/LocationAlways/Permission-LocationAlways.podspec" pod 'Permission-LocationWhenInUse', :path => "../node_modules/react-native-permissions/ios/LocationWhenInUse/Permission-LocationWhenInUse.podspec" pod 'Permission-Notifications', :path => "../node_modules/react-native-permissions/ios/Notifications/Permission-Notifications.podspec" pod 'Permission-PhotoLibrary', :path => "../node_modules/react-native-permissions/ios/PhotoLibrary/Permission-PhotoLibrary.podspec" pod 'Permission-Camera', :path => "../node_modules/react-native-permissions/ios/Camera/Permission-Camera.podspec" pod 'EXPermissionsInterface', :path => '../node_modules/expo-permissions-interface/ios' config = use_native_modules! use_react_native!(:path => config["reactNativePath"]) # Enables Flipper. # # Note that if you have use_frameworks! enabled, Flipper will not work and # you should disable these next few lines. use_flipper!({ 'Flipper-Folly' => '2.5.3', 'Flipper' => '0.87.0', 'Flipper-RSocket' => '1.3.1' }) # specified version from rn breaking change feb28 2020 post_install do |installer| flipper_post_install(installer) end end ``` #### `AppDelegate.m`: ```objc #import "AppDelegate.h" #import "GoogleMaps/GoogleMaps.h" #import #import #import #import // at the top #import #import #import #import #import #import #import #ifdef FB_SONARKIT_ENABLED #import #import #import #import #import #import // All imports above FB_SONARKIT_ENABLED static void InitializeFlipper(UIApplication *application) { FlipperClient *client = [FlipperClient sharedClient]; SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults]; [client addPlugin:[[FlipperKitLayoutPlugin alloc] initWithRootNode:application withDescriptorMapper:layoutDescriptorMapper]]; [client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]]; [client addPlugin:[FlipperKitReactPlugin new]]; [client addPlugin:[[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]]; [client start]; } #endif @interface AppDelegate () @property (nonatomic, strong) UMModuleRegistryAdapter *moduleRegistryAdapter; @property (nonatomic, strong) NSDictionary *launchOptions; @end @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [FIRApp configure]; // Uncomment this line to use the test key instead of the live one. // [RNBranch useTestInstance]; [RNBranch initSessionWithLaunchOptions:launchOptions isReferrable:YES]; // <-- add this NSURL *jsCodeLocation; [GMSServices provideAPIKey:@"AIzaSyB3t3uNVSb7KPDhhn1cUIk5yA3DGZzvRaE"]; #ifdef FB_SONARKIT_ENABLED InitializeFlipper(application); #endif self.moduleRegistryAdapter = [[UMModuleRegistryAdapter alloc] initWithModuleRegistryProvider:[[UMModuleRegistryProvider alloc] init]]; self.launchOptions = launchOptions; self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; #ifdef DEBUG [self initializeReactNativeApp]; #else EXUpdatesAppController *controller = [EXUpdatesAppController sharedInstance]; controller.delegate = self; [controller startAndShowLaunchScreen:self.window]; #endif [super application:application didFinishLaunchingWithOptions:launchOptions]; return YES; } - (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray> * _Nullable))restorationHandler { return [RNBranch continueUserActivity:userActivity]; } - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary *)options { return [RCTLinkingManager application:application openURL:url options:options]; } - (RCTBridge *)initializeReactNativeApp { RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:self.launchOptions]; RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"main" initialProperties:nil]; rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1]; self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; UIViewController *rootViewController = [UIViewController new]; rootViewController.view = rootView; self.window.rootViewController = rootViewController; [self.window makeKeyAndVisible]; return bridge; } - (NSArray> *)extraModulesForBridge:(RCTBridge *)bridge { NSArray> *extraModules = [_moduleRegistryAdapter extraModulesForBridge:bridge]; // If you'd like to export some custom RCTBridgeModules that are not Expo modules, add them here! return extraModules; } - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge { #ifdef DEBUG return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; #else return [[EXUpdatesAppController sharedInstance] launchAssetUrl]; #endif } - (void)appController:(EXUpdatesAppController *)appController didStartWithSuccess:(BOOL)success { appController.bridge = [self initializeReactNativeApp]; EXSplashScreenService *splashScreenService = (EXSplashScreenService *)[UMModuleRegistryProvider getSingletonModuleForClass:[EXSplashScreenService class]]; [splashScreenService showSplashScreenFor:self.window.rootViewController]; } @end ```


Android

Click To Expand

#### Have you converted to AndroidX? - [x] my application is an AndroidX application? - [x] I am using `android/gradle.settings` `jetifier=true` for Android compatibility? - [ ] I am using the NPM package `jetifier` for react-native compatibility? #### `android/build.gradle`: ```groovy // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { ext { buildToolsVersion = "29.0.2" minSdkVersion = 21 compileSdkVersion = 30 targetSdkVersion = 30 kotlinVersion = "1.4.0" androidXCore = "1.6.0" // Only using Android Support libraries supportLibVersion = "28.0.0" } repositories { google() jcenter() } dependencies { classpath('com.android.tools.build:gradle:4.1.1') classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.0" classpath 'com.google.gms:google-services:4.3.10' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { google() mavenLocal() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url("$rootDir/../node_modules/react-native/android") } maven { // Android JSC is installed from npm url("$rootDir/../node_modules/jsc-android/dist") } /* configurations.all { resolutionStrategy { // use 0.9.0 to fix crash on Android 11 force "com.facebook.soloader:soloader:0.9.0+" } } */ jcenter() maven { url 'https://www.jitpack.io' } } } ``` #### `android/app/build.gradle`: ```groovy buildscript { repositories { gradlePluginPortal() } dependencies { classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.10, 0.99.99]' } } apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin' apply plugin: "com.android.application" apply plugin: 'com.google.gms.google-services' import com.android.build.OutputFile /** * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets * and bundleReleaseJsAndAssets). * These basically call `react-native bundle` with the correct arguments during the Android build * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the * bundle directly from the development server. Below you can see all the possible configurations * and their defaults. If you decide to add a configuration block, make sure to add it before the * `apply from: "../../node_modules/react-native/react.gradle"` line. * * project.ext.react = [ * // the name of the generated asset file containing your JS bundle * bundleAssetName: "index.android.bundle", * * // the entry file for bundle generation. If none specified and * // "index.android.js" exists, it will be used. Otherwise "index.js" is * // default. Can be overridden with ENTRY_FILE environment variable. * entryFile: "index.android.js", * * // https://reactnative.dev/docs/performance#enable-the-ram-format * bundleCommand: "ram-bundle", * * // whether to bundle JS and assets in debug mode * bundleInDebug: false, * * // whether to bundle JS and assets in release mode * bundleInRelease: true, * * // whether to bundle JS and assets in another build variant (if configured). * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants * // The configuration property can be in the following formats * // 'bundleIn${productFlavor}${buildType}' * // 'bundleIn${buildType}' * // bundleInFreeDebug: true, * // bundleInPaidRelease: true, * // bundleInBeta: true, * * // whether to disable dev mode in custom build variants (by default only disabled in release) * // for example: to disable dev mode in the staging build type (if configured) * devDisabledInStaging: true, * // The configuration property can be in the following formats * // 'devDisabledIn${productFlavor}${buildType}' * // 'devDisabledIn${buildType}' * * // the root of your project, i.e. where "package.json" lives * root: "../../", * * // where to put the JS bundle asset in debug mode * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", * * // where to put the JS bundle asset in release mode * jsBundleDirRelease: "$buildDir/intermediates/assets/release", * * // where to put drawable resources / React Native assets, e.g. the ones you use via * // require('./image.png')), in debug mode * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", * * // where to put drawable resources / React Native assets, e.g. the ones you use via * // require('./image.png')), in release mode * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", * * // by default the gradle tasks are skipped if none of the JS files or assets change; this means * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to * // date; if you have any other folders that you want to ignore for performance reasons (gradle * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ * // for example, you might want to remove it from here. * inputExcludes: ["android/**", "ios/**"], * * // override which node gets called and with what additional arguments * nodeExecutableAndArgs: ["node"], * * // supply additional arguments to the packager * extraPackagerArgs: [] * ] */ project.ext.react = [ enableHermes: true, nodeExecutableAndArgs: ["node", "--max-old-space-size=8192"] ] apply from: '../../node_modules/react-native-unimodules/gradle.groovy' apply from: "../../node_modules/react-native/react.gradle" apply from: "../../node_modules/expo-updates/scripts/create-manifest-android.gradle" apply from: "../../node_modules/react-native-vector-icons/fonts.gradle" project.ext.envConfigFiles = [ debug: ".env.qa", release: ".env.qa", qarelease: ".env.qa", devrelease: ".env.dev", stagerelease: ".env.stage", productionrelease: ".env.prod" ] apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle" /** * Set this to true to create two separate APKs instead of one: * - An APK that only works on ARM devices * - An APK that only works on x86 devices * The advantage is the size of the APK is reduced by about 4MB. * Upload all the APKs to the Play Store and people will download * the correct one based on the CPU architecture of their device. */ def enableSeparateBuildPerCPUArchitecture = false /** * Run Proguard to shrink the Java bytecode in release builds. */ def enableProguardInReleaseBuilds = false /** * The preferred build flavor of JavaScriptCore. * * For example, to use the international variant, you can use: * `def jscFlavor = 'org.webkit:android-jsc-intl:+'` * * The international variant includes ICU i18n library and necessary data * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that * give correct results when using with locales other than en-US. Note that * this variant is about 6MiB larger per architecture than default. */ def jscFlavor = 'org.webkit:android-jsc:+' /** * Whether to enable the Hermes VM. * * This should be set on project.ext.react and mirrored here. If it is not set * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode * and the benefits of using Hermes will therefore be sharply reduced. */ def enableHermes = project.ext.react.get("enableHermes", false); android { packagingOptions { pickFirst 'lib/x86/libc++_shared.so' pickFirst 'lib/x86_64/libjsc.so' pickFirst 'lib/arm64-v8a/libjsc.so' pickFirst 'lib/arm64-v8a/libc++_shared.so' pickFirst 'lib/x86_64/libc++_shared.so' pickFirst 'lib/armeabi-v7a/libc++_shared.so' } compileSdkVersion rootProject.ext.compileSdkVersion compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } defaultConfig { configurations.all { resolutionStrategy { force 'androidx.work:work-runtime:2.6.0' } } applicationId 'com.dinnerbellmarketing.dinnerbell' minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion // For QR scanner missingDimensionStrategy 'react-native-camera', 'general' versionCode 39 versionName "1.0.9" // Read the API key from ./secure.properties into R.string.maps_api_key def secureProps = new Properties() if (file("../secure.properties").exists()) { file("../secure.properties")?.withInputStream { secureProps.load(it) } } resValue "string", "maps_api_key", (secureProps.getProperty("MAPS_API_KEY") ?: "") } splits { abi { reset() enable enableSeparateBuildPerCPUArchitecture universalApk false // If true, also generate a universal APK include "armeabi-v7a", "x86", "arm64-v8a", "x86_64" } } signingConfigs { debug { storeFile file('debug.keystore') storePassword 'android' keyAlias 'androiddebugkey' keyPassword 'android' } } buildTypes { debug { signingConfig signingConfigs.debug } release { // Caution! In production, you need to generate your own keystore file. // see https://reactnative.dev/docs/signed-apk-android. signingConfig signingConfigs.debug minifyEnabled enableProguardInReleaseBuilds proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" } qarelease { initWith release matchingFallbacks = ['release', 'debug'] } devrelease { initWith release matchingFallbacks = ['release', 'debug'] } stagerelease { initWith release matchingFallbacks = ['release', 'debug'] } productionrelease { initWith release matchingFallbacks = ['release', 'debug'] } } // applicationVariants are e.g. debug, release applicationVariants.all { variant -> variant.outputs.each { output -> // For each separate APK per architecture, set a unique version code as described here: // https://developer.android.com/studio/build/configure-apk-splits.html def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4] def abi = output.getFilter(OutputFile.ABI) if (abi != null) { // null for the universal-debug, universal-release variants output.versionCodeOverride = versionCodes.get(abi) * 1048576 + defaultConfig.versionCode } } } } dependencies { implementation platform('com.google.firebase:firebase-bom:29.0.3') implementation "com.google.firebase:firebase-iid" implementation 'com.google.firebase:firebase-analytics' implementation 'com.google.firebase:firebase-dynamic-links' // Fixes launch failure implementation 'com.facebook.soloader:soloader:0.9.0+' debugImplementation 'com.facebook.soloader:soloader:0.9.0+' releaseImplementation 'com.facebook.soloader:soloader:0.9.0+' qareleaseImplementation 'com.facebook.soloader:soloader:0.9.0+' stagereleaseImplementation 'com.facebook.soloader:soloader:0.9.0+' devreleaseImplementation 'com.facebook.soloader:soloader:0.9.0+' productionreleaseImplementation 'com.facebook.soloader:soloader:0.9.0+' //End fix launch failure implementation fileTree(dir: "libs", include: ["*.jar"]) //noinspection GradleDynamicVersion implementation "com.facebook.react:react-native:+" // From node_module implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0" implementation 'androidx.appcompat:appcompat:1.1.0-rc01' debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") { exclude group:'com.facebook.fbjni' } debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { exclude group:'com.facebook.flipper' exclude group:'com.squareup.okhttp3', module:'okhttp' } debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") { exclude group:'com.facebook.flipper' } addUnimodulesDependencies() if (enableHermes) { def hermesPath = "../../node_modules/hermes-engine/android/"; debugImplementation files(hermesPath + "hermes-debug.aar") releaseImplementation files(hermesPath + "hermes-release.aar") //Fix launch failure devreleaseImplementation files(hermesPath + "hermes-release.aar") qareleaseImplementation files(hermesPath + "hermes-release.aar") stagereleaseImplementation files(hermesPath + "hermes-release.aar") productionreleaseImplementation files(hermesPath + "hermes-release.aar") //End fix launch failure } else { implementation jscFlavor } } // Run this once to be able to run the application with BUCK // puts all compile dependencies into folder libs for BUCK to use task copyDownloadableDepsToLibs(type: Copy) { from configurations.compile into 'libs' } apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) googleServices { disableVersionCheck = true } ``` #### `AndroidManifest.xml`: ```xml ```


Environment

Click To Expand

**`react-native info` output:** ``` OUTPUT GOES HERE ``` - **Platform that you're experiencing the issue on**: - [x] iOS - [x] Android - [ ] **iOS** but have not tested behavior on Android - [ ] **Android** but have not tested behavior on iOS - [ ] Both - **`react-native-firebase` version you're using that has this issue:** ``` "@react-native-firebase/app": "^14.1.0", "@react-native-firebase/dynamic-links": "^14.1.0" ``` - **`Firebase` module(s) you're using that has the issue:** - `dynamic-links` - **Are you using `TypeScript`?** - `Y` & `~4.0.0`

mikehardy commented 2 years ago

Interesting - this is an area of some difficulty, in the underlying SDKs. There's nothing react-native-firebase is doing specifically here, and react-native-share suffers from similar app-specific / share-method-specific issues on an app by app share-target basis.

"@react-native-firebase/dynamic-links": "^14.1.0",
"@react-native-firebase/app": "^14.1.0",

We update the underlying SDKs as we update versions, logging issues against old versions is not as useful as logging against current ones and making sure it still reproduces

If you can still reproduce against a current version of react-native-firebase, I'd try a quickstart reproduction against the underlying SDK to see if you have similar issues, I'm guessing it will reproduce in the underlying SDK as well:

https://github.com/firebase/quickstart-android/tree/master/dynamiclinks

evanlarkin10 commented 2 years ago

Hi Mike, Thanks for the response. I have used the quickstart sdk to test. There are still some interesting things happening here.

Sharing via Snapchat from the quick start app send the dynamic link as plaintext, therefore it can't be clicked and Snapchat doesn't 'resolve' the URL. I tried sending the link to an iOS device through snapchat, copying, re-pasting, and sending it back to the Android. The link is clickable, and launches the app but doesn't show the received link. I think this differs from my issue where, when sent from iOS, the link opens the receive link, and doesn't launch the app.

All other methods of testing show the receive link, and when uninstalled shows the app store page.

Without distributing the app I can't test whether or not it goes to the app store instead of the app. But I think the real issue is that Snapchat doesn't recognize it as a link on Android (probably not a fault of this library). But I guess I'm still not sure why on my app Snapchat links to the receive link on iOS.

stale[bot] commented 2 years ago

Hello 👋, to help manage issues we automatically close stale issues. This issue has been automatically marked as stale because it has not had activity for quite some time. Has this issue been fixed, or does it still require the community's attention?

This issue will be closed in 15 days if no further activity occurs. Thank you for your contributions.

stale[bot] commented 2 years ago

Closing this issue after a prolonged period of inactivity. If this is still present in the latest release, please feel free to create a new issue with up-to-date information.

zain-khalid commented 1 year ago

@evanlarkin10 I am facing this same issue for android case. Did you resolve this issue? IF resolve === true than please share your findings.

Thank You