How to use the expo-core.Platform.OS function in expo-core

To help you get started, we’ve selected a few expo-core 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 expo / expo / modules / expo-firebase-links / src / index.js View on Github external
multiApp: false,
      hasShards: false,
      namespace: NAMESPACE,
    });

    SharedEventEmitter.addListener(
      // sub to internal native event - this fans out to
      // public event name: onMessage
      'links_link_received',
      ({ link }) => {
        SharedEventEmitter.emit('onLink', link);
      }
    );

    // Tell the native module that we're ready to receive events
    if (Platform.OS === 'ios') {
      getNativeModule(this).jsInitialised();
    }
  }
github expo / expo / modules / expo-firebase-notifications / src / index.js View on Github external
results: notificationOpen.results,
        });
      }
    );

    SharedEventEmitter.addListener(
      // sub to internal native event - this fans out to
      // public event name: onNotification
      'notifications_notification_received',
      (notification: NativeNotification) => {
        SharedEventEmitter.emit('onNotification', new Notification(notification));
      }
    );

    // Tell the native module that we're ready to receive events
    if (Platform.OS === 'ios') {
      getNativeModule(this).jsInitialised();
    }
  }
github expo / expo / packages / expo-asset / src / Asset.ts View on Github external
// because resolveAssetSource depends on it
    if (!MANAGED_ENV) {
      const { uri } = resolveAssetSource(virtualAssetModule);
      const asset = new Asset({
        name: meta.name,
        type: meta.type,
        hash: meta.hash,
        uri,
        width: meta.width,
        height: meta.height,
      });

      // TODO: FileSystem should probably support 'downloading' from drawable resources
      // But for now it doesn't and React Native's Image works fine with drawable resource
      // names for images.
      if (Platform.OS === 'android' && !uri.includes(':') && (meta.width || meta.height)) {
        asset.localUri = asset.uri;
        asset.downloaded = true;
      }

      Asset.byHash[meta.hash] = asset;
      return asset;
    }

    return Asset.fromMetadata(meta);
  }
github expo / expo / packages / expo / src / Localization.ts View on Github external
},
      });

      const methods = new Set(['setLocale']);
      for (const name of localizedValues.keys()) {
        if (methods.has(name)) {
          throw new Error(`Cannot use ${name} as a locale name`);
        }
        Object.defineProperty(proxy, name, {
          get() {
            return localizationValueHelper(name);
          },
        });
      }
      return proxy;
    } else if (Platform.OS === 'ios') {
      const handlers = { setLocale: setLocaleHelper };
      const methods = new Set(Object.keys(handlers));
      return new Proxy(this, {
        set() {
          if (__DEV__) {
            console.warn('Setting anything directly on the localization store is a no op');
          }
          return false;
        },
        get(target, name) {
          if (typeof name !== 'string') {
            return target[name];
          } else {
            if (defaultLocalePhrases.has(name)) {
              return localizationValueHelper(name);
            } else if (methods.has(name)) {
github expo / expo / packages / expo-local-authentication / src / LocalAuthentication.js View on Github external
export async function authenticateAsync(
  promptMessageIOS?: string = 'Authenticate'
): Promise {
  if (Platform.OS === 'ios') {
    invariant(
      typeof promptMessageIOS === 'string' && promptMessageIOS.length,
      'Fingerprint.authenticateAsync must be called with a non-empty string on iOS'
    );

    const result = await LocalAuthentication.authenticateAsync(promptMessageIOS);

    if (result.warning) {
      console.warn(result.warning);
    }
    return result;
  } else {
    return await LocalAuthentication.authenticateAsync();
  }
}
github expo / expo / packages / expo-location / src / Location.ts View on Github external
return ExpoLocation.reverseGeocodeAsync(location).catch(error => {
    const platformUsesGoogleMaps = Platform.OS === 'android' || Platform.OS === 'web';

    if (platformUsesGoogleMaps && error.code === 'E_NO_GEOCODER') {
      if (!googleApiKey) {
        throw new Error(error.message + ' Please set a Google API Key to use geocoding.');
      }
      return _googleReverseGeocodeAsync(location);
    }
    throw error;
  });
}
github expo / expo / packages / expo-location / src / Location.ts View on Github external
return ExpoLocation.reverseGeocodeAsync(location).catch(error => {
    const platformUsesGoogleMaps = Platform.OS === 'android' || Platform.OS === 'web';

    if (platformUsesGoogleMaps && error.code === 'E_NO_GEOCODER') {
      if (!googleApiKey) {
        throw new Error(error.message + ' Please set a Google API Key to use geocoding.');
      }
      return _googleReverseGeocodeAsync(location);
    }
    throw error;
  });
}
github mahmudahsan / todos-react-reactnative / mobile / screens / AboutScreen.js View on Github external
componentDidMount(){
    /**
     * If Apple Store webpage provide, and user open the app in iOS
     * the apple webpage will be shown.
     * Same goes for Google Play.
     * If no Apple Store page or Google Play page but normal webpage only then normal web page will be open.
     */
    if (Platform.OS === 'ios') {
      if (Config.aboutiOSURL !== ""){
        this.setState({url: Config.aboutiOSURL});
      }
      else if (Config.aboutWebPage !== ""){
        this.setState({url: Config.aboutWebPage});
      }
    }
    else if (Platform.OS === 'android'){
      if (Config.aboutGooglePlayURL !== ""){
        this.setState({url: Config.aboutGooglePlayURL});
      }
      else if (Config.aboutWebPage !== ""){
        this.setState({url: Config.aboutWebPage});
      }
    }
  }
github expo / expo / packages / expo-location / src / Location.ts View on Github external
return ExpoLocation.geocodeAsync(address).catch(error => {
    const platformUsesGoogleMaps = Platform.OS === 'android' || Platform.OS === 'web';

    if (platformUsesGoogleMaps && error.code === 'E_NO_GEOCODER') {
      if (!googleApiKey) {
        throw new Error(error.message + ' Please set a Google API Key to use geocoding.');
      }
      return _googleGeocodeAsync(address);
    }
    throw error;
  });
}
github expo / expo / modules / expo-contacts / src / Contacts.js View on Github external
id?: string,
};

type ContainerQuery = {
  contactId?: string,
  groupId?: string,
  containerId?: string | string[],
};

type Container = {
  name: string,
  id: string,
  type: ContainerType,
};

const isIos = Platform.OS === 'ios';

export async function shareContactAsync(
  contactId: string,
  message: string,
  shareOptions: Object = {}
): Promise {
  if (isIos) {
    const url = await writeContactToFileAsync({
      id: contactId,
    });
    Share.share(
      {
        url,
        message,
      },
      shareOptions