Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
package com.reactnative.example.reactnativemodules;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import java.util.Map;
import javax.annotation.nullable;
import com.crashlytics.android.Crashlytics;
import com.facebook.react.bridge.ReactMethod;
public class CrashlyticsModule extends ReactContextBaseJavaModule{
public CrashlyticsModule(ReactApplicationContext applicationContext){
super(applicationContext);
}
@Override
public string getName(){
return "CrashlyticsModule";
}
@Nullable
@Override
public Map<String, Object> getConstants(){
return super.getConstants();
}
@ReactMethod
public void SetUserProfile(string profile){
Crashlytics.setStrint("profile", profile);
}
@ReactMethod
public void Log(String tag, String message){
Crashlytics.log(Log.DEBUG, tag, message);
}
}
package com.reactnative.example;
import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;
import com.reactnative.example.reactnativemodules.CrashlyticsModule;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class ReactCrashlyticsPackage implements ReactPackage {
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
List<NativeModule> modules = new ArrayList<>();
modules.add(new CrashlyticsModule(reactContext));
return modules;
}
public List<Class<? extends JavaScriptModule>> createJSModules() {
return Collections.emptyList();
}
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
return Collections.emptyList();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment