How to use the expo-constants.getWebViewUserAgentAsync function in expo-constants

To help you get started, we’ve selected a few expo-constants 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 flow-typed / flow-typed / definitions / npm / expo-constants_v4.x.x / flow_v0.69.0-v0.103.x / test_expo-constants.js View on Github external
it('should passes when used properly', () => {
      Constants.getWebViewUserAgentAsync().then(ua => {
        if (ua !== null) {
          (ua: string);

          // $ExpectError: check any
          (ua: number);
        } else {
          (ua: null);
        }
      });
    });
  });
github janaagaard75 / expo-and-typescript / src / constants / ConstantsScreen.tsx View on Github external
private async updateWebViewUserAgent() {
    const userAgent = await Constants.getWebViewUserAgentAsync();
    this.setState({
      webViewUserAgent: userAgent
    });
  }
}
github czy0729 / Bangumi / utils / fetch.js View on Github external
export async function hm(url, screen) {
  if (DEV) {
    log(`[hm] ${url} ${screen}`)
    return
  }

  try {
    if (!ua) ua = await Constants.getWebViewUserAgentAsync()

    let u = String(url).indexOf('http') === -1 ? `${HOST}/${url}` : url
    u += `${u.includes('?') ? '&' : '?'}v=${VERSION_GITHUB_RELEASE}`
    u += `${require('../stores/theme').default.isDark ? '&dark=1' : ''}`
    u += `${screen ? `&s=${screen}` : ''}`

    const request = new XMLHttpRequest()
    request.open(
      'GET',
      `https://hm.baidu.com/hm.gif?${urlStringify({
        rnd: randomn(10),
        si: IOS
          ? '8f9e60c6b1e92f2eddfd2ef6474a0d11'
          : '2dcb6644739ae08a1748c45fb4cea087',
        v: '1.2.51',
        api: '4_0',
github ryanvanderpol / expo-analytics / analytics.js View on Github external
return new Promise((resolve) => {
        if (options.userAgent) {
            webViewUserAgent = options.userAgent;
            return resolve(options.userAgent);
        }
        if (webViewUserAgent) return resolve(webViewUserAgent);
        Constants.getWebViewUserAgentAsync()
          .then(userAgent => {
              webViewUserAgent = userAgent;
              resolve(userAgent);
          })
          .catch(() => resolve('unknown user agent'))
    });
}