Skip to content

Instantly share code, notes, and snippets.

@alexcroox
Created February 18, 2020 21:46
Show Gist options
  • Save alexcroox/71f086298ff079b051532c8b357727ab to your computer and use it in GitHub Desktop.
Save alexcroox/71f086298ff079b051532c8b357727ab to your computer and use it in GitHub Desktop.
export let Capacitor
export let Plugins
export let CameraResultType
export let CameraSource
export let StatusBarStyle
export let HapticsImpactStyle
export let platform = 'web'
export let isNativeApp = false
// This is an abstraction for IE11 / iOS 9 which do not support Proxy which
// Capacitor uses at it's core. A polyfill is too heavy for Proxy support
try {
if (window.Proxy) {
const capacitor = require('@capacitor/core')
Capacitor = capacitor.Capacitor
Plugins = capacitor.Plugins
CameraResultType = capacitor.CameraResultType
CameraSource = capacitor.CameraSource
StatusBarStyle = capacitor.StatusBarStyle
HapticsImpactStyle = capacitor.HapticsImpactStyle
platform = Capacitor.platform
// Remember, many of the capacitor APIs work for web browsers too
isNativeApp = platform !== 'web'
} else {
Capacitor = undefined
Plugins = undefined
CameraResultType = undefined
CameraSource = undefined
StatusBarStyle = undefined
HapticsImpactStyle = undefined
}
} catch (e) {
// Catch the error IE11 throws about Proxy being undefined;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment