How to use expo-core - 10 common examples

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 / modules / expo-media-library / src / MediaLibrary.js View on Github external
// @flow

import { Platform } from 'react-native';
import { NativeModulesProxy, EventEmitter } from 'expo-core';

const MediaLibrary = NativeModulesProxy.ExponentMediaLibrary;
const eventEmitter = new EventEmitter(MediaLibrary);

type MediaTypeValue = 'audio' | 'photo' | 'video' | 'unknown';
type SortByKey =
  | 'default'
  | 'id'
  | 'mediaType'
  | 'width'
  | 'height'
  | 'creationTime'
  | 'modificationTime'
  | 'duration';
type SortByValue = [SortByKey, boolean] | SortByKey;

type MediaTypeObject = {
  audio: 'audio',
  photo: 'photo',
github expo / expo / modules / expo-ads-admob / src / AdMobInterstitial.js View on Github external
// @flow

'use strict';

import { NativeModulesProxy, EventEmitter } from 'expo-core';
import { Platform } from 'react-native';
import type { EmitterSubscription } from 'react-native';

const AdMobInterstitialManager: Object = NativeModulesProxy.ExpoAdsAdMobInterstitialManager;

const adMobInterstitialEmitter = new EventEmitter(AdMobInterstitialManager);

const eventNames = [
  'interstitialDidLoad',
  'interstitialDidFailToLoad',
  'interstitialDidOpen',
  'interstitialDidClose',
  'interstitialWillLeaveApplication',
];

type EventNameType =
  | 'interstitialDidLoad'
  | 'interstitialDidFailToLoad'
  | 'interstitialDidOpen'
  | 'interstitialDidClose'
  | 'interstitialWillLeaveApplication';
github expo / expo / modules / expo-location / src / Location.js View on Github external
// @flow

import invariant from 'invariant';
import { NativeModulesProxy, EventEmitter } from 'expo-core';
import { Platform } from 'react-native';

const { ExpoLocation: Location } = NativeModulesProxy;
const LocationEventEmitter = new EventEmitter(Location);

type ProviderStatus = {
  locationServicesEnabled: boolean,
  gpsAvailable: ?boolean,
  networkAvailable: ?boolean,
  passiveAvailable: ?boolean,
};

type LocationOptions = {
  enableHighAccuracy?: boolean,
  timeInterval?: number,
  distanceInterval?: number,
};

type LocationTaskOptions = {
  type: string,
github expo / expo / modules / expo-ads-admob / src / AdMobRewarded.js View on Github external
// @flow

'use strict';

import { NativeModulesProxy, EventEmitter } from 'expo-core';
import { Platform } from 'react-native';

const AdMobRewardedVideoAdManager: Object = NativeModulesProxy.ExpoAdsAdMobRewardedVideoAdManager;

const adMobRewardedEventEmitter = new EventEmitter(AdMobRewardedVideoAdManager);

const eventNames = [
  'rewardedVideoDidRewardUser',
  'rewardedVideoDidLoad',
  'rewardedVideoDidFailToLoad',
  'rewardedVideoDidOpen',
  'rewardedVideoDidStart',
  'rewardedVideoDidClose',
  'rewardedVideoWillLeaveApplication',
];

type EventNameType =
  | 'rewardedVideoDidRewardUser'
  | 'rewardedVideoDidLoad'
  | 'rewardedVideoDidFailToLoad'
  | 'rewardedVideoDidOpen'
github expo / expo / modules / expo-ads-admob / src / AdMobInterstitial.js View on Github external
// @flow

'use strict';

import { NativeModulesProxy, EventEmitter } from 'expo-core';
import { Platform } from 'react-native';
import type { EmitterSubscription } from 'react-native';

const AdMobInterstitialManager: Object = NativeModulesProxy.ExpoAdsAdMobInterstitialManager;

const adMobInterstitialEmitter = new EventEmitter(AdMobInterstitialManager);

const eventNames = [
  'interstitialDidLoad',
  'interstitialDidFailToLoad',
  'interstitialDidOpen',
  'interstitialDidClose',
  'interstitialWillLeaveApplication',
];

type EventNameType =
  | 'interstitialDidLoad'
  | 'interstitialDidFailToLoad'
  | 'interstitialDidOpen'
  | 'interstitialDidClose'
github expo / expo / modules / expo-ads-admob / src / AdMobRewarded.js View on Github external
// @flow

'use strict';

import { NativeModulesProxy, EventEmitter } from 'expo-core';
import { Platform } from 'react-native';

const AdMobRewardedVideoAdManager: Object = NativeModulesProxy.ExpoAdsAdMobRewardedVideoAdManager;

const adMobRewardedEventEmitter = new EventEmitter(AdMobRewardedVideoAdManager);

const eventNames = [
  'rewardedVideoDidRewardUser',
  'rewardedVideoDidLoad',
  'rewardedVideoDidFailToLoad',
  'rewardedVideoDidOpen',
  'rewardedVideoDidStart',
  'rewardedVideoDidClose',
  'rewardedVideoWillLeaveApplication',
];

type EventNameType =
  | 'rewardedVideoDidRewardUser'
  | 'rewardedVideoDidLoad'
github expo / expo / modules / expo-file-system / FileSystem.js View on Github external
// @flow

import { NativeModulesProxy, EventEmitter } from 'expo-core';
import UUID from 'uuid-js';

const FS = NativeModulesProxy.ExponentFileSystem;

const normalizeEndingSlash = p => p.replace(/\/*$/, '') + '/';

FS.documentDirectory = normalizeEndingSlash(FS.documentDirectory);
FS.cacheDirectory = normalizeEndingSlash(FS.cacheDirectory);

export const documentDirectory = FS.documentDirectory;
export const cacheDirectory = FS.cacheDirectory;
export const bundledAssets = FS.bundledAssets;
export const bundleDirectory = FS.bundleDirectory;
export const EncodingTypes = {
  UTF8: "utf8",
  Base64: "base64",
}

type FileInfo =