Integration With Existing Apps Demo
import { DeviceEventEmitter } from 'react-native';
componentDidMount() {
DeviceEventEmitter.addListener('qrCode', function(e: Event) {
console.warn('qrCode : ', e);
});
}
public void sendEventQrCode() {
String qrCode = "876398776";
ReactContext reactContext = mReactInstanceManager.getCurrentReactContext();
if (reactContext != null) {
reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
.emit("qrCode", qrCode);
}
}
@ReactMethod
public void showMessage(String message, Callback successCallback) {
String finalMsg = message +" Test "+" final message";
Toast.makeText(getReactApplicationContext(), finalMsg, Toast.LENGTH_LONG).show();
successCallback.invoke(finalMsg);
}
import { NativeModules } from 'react-native';
var RCTToastAndroid = NativeModules.ToastCustomModule;
RCTToastAndroid.showMessage('Awesome', result => {
console.warn(result);
});