react-native-ussd
React Native Library to handle USSD.
TODO: Need to implement functionalities for IOS, Currently only work for Android
Getting started
$ npm install react-native-ussd --save
Mostly automatic installation
$ react-native link react-native-ussd
Usage
Following configurations need to be done before using in either of the platforms
Android
Add permissions to Make calls in the Manifest
IOS
[ TODO]
....
Dialing a USSD CODE
Ussd code can be dialled simply by calling dial method with required dialling number.
; // Add USSD code you want to dialUssd;
A event listener should be initialized to listen for ussd replies from the dialling made using Ussd.dial()
; // Add USSD code you want to dialUssd; ...// in useEffect or in componentDidMountthiseventListener = ussdEventEmitter; ... //unregister the listener after using (probably in componentWillUnmount)thiseventListener;...
Example Usecase
;;; Component state = userBalance:0 expiryDate:'' ; async { let granted = await PermissionsAndroid if granted console; Ussd; console; else console; } { thiseventListener = ussdEventEmitter; } { thiseventListener; } { return <View > <TouchableOpacity onPress= this> <Text>Check Balance</Text> </TouchableOpacity> <Text>Your Balance is: thisstateuserBalance</Text> <Text>Expiry Date is: thisstateexpiryDate</Text> </View> ; }