@trycourier/courier-react-native
Version:
Inbox, Push Notifications, and Preferences for React Native
24 lines • 1.33 kB
JavaScript
import { NativeModules, Platform, UIManager, TurboModuleRegistry, requireNativeComponent } from 'react-native';
export class Modules {
static LINKING_ERROR = `The package '@trycourier/courier-react-native' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
ios: "- You have run 'pod install'\n",
default: ''
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
static Client = Modules.getNativeModule('CourierClientModule', NativeModules.CourierClientModule);
static Shared = Modules.getNativeModule('CourierSharedModule', NativeModules.CourierSharedModule);
static System = Modules.getNativeModule('CourierSystemModule', NativeModules.CourierSystemModule);
static getNativeModule(moduleName, bridgeModule) {
const resolved = (TurboModuleRegistry === null || TurboModuleRegistry === void 0 ? void 0 : TurboModuleRegistry.get(moduleName)) ?? bridgeModule ?? undefined;
return resolved ? resolved : new Proxy({}, {
get() {
throw new Error(Modules.LINKING_ERROR);
}
});
}
static getNativeComponent(componentName) {
return UIManager.getViewManagerConfig(componentName) != null ? requireNativeComponent(componentName) : () => {
throw new Error(Modules.LINKING_ERROR);
};
}
}
//# sourceMappingURL=Modules.js.map