Skip to content

shalanah/inapp-spy

Repository files navigation

InAppSpy 🔎

Detect in-app browsers - fork of detect-inapp with API modifications + additions

Installation

yarn add inapp-spy
npm install inapp-spy

Code Example

import InAppSpy from "inapp-spy";

const { isInApp, appKey, appName } = InAppSpy();

API Reference

Return properties

{
  // Detected in-app browser
  isInApp: boolean;

  // Recognized app with in-app browser
  appKey: "messenger" |
    "facebook" |
    "twitter" |
    "wechat" |
    "instagram" |
    "tiktok" |
    "snapchat" |
    "line" |
    undefined; // can be undefined if `isInApp: true`

  // Pretty printed app name
  // - ie `appKey: 'tiktok', appName: 'TikTok'`
  // - Subject to change, use `appKey` for programmatic use
  appName: string;

  ua: string; // The user agent passed in or figured out by `InAppSpy()` function

  // Experimental and unstable detection of SFSafariViewController (SFSVC)
  // - Downloading UX in SFSVC is almost useless compared to regular Safari
  // - If SFSVC is detected, `isInApp` will be `false` and `appKey` will be `undefined`
  // - Subject to change, use with caution
  isSFSafariViewController: boolean;
}

Parameters (optional)

InAppSpy({
  ua?: string; // not required
})

License

MIT License

Related

  • Bowser - Browser + OS detection
  • InAppDebugger - Easily debug in-app browsers. Uses both bowser and inapp-spy libraries.

Thanks

inapp-spy is a fork of detect-inapp with modifications. This wouldn't exist without the original work of the detect-inapp contributors.