mirror of
https://github.com/standardnotes/mobile.git
synced 2026-04-19 13:49:03 -04:00
Handle URL open exceptions
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import {AppState, Platform, NativeModules} from 'react-native'
|
||||
import {AppState, Platform, NativeModules, Linking, Alert} from 'react-native'
|
||||
const { PlatformConstants } = NativeModules;
|
||||
import KeysManager from "@Lib/keysManager"
|
||||
import OptionsState from "@Lib/OptionsState"
|
||||
@@ -299,4 +299,20 @@ export default class ApplicationState {
|
||||
onAuthenticate: this.unlockApplication.bind(this)
|
||||
}
|
||||
}
|
||||
|
||||
static openURL(url) {
|
||||
let showAlert = () => {
|
||||
Alert.alert("Unable to Open", `Unable to open URL ${url}.`);
|
||||
}
|
||||
|
||||
Linking.canOpenURL(url)
|
||||
.then((supported) => {
|
||||
if (!supported) {
|
||||
showAlert();
|
||||
} else {
|
||||
return Linking.openURL(url);
|
||||
}
|
||||
})
|
||||
.catch((err) => showAlert());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,18 +14,18 @@ export default class CompanySection extends Component {
|
||||
onAction = (action) => {
|
||||
if(action == "feedback") {
|
||||
var platformString = Platform.OS == "android" ? "Android" : "iOS";
|
||||
Linking.openURL(`mailto:hello@standardnotes.org?subject=${platformString} app feedback (v${ApplicationState.version})`);
|
||||
ApplicationState.openURL(`mailto:hello@standardnotes.org?subject=${platformString} app feedback (v${ApplicationState.version})`);
|
||||
} else if(action == "learn_more") {
|
||||
Linking.openURL("https://standardnotes.org");
|
||||
ApplicationState.openURL("https://standardnotes.org");
|
||||
} else if(action == "privacy") {
|
||||
Linking.openURL("https://standardnotes.org/privacy");
|
||||
ApplicationState.openURL("https://standardnotes.org/privacy");
|
||||
} else if(action == "help") {
|
||||
Linking.openURL("https://standardnotes.org/help");
|
||||
ApplicationState.openURL("https://standardnotes.org/help");
|
||||
} else if(action == "rate") {
|
||||
if(ApplicationState.isIOS) {
|
||||
Linking.openURL("https://itunes.apple.com/us/app/standard-notes/id1285392450?ls=1&mt=8");
|
||||
ApplicationState.openURL("https://itunes.apple.com/us/app/standard-notes/id1285392450?ls=1&mt=8");
|
||||
} else {
|
||||
Linking.openURL("market://details?id=com.standardnotes");
|
||||
ApplicationState.openURL("market://details?id=com.standardnotes");
|
||||
}
|
||||
} else if(action == "friend") {
|
||||
let title = "Standard Notes";
|
||||
|
||||
@@ -124,7 +124,7 @@ export default class MainSideMenu extends AbstractSideMenu {
|
||||
side: "right",
|
||||
size: 17
|
||||
},
|
||||
onSelect: () => { Linking.openURL("https://standardnotes.org/extensions")},
|
||||
onSelect: () => { ApplicationState.openURL("https://standardnotes.org/extensions")},
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@@ -259,7 +259,7 @@ export default class NoteSideMenu extends AbstractSideMenu {
|
||||
side: "right",
|
||||
size: 17
|
||||
},
|
||||
onSelect: () => { Linking.openURL("https://standardnotes.org/extensions")},
|
||||
onSelect: () => { ApplicationState.openURL("https://standardnotes.org/extensions")},
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user