fix: redirect the user to the phone app (#5441)

* fix: redirect the user to the phone app

* minor tweak
This commit is contained in:
Reinaldo Neto 2024-01-04 17:09:46 -03:00 committed by GitHub
parent 2ff39d9a62
commit 30253aa4cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View File

@ -6,6 +6,7 @@ import { themes } from '../../constants';
import { TSupportedThemes } from '../../../theme';
import UserPreferences from '../userPreferences';
import ensureSecureProtocol from './ensureSecureProtocol';
import log from './log';
export const DEFAULT_BROWSER_KEY = 'DEFAULT_BROWSER_KEY';
@ -38,6 +39,16 @@ const appSchemeURL = (url: string, browser: string): string => {
};
const openLink = async (url: string, theme: TSupportedThemes = 'light'): Promise<void> => {
const telRegExp = new RegExp(/^(tel:)/);
if (telRegExp.test(url)) {
try {
await Linking.openURL(url);
return;
} catch (e) {
log(e);
}
}
url = ensureSecureProtocol(url);
try {
const browser = UserPreferences.getString(DEFAULT_BROWSER_KEY);

View File

@ -54,6 +54,7 @@
<string>googlechromes</string>
<string>firefox</string>
<string>brave</string>
<string>tel</string>
</array>
<key>LSRequiresIPhoneOS</key>
<true/>