yone
yone

Reputation: 121

How to send intent data to Javascript from ReactActivity of React Native

I want to send intent value to Java Script from ReactActivity of React Native.

I write following example code. How to send "tag" to JavaScript

public class MainActivity extends ReactActivity {
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   Intent intent = getIntent();
   Tag tag = (Tag) intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);

    // I want to send tag data to Javascript
    // How to do?
 }  

Upvotes: 0

Views: 1965

Answers (1)

Ishant Sagar
Ishant Sagar

Reputation: 228

public class CustomActivity extends ReactActivity {

@Override
protected String getMainComponentName() {
    return "CustomJSScene";
}

@Override
protected ReactActivityDelegate createReactActivityDelegate() {
    return new ReactActivityDelegate(this, getMainComponentName()) {

        @javax.annotation.Nullable
        @Override
        protected Bundle getLaunchOptions() {
            Bundle initialProps = new Bundle()
            initialProps.putString("key", "value");
            return initialProps;
        }
    };
}

Upvotes: 1

Related Questions