All files / src withDeepLinks.ts

100% Statements 7/7
100% Branches 2/2
100% Functions 2/2
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28        4x     32x 5x 5x   5x               4x     5x          
import { withAndroidManifest, type ConfigPlugin } from 'expo/config-plugins';
 
import type { ConfigPluginPropsWithDefaults } from './withIterable.types';
 
export const withDeepLinks: ConfigPlugin<ConfigPluginPropsWithDefaults> = (
  config
) => {
  return withAndroidManifest(config, (newConfig) => {
    const application = newConfig.modResults.manifest?.application?.[0];
    const activity = application?.activity?.[0];
 
    if (activity) {
      /**
       * Set the launch mode to singleTask to prevent multiple deep links from
       * opening multiple copies of the same activity in the same app.
       *
       * @see Step 2:
       * https://support.iterable.com/hc/en-us/articles/360046134911-Deep-Links-and-Custom-Actions-with-Iterable-s-React-Native-SDK#step-2-update-native-code-for-android
       */
      activity.$['android:launchMode'] = 'singleTask';
    }
 
    return newConfig;
  });
};
 
export default withDeepLinks;