@raulduartep/expo-minimizer
v1.0.0
Published
An Expo module to minimize the current app or navigate back to the previous app
Downloads
23
Maintainers
Readme
expo-minimizer
An Expo module to minimize the current app or navigate back to the previous app.
Installation
npm install @raulduartep/expo-minimizeror
yarn add @raulduartep/expo-minimizerUsage
Import the module in your React Native component:
import { goBackToPreviousApp, minimizeApp } from "expo-minimizer";goBackToPreviousApp()
Navigates back to the previously opened app. This is useful when you want to return the user to the app they were using before opening your app.
import React from "react";
import { View, Button } from "react-native";
import { goBackToPreviousApp } from "expo-minimizer";
export default function App() {
const handleGoBack = () => {
goBackToPreviousApp();
};
return (
<View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}>
<Button title="Go Back to Previous App" onPress={handleGoBack} />
</View>
);
}minimizeApp()
Minimizes the current app, sending it to the background. This is equivalent to pressing the home button on the device.
import React from "react";
import { View, Button } from "react-native";
import { minimizeApp } from "expo-minimizer";
export default function App() {
const handleMinimize = () => {
minimizeApp();
};
return (
<View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}>
<Button title="Minimize App" onPress={handleMinimize} />
</View>
);
}Complete Example
import React from "react";
import { View, Button, StyleSheet } from "react-native";
import { goBackToPreviousApp, minimizeApp } from "expo-minimizer";
export default function App() {
return (
<View style={styles.container}>
<Button
title="Go Back to Previous App"
onPress={goBackToPreviousApp}
style={styles.button}
/>
<Button
title="Minimize App"
onPress={minimizeApp}
style={styles.button}
/>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: "center",
alignItems: "center",
gap: 20,
},
button: {
marginVertical: 10,
},
});API Reference
Functions
| Function | Description | Parameters | Returns |
| ----------------------- | ------------------------------------------- | ---------- | ------- |
| goBackToPreviousApp() | Navigates back to the previously opened app | None | void |
| minimizeApp() | Minimizes the current app to the background | None | void |
Platform Support
- ✅ iOS
- ✅ Android
- ❌ Web (Not applicable)
License
MIT
Issues
If you encounter any issues, please report them on GitHub Issues.
Author
Created by raulduartep
