Skip to content

Commit 1fe616b

Browse files
drewvolzhawkrives
authored andcommitted
Prompt user when they open the safety home button
1 parent 29885b1 commit 1fe616b

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

modules/open-url/open-url.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
// @flow
22

3-
import {Platform, Linking} from 'react-native'
3+
import {Platform, Linking, Alert} from 'react-native'
44

55
import {trackUrl, trackException} from '@frogpond/analytics'
6+
import {appName} from '@frogpond/constants'
67
import SafariView from 'react-native-safari-view'
78
import {CustomTabs} from 'react-native-custom-tabs'
89

@@ -75,5 +76,15 @@ export function canOpenUrl(url: string) {
7576

7677
export function openUrlInBrowser({url, id}: {url: string, id?: string}) {
7778
trackUrl(id || url)
78-
return genericOpen(url)
79+
return promptConfirm(url)
80+
}
81+
82+
function promptConfirm(url: string) {
83+
const app = appName()
84+
const title = `Leaving ${app}`
85+
const detail = `A web page will be opened in a browser outside of ${app}. Are you sure you want to open it?`
86+
Alert.alert(title, detail, [
87+
{text: 'Cancel', onPress: () => {}},
88+
{text: 'Open', onPress: () => genericOpen(url)},
89+
])
7990
}

0 commit comments

Comments
 (0)