Toast alert in Android & IOS creat react native expo

Viewed 9347

I am creating an APP using managed expo react native.

And want to implement Toast alerts, react-native provides Toast only for Android not for IOS.

I googled it and found the couple of modules which works on Android and ios but they required some config change in Native code. But as I said I am working on Managed expo app. So, I don't have access for that.

Now let me know how I can implement Toast on this?

Thanks.

2 Answers

As toast is a native feature in android, for ios try snakbar.

import {
    ToastAndroid,
    Platform
} from "react-native";
import Snackbar from 'react-native-snackbar';

notify = (message) => {
    if (Platform.OS != 'android') {
        Snackbar.show({
            text: message,
            duration: Snackbar.LENGTH_SHORT,
        });
    } else {
        ToastAndroid.show(message, ToastAndroid.SHORT);
    }
}

** If you are on expo https://snack.expo.io/@mainak/snackbar

Related