在react native中,我们可以用这个来打开一个特定的吗?这里extra
有什么用
import React, { useCallback } from "react";
import { Alert, Button, Linking, StyleSheet, View } from "react-native";
const SendIntentButton = ({ action, extras, children }) => {
const handlePress = useCallback(async () => {
try {
await Linking.sendIntent(action, extras);
} catch (e) {
Alert.alert(e.message);
}
}, [action, extras]);
return <Button title={children} onPress={handlePress} />;
};
const App = () => {
return (
<View style={styles.container}>
<SendIntentButton action="android.intent.action.POWER_USAGE_SUMMARY">
Power Usage Summary
</SendIntentButton>
<SendIntentButton
action="android.settings.APP_NOTIFICATION_SETTINGS"
extras={[
{ "android.provider.extra.APP_PACKAGE": "com.facebook.katana" },
]}
>
App Notification Settings
</SendIntentButton>
</View>
);
};
const styles = StyleSheet.create({
container: { flex: 1, justifyContent: "center", alignItems: "center" },
});
export default App;
尝试理解android中的意图
1条答案
按热度按时间tzcvj98z1#
在Android上,这将在设置中打开通知。
extras
提供了您要编辑通知设置的应用程序。有关此属性的更多信息,请参阅Android文档。通常,这些额外内容应包括应用的标识符。