Skip to content

Commit

Permalink
Merge pull request #88 from getamis/ASL-4885/iab-once-and-for-all
Browse files Browse the repository at this point in the history
[ASL-4885] iab once and for all
  • Loading branch information
morsha authored Jan 2, 2024
2 parents 41f8964 + 6f240bb commit 8b7d44f
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 44 deletions.
1 change: 1 addition & 0 deletions examples/example-pure-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"start:stag": "env-cmd -f ../.env.stag yarn start",
"start:prod": "env-cmd -f ../.env.prod yarn start",
"build": "react-app-rewired build",
"build:dev": "GENERATE_SOURCEMAP=false env-cmd -f ../.env.dev react-app-rewired build",
"test": "react-app-rewired test",
"eject": "react-scripts eject",
"lint:tsc": "npx tsc"
Expand Down
1 change: 1 addition & 0 deletions examples/example-pure-js/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ async function main() {
apiUrl: API_URL, // optional
marketApiUrl: MARKET_API_URL,
authRedirectUrl: AUTH_REDIRECT_URL, // optional, for debug
disableIabWarning: false, // optional
iabRedirectUrl: '', // optional
shouldAlwaysShowCopyUI: false, // optional
trackGaSettings: ['G-W8EB8ZK5CV'], // optional
Expand Down
13 changes: 10 additions & 3 deletions packages/detect-iab/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,22 @@ import { showBlockerWhenIab, openExternalBrowserWhenLineIab } from '@qubic-conne
### showBlockerWhenIab({ redirectUrl?: string, shouldAlwaysShowCopyUI?: boolean }): void
shows a blocker when detected in iab

shows relative hint when in facebook, facebook messenger, line, instagram
shows relative hint when in instagram (due to maintaining reason we support only instagram now)

![relative](src/assets/readme/position-preview.png)

shows a copy box when not in facebook, facebook messenger, line, instagram, or when `shouldAlwaysShowCopyUI` is true
shows a copy box when not in instagram, or when `shouldAlwaysShowCopyUI` is true

![relative](src/assets/readme/copy-preview.png)

if `redirectUrl` is given, show and copy `redirectUrl` instead of current url
### openExternalBrowserWhenLineIab(): void

when in line iab, auto opens native browser (chrome / google for android, safari for ios) with same url
when in line iab, auto opens native browser (chrome / google for android, safari for ios) with same url

## Preview deploy
After sending a PR,a link will be created after netlify generates a deploy-preview website

![relative](src/assets/readme/deploy-preview.png)

Post in on apps to preview PR's work
37 changes: 0 additions & 37 deletions packages/detect-iab/src/LeaveInAppBrowserModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import InApp, { InAppBrowser } from '@qubic-js/detect-inapp';

import HorizontalMoreOptions from './icons/HorizontalMoreOptions';
import VerticalMoreOptions from './icons/VerticalMoreOptions';
import ExportMoreOptions from './icons/ExportMoreOptions';
import { LEAVE_IAB_MODAL_ID } from './constant';
import { getLocaleStrings } from './locale';
import { classes } from './styles';
Expand All @@ -31,28 +30,16 @@ interface ModalProps {
function getHintImage(platform: Platform, browser: InAppBrowser) {
if (platform === 'ios') {
switch (browser) {
case 'facebook':
return <HorizontalMoreOptions className={classes.icon} />;
case 'instagram':
return <HorizontalMoreOptions className={classes.icon} />;
case 'line':
return <VerticalMoreOptions className={classes.icon} />;
case 'messenger':
return <ExportMoreOptions className={classes.exportMoreIcon} />;
default:
}
}

if (platform === 'android') {
switch (browser) {
case 'facebook':
return <HorizontalMoreOptions className={classes.icon} />;
case 'instagram':
return <VerticalMoreOptions className={classes.icon} />;
case 'line':
return <VerticalMoreOptions className={classes.icon} />;
case 'messenger':
return <VerticalMoreOptions className={classes.icon} />;
default:
}
}
Expand All @@ -63,28 +50,16 @@ function getHintImage(platform: Platform, browser: InAppBrowser) {
function getHintBrowserString(platform: Platform, browser: InAppBrowser) {
if (platform === 'ios') {
switch (browser) {
case 'facebook':
return localeStrings.openInSystemBrowser; // open in system browser
case 'instagram':
return localeStrings.openInSystemBrowser; // open in system browser
case 'line':
return localeStrings.openInBrowser; // open in browser
case 'messenger':
return localeStrings.openInSafari; // open in safari
default:
}
}

if (platform === 'android') {
switch (browser) {
case 'facebook':
return localeStrings.openInSystemBrowser; // open in system browser
case 'instagram':
return localeStrings.openInChrome; // Open in Chrome
case 'line':
return localeStrings.openInDefaultBrowser; // open in your default browser
case 'messenger':
return localeStrings.openInChrome; // Open in Chrome
default:
}
}
Expand Down Expand Up @@ -122,28 +97,16 @@ function getAndroidFacebookBrowser(userAgent: string): InAppBrowser {
function getArrowPosition(platform: Platform, browser: InAppBrowser) {
if (platform === 'ios') {
switch (browser) {
case 'facebook':
return 'bottom';
case 'instagram':
return 'top';
case 'line':
return 'bottom';
case 'messenger':
return 'bottom';
default:
}
}

if (platform === 'android') {
switch (browser) {
case 'facebook':
return 'top';
case 'instagram':
return 'top';
case 'line':
return 'bottom';
case 'messenger':
return 'top';
default:
}
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions packages/detect-iab/src/locale.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const en = {
alertIabSentence1: 'You are using a third-party browser',
alertIabSentence2: 'To have a better experience, open the website in system browser.',
alertIabSentence1: 'You are using an in-app browser.',
alertIabSentence2: 'Some functions will be affected. To have a better experience, tap “⋯” and choose “open in system browser.',
alertIncognitoSentence1: 'You are now in private browsing mode',
alertIncognitoSentence2: 'To have a better experience, open the website in normal browsing mode.',
hintPart1: 'Tap "',
Expand All @@ -17,8 +17,8 @@ const en = {
};

const zhTW = {
alertIabSentence1: '您正在使用第三方瀏覽器',
alertIabSentence2: '為了享有更完整的服務,請以系統瀏覽器開啟網頁',
alertIabSentence1: '您正在使用其他應用程式的瀏覽器',
alertIabSentence2: '可能會影響部分功能,為了享有更完整的服務,請點擊「⋯」,並選擇「 以瀏覽器開啟」。',
alertIncognitoSentence1: '您正在使用私密瀏覽模式',
alertIncognitoSentence2: '為了享有更完整的服務,請在瀏覽器以一般模式開啟網頁',
hintPart1: '點擊「',
Expand Down

0 comments on commit 8b7d44f

Please sign in to comment.