How to use the expo-constants.appOwnership function in expo-constants

To help you get started, we’ve selected a few expo-constants examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github alan-ai / alan-sdk-reactnative / testtools / node_modules / expo-linking / src / Linking.ts View on Github external
// We don't have a manifest in bare workflow except after publishing, so warn people in development.
  if (!Constants.manifest) {
    console.warn(
      'Linking.makeUrl is not supported in bare workflow. Switch to using your scheme string directly.'
    );
    return '';
  }

  let scheme = 'exp';
  const manifestScheme = manifest.scheme ?? manifest?.detach?.scheme;

  if (Constants.appOwnership === 'standalone' && manifestScheme) {
    scheme = manifestScheme;
  } else if (Constants.appOwnership === 'standalone' && !manifestScheme) {
    throw new Error('Cannot make a deep link into a standalone app with no custom scheme defined');
  } else if (Constants.appOwnership === 'expo' && !manifestScheme) {
    console.warn(
      'Linking requires that you provide a `scheme` in app.json for standalone apps - if it is left blank, your app may crash. The scheme does not apply to development in the Expo client but you should add it as soon as you start working with Linking to avoid creating a broken build. Add a `scheme` to silence this warning. Learn more about Linking at https://docs.expo.io/versions/latest/workflow/linking/'
    );
  }

  let hostUri = getHostUri() || '';
  if (usesCustomScheme() && isExpoHosted()) {
    hostUri = '';
  }

  if (path) {
    if (isExpoHosted() && hostUri) {
      path = `/--/${removeLeadingSlash(path)}`;
    }
    if (!path.startsWith('/')) {
      path = `/${path}`;
github alan-ai / alan-sdk-reactnative / testtools / node_modules / expo-linking / src / Linking.ts View on Github external
return encodeURI(`${origin}${outputPath}${queryString}`);
  }

  // We don't have a manifest in bare workflow except after publishing, so warn people in development.
  if (!Constants.manifest) {
    console.warn(
      'Linking.makeUrl is not supported in bare workflow. Switch to using your scheme string directly.'
    );
    return '';
  }

  let scheme = 'exp';
  const manifestScheme = manifest.scheme ?? manifest?.detach?.scheme;

  if (Constants.appOwnership === 'standalone' && manifestScheme) {
    scheme = manifestScheme;
  } else if (Constants.appOwnership === 'standalone' && !manifestScheme) {
    throw new Error('Cannot make a deep link into a standalone app with no custom scheme defined');
  } else if (Constants.appOwnership === 'expo' && !manifestScheme) {
    console.warn(
      'Linking requires that you provide a `scheme` in app.json for standalone apps - if it is left blank, your app may crash. The scheme does not apply to development in the Expo client but you should add it as soon as you start working with Linking to avoid creating a broken build. Add a `scheme` to silence this warning. Learn more about Linking at https://docs.expo.io/versions/latest/workflow/linking/'
    );
  }

  let hostUri = getHostUri() || '';
  if (usesCustomScheme() && isExpoHosted()) {
    hostUri = '';
  }

  if (path) {
    if (isExpoHosted() && hostUri) {
github expo / expo / packages / expo / build / Linking / Linking.js View on Github external
import Constants from 'expo-constants';
import qs from 'qs';
import Linking from './LinkingModule';
const { manifest } = Constants;
const USES_CUSTOM_SCHEME = Constants.appOwnership === 'standalone' && manifest.scheme;
let HOST_URI = manifest.hostUri;
if (!HOST_URI && !USES_CUSTOM_SCHEME) {
    // we're probably not using up-to-date xdl, so just fake it for now
    // we have to remove the /--/ on the end since this will be inserted again later
    HOST_URI = _removeScheme(Constants.linkingUri).replace(/\/--($|\/.*$)/, '');
}
const IS_EXPO_HOSTED = HOST_URI &&
    (/^(.*\.)?(expo\.io|exp\.host|exp\.direct|expo\.test)(:.*)?(\/.*)?$/.test(HOST_URI) ||
        manifest.developer);
function _removeScheme(url) {
    return url.replace(/^[a-zA-Z0-9+.-]+:\/\//, '');
}
function _removePort(url) {
    return url.replace(/(?=([a-zA-Z0-9+.-]+:\/\/)?[^/]):\d+/, '');
}
function _removeLeadingSlash(url) {
github expo / expo / packages / expo-google-sign-in / build / GoogleSignIn.js View on Github external
function validateOwnership() {
    invariant(_isClientUsageEnabled || Constants.appOwnership !== 'expo', 'expo-google-sign-in is not supported in the Expo Client because a custom URL scheme is required at build time. Please refer to the docs for usage outside of Expo www.npmjs.com/package/expo-google-sign-in');
}
async function ensureGoogleIsInitializedAsync(options) {
github expo / expo / packages / expo-font / src / FontLoader.ts View on Github external
import { Asset } from 'expo-asset';
import Constants from 'expo-constants';
import { Platform } from 'react-native';

import { CodedError } from '@unimodules/core';
import ExpoFontLoader from './ExpoFontLoader';
import { FontResource, FontSource } from './Font.types';

const isInClient = Constants.appOwnership === 'expo';
const isInIOSStandalone = Constants.appOwnership === 'standalone' && Platform.OS === 'ios';

export function fontFamilyNeedsScoping(name: string): boolean {
  return (
    (isInClient || isInIOSStandalone) &&
    !Constants.systemFonts.includes(name) &&
    name !== 'System' &&
    !name.includes(Constants.sessionId)
  );
}

export function getAssetForSource(source: FontSource): Asset | FontResource {
  if (source instanceof Asset) {
    return source;
  }
github expo / expo / packages / expo-font / build / FontLoader.js View on Github external
import { Asset } from 'expo-asset';
import Constants from 'expo-constants';
import { Platform } from 'react-native';
import { CodedError } from '@unimodules/core';
import ExpoFontLoader from './ExpoFontLoader';
const isInClient = Constants.appOwnership === 'expo';
const isInIOSStandalone = Constants.appOwnership === 'standalone' && Platform.OS === 'ios';
export function fontFamilyNeedsScoping(name) {
    return ((isInClient || isInIOSStandalone) &&
        !Constants.systemFonts.includes(name) &&
        name !== 'System' &&
        !name.includes(Constants.sessionId));
}
export function getAssetForSource(source) {
    if (source instanceof Asset) {
        return source;
    }
    if (typeof source === 'string') {
        return Asset.fromURI(source);
    }
    else if (typeof source === 'number') {
        return Asset.fromModule(source);
    }
github wheatandcat / Peperomia / PeperomiaNative / src / containers / Auth.tsx View on Github external
const isStandaloneAndAndroid = () => {
  return Platform.OS === 'android' && Constants.appOwnership !== 'expo';
};
github expo / expo / apps / native-component-list / src / screens / BranchScreen.tsx View on Github external
render() {
    if (Constants.appOwnership !== 'standalone') {
      return (
        
      );
    }
    return (
github expo / expo / packages / expo-google-app-auth / src / Google.ts View on Github external
import * as AppAuth from 'expo-app-auth';
import Constants from 'expo-constants';
import { Platform } from 'react-native';

import { CodedError } from '@unimodules/core';

const isInExpo = Constants.appOwnership === 'expo';
export type GoogleLogInConfig = {
  androidClientId?: string;
  iosClientId?: string;
  androidStandaloneAppClientId?: string;
  iosStandaloneAppClientId?: string;
  /** Deprecated: You will need to use expo-google-sign-in to do server side authentication outside of the Expo client */
  webClientId?: string;
  /**
   * System authentication is very different from web auth.
   * All system functionality has been moved to expo-google-sign-in
   */
  behavior?: 'system' | 'web';
  scopes?: string[];
  /**
   * Optionally you can define your own redirect URL.
   * If this isn't defined then it will be infered from the correct client ID.
github expo / expo / packages / expo / src / Linking / Linking.ts View on Github external
function makeUrl(path: string = '', queryParams: Object = {}): string {
  let scheme = 'exp';
  if (Constants.appOwnership === 'standalone') {
    scheme = manifest.scheme || (manifest.detach && manifest.detach.scheme);
  }
  if (!scheme) {
    throw new Error('Cannot make a deep link into a standalone app with no custom scheme defined');
  }

  let hostUri = HOST_URI || '';
  if (USES_CUSTOM_SCHEME && IS_EXPO_HOSTED) {
    hostUri = '';
  }

  if (path) {
    if (IS_EXPO_HOSTED && hostUri) {
      path = `/--/${_removeLeadingSlash(path)}`;
    }