1.0.1 • Published 6 years ago

awesome-landing v1.0.1

Weekly downloads
12
License
MIT
Repository
github
Last release
6 years ago

awesome-landing

NPM version build status Test coverage npm download


How to use

open and download all in one

import commonLanding from 'awesome-landing'

// for open app
const urlScheme = 'appscheme://app.scheme'
const androidIntentScheme = 'intent://app.intent/#Intent;scheme=appscheme;package=app.package;action=app.action;end'

// for download app
const iosDownloadUrl = 'https://itunes.apple.com/us/app/appid'
const androidDownloadUrl = 'https://play.google.com/store/apps/details?id=app.id'
const androidPackageName = 'app.package.name'
const androidIntentDownloadScheme = 'intent://app.intent/#Intent;scheme=appScheme;end'

commonLanding({
  urlScheme,
  iosDownloadUrl,
  androidPackageName,
  androidIntentScheme,
  androidDownloadUrl,
  androidIntentDownloadScheme,
  forceIntent, // force Android to use intent
})

Theses params are optional:

  • androidIntentScheme
  • androidIntentDownLoadScheme
  • forceIntent

separate open and download

import {
  openApp,
  download,
} from 'awesome-landing'

// for open app
const urlScheme = 'appscheme://app.scheme'
const androidIntentScheme = 'intent://app.intent/#Intent;scheme=appscheme;package=app.package;action=app.action;end'

// for download app
const iosDownloadUrl = 'https://itunes.apple.com/us/app/appid'
const androidDownloadUrl = 'https://play.google.com/store/apps/details?id=app.id'
const androidPackageName = 'app.package.name'
const androidIntentDownloadScheme = 'intent://app.intent/#Intent;scheme=appScheme;end'

// openApp() returns a Promise
openApp({
  urlScheme,
  androidPackageName,
  androidIntentScheme,
}).then(res => {
  console.log('open app res:', res)
}).catch(e => {
  console.log('open app failed:', e)
})


download({
  iosDownloadUrl,
  androidDownloadUrl,
  androidIntentDownloadScheme,
})

How to debug

  • add query in url __landingDebug__=1

How to mock userAgent

window.sessionStorage.DEBUG_SCHEME_UA = YOUR_MOCK_UA_STRING

Contributors

yangmingshanzhangyuhengxudafeng

This project follows the git-contributor spec, auto upated at Thu Oct 18 2018 11:07:22 GMT+0800.