fix(deep-linking): Don't rely on custom scheme
This commit is contained in:
parent
e0fdeea69b
commit
840c0190c4
|
@ -50,7 +50,6 @@ class DeepLinkingDesktopPage<P : Props> extends Component<P> {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
// Bind event handlers so they are only bound once per instance.
|
// Bind event handlers so they are only bound once per instance.
|
||||||
this._openDesktopApp = this._openDesktopApp.bind(this);
|
|
||||||
this._onLaunchWeb = this._onLaunchWeb.bind(this);
|
this._onLaunchWeb = this._onLaunchWeb.bind(this);
|
||||||
this._onTryAgain = this._onTryAgain.bind(this);
|
this._onTryAgain = this._onTryAgain.bind(this);
|
||||||
}
|
}
|
||||||
|
@ -61,7 +60,6 @@ class DeepLinkingDesktopPage<P : Props> extends Component<P> {
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this._openDesktopApp();
|
|
||||||
sendAnalytics(
|
sendAnalytics(
|
||||||
createDeepLinkingPageEvent(
|
createDeepLinkingPageEvent(
|
||||||
'displayed', 'DeepLinkingDesktop', { isMobileBrowser: false }));
|
'displayed', 'DeepLinkingDesktop', { isMobileBrowser: false }));
|
||||||
|
@ -133,17 +131,6 @@ class DeepLinkingDesktopPage<P : Props> extends Component<P> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_openDesktopApp: () => {}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Dispatches the <tt>openDesktopApp</tt> action.
|
|
||||||
*
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
_openDesktopApp() {
|
|
||||||
this.props.dispatch(openDesktopApp());
|
|
||||||
}
|
|
||||||
|
|
||||||
_onTryAgain: () => {}
|
_onTryAgain: () => {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -155,7 +142,7 @@ class DeepLinkingDesktopPage<P : Props> extends Component<P> {
|
||||||
sendAnalytics(
|
sendAnalytics(
|
||||||
createDeepLinkingPageEvent(
|
createDeepLinkingPageEvent(
|
||||||
'clicked', 'tryAgainButton', { isMobileBrowser: false }));
|
'clicked', 'tryAgainButton', { isMobileBrowser: false }));
|
||||||
this._openDesktopApp();
|
this.props.dispatch(openDesktopApp());
|
||||||
}
|
}
|
||||||
|
|
||||||
_onLaunchWeb: () => {}
|
_onLaunchWeb: () => {}
|
||||||
|
|
|
@ -8,28 +8,7 @@ import {
|
||||||
DeepLinkingMobilePage,
|
DeepLinkingMobilePage,
|
||||||
NoMobileApp
|
NoMobileApp
|
||||||
} from './components';
|
} from './components';
|
||||||
import { _shouldShowDeepLinkingDesktopPage }
|
import { _openDesktopApp } from './openDesktopApp';
|
||||||
from './shouldShowDeepLinkingDesktopPage';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Promise that resolves when the window load event is received.
|
|
||||||
*
|
|
||||||
* @type {Promise<void>}
|
|
||||||
*/
|
|
||||||
const windowLoadedPromise = new Promise(resolve => {
|
|
||||||
/**
|
|
||||||
* Handler for the window load event.
|
|
||||||
*
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
function onWindowLoad() {
|
|
||||||
resolve();
|
|
||||||
window.removeEventListener('load', onWindowLoad);
|
|
||||||
}
|
|
||||||
|
|
||||||
window.addEventListener('load', onWindowLoad);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a deep linking URL based on the current window URL.
|
* Generates a deep linking URL based on the current window URL.
|
||||||
|
@ -96,23 +75,17 @@ export function getDeepLinkingPage(state) {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
return _shouldShowDeepLinkingDesktopPage().then(
|
return _openDesktopApp().then(
|
||||||
// eslint-disable-next-line no-confusing-arrow
|
// eslint-disable-next-line no-confusing-arrow
|
||||||
show => show ? DeepLinkingDesktopPage : undefined);
|
result => result ? DeepLinkingDesktopPage : undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens the desktop app.
|
* Opens the desktop app.
|
||||||
*
|
*
|
||||||
* @returns {void}
|
* @returns {Promise<boolean>} - Resolves with true if the attempt to open the desktop app was successful and resolves
|
||||||
|
* with false otherwise.
|
||||||
*/
|
*/
|
||||||
export function openDesktopApp() {
|
export function openDesktopApp() {
|
||||||
windowLoadedPromise.then(() => {
|
return _openDesktopApp();
|
||||||
// If the code for opening the deep link is executed before the window
|
|
||||||
// load event, something with the internal chrome state goes wrong. The
|
|
||||||
// result is that no window load event is received which is the cause
|
|
||||||
// for some permission prompts to not be displayed. In our case the GUM
|
|
||||||
// prompt wasn't displayed which causes the GUM call to never finish.
|
|
||||||
window.location.href = generateDeepLinkingURL();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
/**
|
||||||
|
* Opens the desktop app.
|
||||||
|
*
|
||||||
|
* @returns {Promise<boolean>} - Resolves with true if the attempt to open the desktop app was successful and resolves
|
||||||
|
* with false otherwise.
|
||||||
|
*/
|
||||||
|
export function _openDesktopApp() {
|
||||||
|
return Promise.resolve(false);
|
||||||
|
}
|
|
@ -1,9 +0,0 @@
|
||||||
/**
|
|
||||||
* Resolves with <tt>true</tt> if the deep linking page should be shown and with
|
|
||||||
* <tt>false</tt> otherwise.
|
|
||||||
*
|
|
||||||
* @returns {Promise<boolean>}
|
|
||||||
*/
|
|
||||||
export function _shouldShowDeepLinkingDesktopPage() {
|
|
||||||
return Promise.resolve(false);
|
|
||||||
}
|
|
Loading…
Reference in New Issue