redirect to referral service if invite code is set
Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
parent
34d9748a78
commit
106029b0bb
|
@ -40,16 +40,15 @@ const _getMetaProp = (prop) => $(`meta[property="${prop}"]`).attr("content")
|
||||||
/* helper to detect Android/iOS user agent */
|
/* helper to detect Android/iOS user agent */
|
||||||
const _userAgentHas = (str) => navigator.userAgent.toLowerCase().indexOf(str) > -1
|
const _userAgentHas = (str) => navigator.userAgent.toLowerCase().indexOf(str) > -1
|
||||||
|
|
||||||
|
/* redirect to Referral Service for referral bonus */
|
||||||
|
const getReferralUrl = (params) => {
|
||||||
|
return `https://get.status.im/${params.invite}`
|
||||||
|
}
|
||||||
|
|
||||||
/* redirect to Play Store based on URL */
|
/* redirect to Play Store based on URL */
|
||||||
const getPlayStoreUrl = () => {
|
const getPlayStoreUrl = (params) => {
|
||||||
let params = _getParams(window.location.href)
|
|
||||||
/* action for app to take after installation */
|
/* action for app to take after installation */
|
||||||
let args = { out: _getMetaProp('status-im:target') }
|
let args = { out: _getMetaProp('status-im:target') }
|
||||||
|
|
||||||
/* if available set invite and cid arguments */
|
|
||||||
if (params.invite) { args.invite = params.invite }
|
|
||||||
if (params.cid) { args.cid = params.cid }
|
|
||||||
|
|
||||||
return _buildPlayStoreUrl(_formatArgs(args))
|
return _buildPlayStoreUrl(_formatArgs(args))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,9 +60,13 @@ const redirectToStore = () => {
|
||||||
/* to avoid showing store after app has been opened */
|
/* to avoid showing store after app has been opened */
|
||||||
if (siteLostFocus || isHidden()) { return }
|
if (siteLostFocus || isHidden()) { return }
|
||||||
|
|
||||||
|
let params = _getParams(window.location.href)
|
||||||
var url
|
var url
|
||||||
if (_userAgentHas('android')) {
|
/* if invite is set redirect tor referral service */
|
||||||
url = getPlayStoreUrl()
|
if (params.invite) {
|
||||||
|
url = getReferralUrl(params)
|
||||||
|
} else if (_userAgentHas('android')) {
|
||||||
|
url = getPlayStoreUrl(params)
|
||||||
} else if (_userAgentHas('iphone')) {
|
} else if (_userAgentHas('iphone')) {
|
||||||
url = getAppStoreUrl()
|
url = getAppStoreUrl()
|
||||||
} else { /* there's no desktop status app */
|
} else { /* there's no desktop status app */
|
||||||
|
|
Loading…
Reference in New Issue