xxxxxxxxxx
Toast Notifications are popup messages that are added so as to display a message to a user. It can be a success message, warning message, or custom message. Toast Notification is also called Toastify Notifications. This all toast notification comes under-react-toastify module so to use them we need to import this module.
xxxxxxxxxx
import {ToastAndroid} from 'react-native' ;
.
ToastAndroid.showWithGravity(
"All Your Base Are Belong To Us",
ToastAndroid.SHORT,
ToastAndroid.CENTER
);
.
xxxxxxxxxx
import { ToastAndroid, Platform, AlertIOS} from 'react-native';
function notifyMessage(msg: string) {
if (Platform.OS === 'android') {
ToastAndroid.show(msg, ToastAndroid.SHORT)
} else {
AlertIOS.alert(msg);
}
}
xxxxxxxxxx
npm install react-native-simple-toast --save
react-native link react-native-simple-toast // only RN < 0.60
cd ios && pod install
xxxxxxxxxx
<ToastProvider containerOptions={{ portalSelector: document.getElementById('toast-root')!}}>
<App />
</ToastProvider>