How to use the expo-constants.isDevice 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 expo / expo / apps / test-suite / TestUtils.js View on Github external
// Requires interaction (sign in popup)
    modules.push(optionalRequire(() => require('./tests/GoogleSignIn')));
    // Popup to request device's location which uses Google's location service
    modules.push(optionalRequire(() => require('./tests/Location')));
    // Fails to redirect because of malformed URL in published version with release channel parameter
    modules.push(optionalRequire(() => require('./tests/Linking')));
    // Has uncontrolled view controllers
    modules.push(require('./tests/SMS'));
    // Requires permission
    modules.push(optionalRequire(() => require('./tests/Calendar')));
    modules.push(optionalRequire(() => require('./tests/Permissions')));
    modules.push(optionalRequire(() => require('./tests/MediaLibrary')));
    modules.push(optionalRequire(() => require('./tests/Notifications')));

    modules.push(optionalRequire(() => require('./tests/Battery')));
    if (Constants.isDevice) {
      modules.push(optionalRequire(() => require('./tests/Brightness')));
    }
    // Crashes app when mounting component
    modules.push(optionalRequire(() => require('./tests/Video')));
    // "sdkUnversionedTestSuite failed: java.lang.NullPointerException: Attempt to invoke interface method
    // 'java.util.Map org.unimodules.interfaces.taskManager.TaskInterface.getOptions()' on a null object reference"
    modules.push(optionalRequire(() => require('./tests/TaskManager')));
    // Audio tests are flaky in CI due to asynchronous fetching of resources
    modules.push(optionalRequire(() => require('./tests/Audio')));
    // The Camera tests are flaky on iOS, i.e. they fail randomly
    if (Constants.isDevice && Platform.OS === 'android')
      modules.push(optionalRequire(() => require('./tests/Camera')));
  }
  if (Constants.isDevice) {
    modules.push(optionalRequire(() => require('./tests/Cellular')));
    modules.push(optionalRequire(() => require('./tests/BarCodeScanner')));
github expo / expo / packages / expo / src / AR.ts View on Github external
export function isAvailable(): boolean {
  // Device has A9 chip
  const hasA9Chip = Constants.deviceYearClass && Constants.deviceYearClass > 2014;

  if (
    !Constants.isDevice || // Prevent Simulators
    // @ts-ignore
    Platform.isTVOS ||
    Platform.OS !== 'ios' || // Device is iOS
    !hasA9Chip ||
    !ExponentAR.isSupported || // ARKit is included in the build
    !ExponentAR.startAsync // Older SDK versions (27 and lower) that are fully compatible
  ) {
    return false;
  }

  return true;
}
github Marwan01 / food-converter / node_modules / expo / build / AR.js View on Github external
export function isAvailable() {
    // Device has A9 chip
    const hasA9Chip = Constants.deviceYearClass && Constants.deviceYearClass > 2014;
    if (!Constants.isDevice || // Prevent Simulators
        // @ts-ignore
        Platform.isTVOS ||
        Platform.OS !== 'ios' || // Device is iOS
        !hasA9Chip ||
        !ExponentAR.isSupported || // ARKit is included in the build
        !ExponentAR.startAsync // Older SDK versions (27 and lower) that are fully compatible
    ) {
        return false;
    }
    return true;
}
export function getUnavailabilityReason() {
github expo / expo / home / components / OpenFromClipboardButton.js View on Github external
render() {
    let { fullWidthBorder, clipboardContents, isValid } = this.props;

    // Show info for iOS simulator about how to make clipboard contents available
    if (!isValid && Platform.OS === 'ios' && !Constants.isDevice) {
      return (
        
      );
    } else if (!isValid) {
      return null;
    }
github flow-typed / flow-typed / definitions / npm / expo-constants_v4.x.x / flow_v0.69.0-v0.103.x / test_expo-constants.js View on Github external
it('should passes when used properly', () => {
      (Constants.debugMode: boolean);
      (Constants.deviceName: ?string);
      (Constants.deviceYearClass: number | null);
      (Constants.experienceUrl: string);
      (Constants.expoRuntimeVersion: string);
      (Constants.expoVersion: string);
      (Constants.isDetached: ?boolean);
      (Constants.intentUri: ?string);
      (Constants.installationId: string);
      (Constants.isDevice: boolean);
      (Constants.isHeadless: boolean);
      (Constants.linkingUri: string);
      (Constants.sessionId: string);
      (Constants.statusBarHeight: number);
      (Constants.systemVersion: ?number);
      (Constants.systemFonts: Array);
    });
github catalinmiron / uzual-mobile / screens / habits / Habits.js View on Github external
registerForPushNotificationsAsync = async () => {
    if (Constants.isDevice) {
      const { status: existingStatus } = await Permissions.getAsync(
        Permissions.NOTIFICATIONS
      );
      let finalStatus = existingStatus;
      if (existingStatus !== 'granted') {
        const { status } = await Permissions.askAsync(
          Permissions.NOTIFICATIONS
        );
        finalStatus = status;
      }
      if (finalStatus !== 'granted') {
        alert('Failed to get push token for push notification!');
        return;
      }
      let token = await Notifications.getExpoPushTokenAsync();
      this._onSetPushToken(token);
github janaagaard75 / expo-and-typescript / src / constants / ConstantsScreen.tsx View on Github external
public render() {
    const navigate = this.props.navigation.navigate;

    return (
      
    );
  }
github expo / expo / home / screens / ProjectsScreen.js View on Github external
export default class ProjectsScreen extends React.Component {
  props: {
    navigation: any,
    isFocused: boolean,
    dispatch: () => void,
    recentHistory: any,
    allHistory: any,
    navigator: any,
    isAuthenticated: boolean,
  };

  static navigationOptions = {
    title: 'Projects',
    ...Platform.select({
      ios: {
        headerRight: Constants.isDevice ? null : ,
      },
    }),
  };

  static getDataProps(data) {
    let { history } = data.history;

    return {
      recentHistory: history.take(10),
      allHistory: history,
      isAuthenticated: data.session && data.session.sessionSecret,
    };
  }

  state = {
    projects: [],
github SCasarotto / casarotto-chat / src / pages / Main / Main.js View on Github external
async componentDidMount() {
		const { numberOfMessagesToLoad } = this.state
		const { startWatchingUser, startWatchingChat } = this.props
		startWatchingUser()
		startWatchingChat(numberOfMessagesToLoad)

		try {
			if (Constants.isDevice) {
				//Only Run On Devices. Will Crash in emulators
				const getResponse = await Permissions.getAsync(Permissions.NOTIFICATIONS)
				const { uid } = firebase.auth().currentUser
				//Save it to DB for debugging
				firebase
					.database()
					.ref(`/Users/${uid}`)
					.update({
						pushPermissions: getResponse,
					})
				switch (getResponse.status) {
					case 'granted': {
						const token = await Notifications.getExpoPushTokenAsync()
						firebase
							.database()
							.ref(`/Users/${uid}`)
github expo / expo / home / screens / ProjectsScreen.js View on Github external
_handlePressHelpProjects = () => {
    if (!this.state.isNetworkAvailable) {
      Alert.alert(
        'No network connection available',
        `You must be connected to the internet to view a list of your projects open in development.`
      );
    }

    let baseMessage = `Make sure you are signed in to the same Expo account on your computer and this app. Also verify that your computer is connected to the internet, and ideally to the same Wi-Fi network as your mobile device. Lastly, ensure that you are using the latest version of Expo CLI. Pull to refresh to update.`;
    let message = Platform.select({
      ios: Constants.isDevice
        ? baseMessage
        : `${baseMessage} If this still doesn't work, press the + icon on the header to type the project URL manually.`,
      android: baseMessage,
    });
    Alert.alert('Troubleshooting', message);
  };