Skip to content
Advertisement

Java Function Return to React-Native

I’m developing an application with an integration Smart-POS. My application is in React-Native and the card reading or printing options are created through Java functions.

In other words, I’m calling a function in React-Native that is requesting a function in a Java file that communicates with the device and gives me a return.

Problem: I’m not getting any return after executing the functions in Java.

Here are code details:

React-Native Code:

JavaScript

After executing this function, I call the Apos.js file that contains this information:

JavaScript

This file then calls a .java file with the function I’m requesting:

JavaScript

In this return, through adb logcat I can see if putting one System.out.println(result); is returning all the transaction data to the console, but it goes back to React Native with return undefined.

This is an example of a return:

JavaScript

For details, I’m integrating PagSeguro’s Moderninha API.

Has anyone been through this situation?

Advertisement

Answer

You just need to change your function from String to void and send the response as a promise, like this:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement