Skip to content

Instantly share code, notes, and snippets.

@ryardley
Last active January 1, 2019 21:51
Show Gist options
  • Save ryardley/3dac2e43f4b9df9548e872c7b8e82d27 to your computer and use it in GitHub Desktop.
Save ryardley/3dac2e43f4b9df9548e872c7b8e82d27 to your computer and use it in GitHub Desktop.
// android/app/src/main/java/com/cppreactnative/helloworld/HelloWorldModule.java
package com.cppreactnative.helloworld;
import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
public class HelloWorldModule extends ReactContextBaseJavaModule {
public HelloWorldModule(ReactApplicationContext reactContext) {
super(reactContext); //required by React Native
}
@Override
public String getName() {
return "HelloWorld"; //HelloWorld is how this module will be referred to from React Native
}
@ReactMethod
public void sayHello(Promise promise) { //this method will be called from JS by React Native
promise.resolve("Hello from Android");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment