From 19225bea1567a7beed9dea5db244305e5fb8d8d7 Mon Sep 17 00:00:00 2001 From: Didas Mbalanya Date: Mon, 8 Aug 2022 21:01:23 +0300 Subject: [PATCH 1/3] feat(universal-links): base set up - refs #BAC-1963 --- .../app/scripts/lib/router.js | 1 + .../scripts/templates/app_link_all.mustache | 14 ++++++++++ .../app/scripts/views/app_link_all.js | 26 +++++++++++++++++++ .../server/lib/routes/get-frontend.js | 1 + 4 files changed, 42 insertions(+) create mode 100644 packages/fxa-content-server/app/scripts/templates/app_link_all.mustache create mode 100644 packages/fxa-content-server/app/scripts/views/app_link_all.js diff --git a/packages/fxa-content-server/app/scripts/lib/router.js b/packages/fxa-content-server/app/scripts/lib/router.js index 5742e138176..f16314fcde1 100644 --- a/packages/fxa-content-server/app/scripts/lib/router.js +++ b/packages/fxa-content-server/app/scripts/lib/router.js @@ -340,6 +340,7 @@ const Router = Backbone.Router.extend({ this.navigateAway('/beta/settings?' + qs); }, 'app_only_link(/)': createViewHandler('app_only_link'), + 'app_link/*(/)': createViewHandler('app-link-all'), }, initialize(options = {}) { diff --git a/packages/fxa-content-server/app/scripts/templates/app_link_all.mustache b/packages/fxa-content-server/app/scripts/templates/app_link_all.mustache new file mode 100644 index 00000000000..a860e2211d8 --- /dev/null +++ b/packages/fxa-content-server/app/scripts/templates/app_link_all.mustache @@ -0,0 +1,14 @@ +
+
+

{{#t}}Installed app required{{/t}}

+
+ +
+
+
+ +

+ {{#t}}The link you clicked can only be handled by the installed mobile app. Please open this link with a device that has the Firefox app installed.{{/t}} +

+
+
diff --git a/packages/fxa-content-server/app/scripts/views/app_link_all.js b/packages/fxa-content-server/app/scripts/views/app_link_all.js new file mode 100644 index 00000000000..0fddff03e99 --- /dev/null +++ b/packages/fxa-content-server/app/scripts/views/app_link_all.js @@ -0,0 +1,26 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +import BaseView from './base'; +// import Template from 'templates/app_link_all.mustache'; + +var View = BaseView.extend({ + className: 'app-link-all', + // template: Template, + initialize(options) { + options = options || {}; + + this._appleItunesApp = options.appleItunesApp; + }, + + beforeRender() { + // TO REFACTOR, basic logic implementation + if (navigator.userAgent.toLowerCase().indexOf('iphone') > -1 || navigator.userAgent.toLowerCase().indexOf('ipad') > -1) { + window.location.href = + 'https://itunes.apple.com/my/app/flipbizz/idexampleapp'; + } + }, +}); + +export default View; diff --git a/packages/fxa-content-server/server/lib/routes/get-frontend.js b/packages/fxa-content-server/server/lib/routes/get-frontend.js index 024b025b250..6a685c4834e 100644 --- a/packages/fxa-content-server/server/lib/routes/get-frontend.js +++ b/packages/fxa-content-server/server/lib/routes/get-frontend.js @@ -106,6 +106,7 @@ module.exports = function (config) { 'verify_secondary_email', 'would_you_like_to_sync', 'app_only_link', + 'app_link/*', ].filter((path) => { return !redirectPaths.includes(path); }).join('|'); // prepare for use in a RegExp From f36b245dba928e9978aafc8047743e53dd764239 Mon Sep 17 00:00:00 2001 From: Didas Mbalanya Date: Mon, 15 Aug 2022 05:32:07 +0300 Subject: [PATCH 2/3] feat(universal-links): call redirect after render - refs #BAC-1963 --- .../scripts/templates/app_link_all.mustache | 4 ++-- .../app/scripts/views/app_link_all.js | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/packages/fxa-content-server/app/scripts/templates/app_link_all.mustache b/packages/fxa-content-server/app/scripts/templates/app_link_all.mustache index a860e2211d8..90082d7a3c3 100644 --- a/packages/fxa-content-server/app/scripts/templates/app_link_all.mustache +++ b/packages/fxa-content-server/app/scripts/templates/app_link_all.mustache @@ -1,6 +1,6 @@
-

{{#t}}Installed app required{{/t}}

+

{{#t}}Redirecting...{{/t}}

@@ -8,7 +8,7 @@

- {{#t}}The link you clicked can only be handled by the installed mobile app. Please open this link with a device that has the Firefox app installed.{{/t}} + {{#t}}Opening app if installed, otherwise you will be redirected to the store.{{/t}}

diff --git a/packages/fxa-content-server/app/scripts/views/app_link_all.js b/packages/fxa-content-server/app/scripts/views/app_link_all.js index 0fddff03e99..7f7adc45f91 100644 --- a/packages/fxa-content-server/app/scripts/views/app_link_all.js +++ b/packages/fxa-content-server/app/scripts/views/app_link_all.js @@ -3,23 +3,24 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ import BaseView from './base'; -// import Template from 'templates/app_link_all.mustache'; +import Template from 'templates/app_link_all.mustache'; var View = BaseView.extend({ className: 'app-link-all', - // template: Template, + template: Template, initialize(options) { options = options || {}; - this._appleItunesApp = options.appleItunesApp; + this.appleItunesApp = options.appleItunesApp; }, - beforeRender() { - // TO REFACTOR, basic logic implementation - if (navigator.userAgent.toLowerCase().indexOf('iphone') > -1 || navigator.userAgent.toLowerCase().indexOf('ipad') > -1) { - window.location.href = - 'https://itunes.apple.com/my/app/flipbizz/idexampleapp'; - } + afterRender() { + //TO DO - Change time to configurable + return setTimeout(() => { + this.navigateAway( + `https://itunes.apple.com/enote/${this.appleItunesApp}` + ); + }, 3000); }, }); From 4e406c41a75a9557149acb569aa33627c134e79c Mon Sep 17 00:00:00 2001 From: Didas Mbalanya Date: Mon, 15 Aug 2022 11:25:13 +0300 Subject: [PATCH 3/3] feat(universal-links): updated redirect link - refs #BAC-1963 --- .../fxa-content-server/app/scripts/views/app_link_all.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/fxa-content-server/app/scripts/views/app_link_all.js b/packages/fxa-content-server/app/scripts/views/app_link_all.js index 7f7adc45f91..40a887a102e 100644 --- a/packages/fxa-content-server/app/scripts/views/app_link_all.js +++ b/packages/fxa-content-server/app/scripts/views/app_link_all.js @@ -16,9 +16,15 @@ var View = BaseView.extend({ afterRender() { //TO DO - Change time to configurable + const country = this.lang || 'us' + + const url = new URL(this.appleItunesApp); + const params = new URLSearchParams(url.search); + const appId = params.get('app-id'); + return setTimeout(() => { this.navigateAway( - `https://itunes.apple.com/enote/${this.appleItunesApp}` + `https://apps.apple.com/${country}/app/enote-intelligent-sheet-music/id${appId}` ); }, 3000); },