Thanks in advance for the help, i need to make a module for react-native that gets a deeplink open an application and gets the return of a 'data' that the application returned, but I'm new to react-native, this involves java (with android) looking at the module code react-native-activity-result. My test sample code to try to perform the module
Codigo do módulo react-native-activity-result
@ReactMethod
public void startActivityForResult(int requestCode, String action, ReadableMap data, Promise promise) {
Activity activity = getReactApplicationContext().getCurrentActivity();
Intent intent = new Intent(action);
intent.putExtras(Arguments.toBundle(data));
activity.startActivityForResult(intent, requestCode);
mPromises.put(requestCode, promise);
}
application code that needs to be opened by deeplink
Private final int REQUEST_CODE = 1001;
protected void onCreate(@Nullable Bundle savedInstanceState){
super.onCreate(savedInstanceState);
Bundle bundle = new Bundle();
bundle.putString("amount","0000000000100");
bundle.putString("currencyPosition","CURRENCY_AFTER_AMOUNT");
bundle.putString("currencyCode","986");
Intent intent = new Intent(Intent.ACTION_VIEW,Uri.parse("getnet://pagamento/v1/payment"));
intent.putExtras(bundle);
startActivityForResult(intent,REQUEST_CODE)
}
My test sample code to try to perform the module
@ReactMethod
public void startActivityForResultUnintentionally(int requestCode, String deepLink, ReadableMap data, Promise promise) {
Activity activity = getReactApplicationContext().getCurrentActivity();
Intent intent = new Intent(ACTION_VIEW,Uri.parse(deepLink));
intent.putExtras(Arguments.toBundle(data));
activity.startActivityForResultUnintentionally(intent, requestCode);
mPromises.put(requestCode, promise);
I got 1 I took the action parameter and in place I added a deepLink parameter, then where the action parameter made sense I put the ACTION.VIEW, and another parameter added the Deeplink converting from String to Uri.
@ReactMethod
public void startActivityForResult(int requestCode, String deeplink, ReadableMap data, Promise promise) {
Activity activity = getReactApplicationContext().getCurrentActivity();
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(deeplink));
intent.putExtras(Arguments.toBundle(data));
activity.startActivityForResult(intent, requestCode);
mPromises.put(requestCode, promise);
}