Created
February 18, 2020 21:46
-
-
Save alexcroox/71f086298ff079b051532c8b357727ab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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