package com.zzliaoyuan.decorate_touch.bugly;

import android.content.pm.PackageManager;

import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.tencent.bugly.beta.Beta;
import com.tencent.bugly.beta.UpgradeInfo;
import com.zzliaoyuan.decorate_touch.MainApplication;

public class BuglyModule extends ReactContextBaseJavaModule {
    public BuglyModule(ReactApplicationContext reactContext) {
        super(reactContext);
    }

    @Override
    public String getName() {
        return "Bugly";
    }

    @ReactMethod
    public void checkUpgrade() {
        Beta.checkUpgrade();
    }

    @ReactMethod
    public void getVersion(Callback callback) {
        String verName = "";
        try {
            verName = this.getReactApplicationContext().getPackageManager().
                    getPackageInfo(this.getReactApplicationContext().getPackageName(), 0).versionName;
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        callback.invoke(verName);
    }
}
