|
9 | 9 | getPlatformSettings,
|
10 | 10 | getUrlBase,
|
11 | 11 | MT5_ACCOUNT_STATUS,
|
| 12 | + mobileOSDetect, |
12 | 13 | } from '@deriv/shared';
|
13 | 14 | import { observer, useStore } from '@deriv/stores';
|
14 | 15 | import { Localize, localize } from '@deriv/translations';
|
@@ -61,6 +62,28 @@ const DMT5TradeModal = observer(
|
61 | 62 | return undefined;
|
62 | 63 | };
|
63 | 64 |
|
| 65 | + const getMobileAppInstallerURL = () => { |
| 66 | + if (mobileOSDetect() === 'iOS') { |
| 67 | + return getPlatformMt5DownloadLink('ios'); |
| 68 | + } else if (/huawei/i.test(navigator.userAgent)) { |
| 69 | + return getPlatformMt5DownloadLink('huawei'); |
| 70 | + } |
| 71 | + return getPlatformMt5DownloadLink('android'); |
| 72 | + }; |
| 73 | + |
| 74 | + let mobile_url; |
| 75 | + const mobileURLSet = () => { |
| 76 | + mobile_url = window.location.replace(deepLink); |
| 77 | + const timeout = setTimeout(() => { |
| 78 | + mobile_url = window.location.replace(getMobileAppInstallerURL()); |
| 79 | + }, 3000); |
| 80 | + if (!/safari/i.test(navigator.userAgent)) { |
| 81 | + window.onblur = () => { |
| 82 | + clearTimeout(timeout); |
| 83 | + }; |
| 84 | + } |
| 85 | + }; |
| 86 | + |
64 | 87 | const getHeadingTitle = () =>
|
65 | 88 | getCFDAccountDisplay({
|
66 | 89 | market_type: mt5_trade_account.market_type,
|
@@ -93,6 +116,10 @@ const DMT5TradeModal = observer(
|
93 | 116 | MT5_ACCOUNT_STATUS.MIGRATED_WITHOUT_POSITION,
|
94 | 117 | ].includes(mt5_trade_account?.status);
|
95 | 118 |
|
| 119 | + const deepLink = `metatrader5://account?login=${ |
| 120 | + (mt5_trade_account as TTradingPlatformAccounts)?.display_login |
| 121 | + }&server=${(mt5_trade_account as DetailsOfEachMT5Loginid)?.server_info?.environment}`; |
| 122 | + |
96 | 123 | return (
|
97 | 124 | <div className='cfd-trade-modal-container'>
|
98 | 125 | <div className='cfd-trade-modal'>
|
@@ -193,9 +220,10 @@ const DMT5TradeModal = observer(
|
193 | 220 | <a
|
194 | 221 | className='dc-btn cfd-trade-modal__download-center-app--option-link'
|
195 | 222 | type='button'
|
196 |
| - href={mt5_trade_account.webtrader_url} |
197 |
| - target='_blank' |
198 |
| - rel='noopener noreferrer' |
| 223 | + onClick={is_mobile ? mobileURLSet : undefined} |
| 224 | + href={is_mobile ? mobile_url : mt5_trade_account.webtrader_url} |
| 225 | + target={is_mobile ? '' : '_blank'} |
| 226 | + rel={is_mobile ? '' : 'noopener noreferrer'} |
199 | 227 | >
|
200 | 228 | <Text size='xxs' weight='bold' color='prominent'>
|
201 | 229 | {localize('Open')}
|
|
0 commit comments