UNPKG

@gathertown/uikit-react-native

Version:

Sendbird UIKit for React Native: A feature-rich and customizable chat UI kit with messaging, channel management, and user authentication.

41 lines (35 loc) 953 B
import { Image, Linking, Platform } from 'react-native'; import { Logger } from '@gathertown/uikit-utils'; export default class SBUUtils { static openSettings() { Linking.openSettings().catch(() => { if (Platform.OS === 'ios') Linking.openURL('App-Prefs:root'); }); } static async openURL(url: string) { try { const targetUrl = url.startsWith('http') ? url : 'https://' + url; await Linking.openURL(targetUrl); } catch (e) { Logger.warn('Cannot open url', e); } } static getImageSize(uri: string): Promise<{ width: number; height: number }> { return new Promise((resolve, reject) => { Image.getSize( uri, (width, height) => { resolve({ width, height }); }, (error) => { reject(error); }, ); }); } static async safeRun(callback: () => Promise<void>) { try { await callback(); } catch (e) {} } }