How to use the @unimodules/core.Platform.OS function in @unimodules/core

To help you get started, we’ve selected a few @unimodules/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 / packages / expo-firebase-notifications / src / IOSNotification.ts View on Github external
import { Platform } from '@unimodules/core';
import { BackgroundFetchResultValue } from './IOSNotifications';

import Notification from './Notification';
import { Notifications, IOSAttachment, IOSAttachmentOptions, NativeIOSNotification } from './types';

type CompletionHandler = (results: BackgroundFetchResultValue) => void;

const isIOS = Platform.OS === 'ios';
export default class IOSNotification {
  _alertAction?: string;

  // alertAction | N/A
  _attachments: IOSAttachment[] = [];

  // N/A | attachments
  _badge?: number;

  // applicationIconBadgeNumber | badge
  _category?: string;

  _hasAction?: boolean;

  // hasAction | N/A
  _launchImage?: string;
github expo / expo / packages / expo-firebase-auth / src / AuthSettings.ts View on Github external
import { Platform } from '@unimodules/core';

const isIOS = Platform.OS === 'ios';
const isAndroid = Platform.OS === 'android';

type Auth = any;

export default class AuthSettings {
  _auth: Auth;

  _appVerificationDisabledForTesting: boolean;

  constructor(auth: Auth) {
    this._auth = auth;
    this._appVerificationDisabledForTesting = false;
  }

  /**
   * Flag to determine whether app verification should be disabled for testing or not.
github expo / expo / packages / expo-firebase-messaging / src / IOSMessaging.ts View on Github external
import { Platform } from '@unimodules/core';

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

export default class IOSMessaging {
  _messaging: any;
  constructor(messaging: any) {
    this._messaging = messaging;
  }

  async getAPNSToken(): Promise {
    if (!isIOS) {
      return null;
    }
    return await this._messaging.nativeModule.getAPNSToken();
  }
}
github expo / expo / packages / expo-notifications / src / getDevicePushTokenAsync.web.ts View on Github external
export default async function getDevicePushTokenAsync(): Promise {
  const data = await _subscribeUserToPushAsync();
  return { type: Platform.OS, data };
}
github expo / expo / packages / expo-firebase-notifications / src / Notification.ts View on Github external
build(): NativeNotification {
    if (!this._notificationId)
      throw new Error('Notification: Missing required `notificationId` property');

    return {
      android: Platform.OS === 'android' ? this._android.build() : undefined,
      body: this._body,
      data: this._data,
      ios: Platform.OS === 'ios' ? this._ios.build() : undefined,
      notificationId: this._notificationId,
      sound: this._sound,
      subtitle: this._subtitle,
      title: this._title,
    };
  }
}
github expo / expo / packages / expo-firebase-app / src / utils / internals.ts View on Github external
ERROR_MISSING_MODULE(namespace: string, nativeModule: string) {
      const snippet = `firebase.${namespace}()`;
      if (Platform.OS === 'ios') {
        return (
          `You attempted to use a firebase module that's not installed natively on your iOS project by calling ${snippet}.` +
          '\r\n\r\nEnsure you have the required Firebase iOS SDK pod for this module included in your Podfile, in this instance ' +
          `confirm you've added "pod '${NAMESPACE_PODS[namespace]}'" to your Podfile` +
          '\r\n\r\nSee http://invertase.link/ios for full setup instructions.'
        );
      }

      const fbSDKDep = `'com.google.firebase:firebase-${GRADLE_DEPS[namespace] || namespace}'`;
      const exFirebasePackage = `'io.invertase.firebase.${namespace}.${nativeModule}Package'`;
      const newInstance = `'new ${nativeModule}Package()'`;
      return (
        `You attempted to use a firebase module that's not installed on your Android project by calling ${snippet}.` +
        `\r\n\r\nEnsure you have:\r\n\r\n1) Installed the required Firebase Android SDK dependency ${fbSDKDep} in your 'android/app/build.gradle' ` +
        `file.\r\n\r\n2) Imported the ${exFirebasePackage} module in your 'MainApplication.java' file.\r\n\r\n3) Added the ` +
        `${newInstance} line inside of the RN 'getPackages()' method list.` +
github expo / expo / packages / expo-firebase-auth / src / AuthSettings.ts View on Github external
import { Platform } from '@unimodules/core';

const isIOS = Platform.OS === 'ios';
const isAndroid = Platform.OS === 'android';

type Auth = any;

export default class AuthSettings {
  _auth: Auth;

  _appVerificationDisabledForTesting: boolean;

  constructor(auth: Auth) {
    this._auth = auth;
    this._appVerificationDisabledForTesting = false;
  }

  /**
   * Flag to determine whether app verification should be disabled for testing or not.
   *
github expo / expo / packages / expo-av / src / AV.ts View on Github external
export function getNativeSourceFromSource(
  source?: PlaybackSource | null
): PlaybackNativeSource | null {
  let uri: string | null = null;
  let overridingExtension: string | null = null;
  let headers: { [fieldName: string]: string } | undefined;

  if (typeof source === 'string' && Platform.OS === 'web') {
    return {
      uri: source,
      overridingExtension,
      headers,
    };
  }

  let asset: Asset | null = _getAssetFromPlaybackSource(source);
  if (asset != null) {
    uri = asset.localUri || asset.uri;
  } else if (
    source != null &&
    typeof source !== 'number' &&
    'uri' in source &&
    typeof source.uri === 'string'
  ) {
github expo / expo / packages / expo-asset / build / AssetSourceResolver.web.js View on Github external
assetServerURL() {
        invariant(!!this.serverUrl, 'need server to load from');
        return this.fromSource(this.serverUrl +
            getScaledAssetPath(this.asset) +
            '?platform=' +
            Platform.OS +
            '&hash=' +
            this.asset.hash);
    }
    scaledAssetPath() {
github expo / expo / packages / expo-firebase-app / src / utils / createAppModule.ts View on Github external
import { Platform } from '@unimodules/core';

import { APP_MODULES, CUSTOM_URL_OR_REGION_NAMESPACES } from './appStore';
import getModuleInstance from './getModuleInstance';
import INTERNALS from './internals';
import { FirebaseModule } from '../types';
type App = any;

type ModuleFactory = () => FirebaseModule;

const isAndroid = Platform.OS === 'android';

/**
 *
 * @param app
 * @param namespace
 * @param InstanceClass
 * @return {function()}
 * @private
 */

export const createAppModule = (
  app: App,
  namespace: any,
  InstanceClass?: any
): ModuleFactory => {
  return (customUrlOrRegion: string | null = null): M => {