ionic3 code-push 搭建自己服务器的问题

1.我想用热更新我的ionic3项目,参考了文章:http://blog.csdn.net/h2545326...
按照这位博主说的一步步做下来了,但是因为我的这个是ionic项目,所以有一个步骤和博主有些不同,我按照自己的理解,把node_module下的code-push.java改成了如下代码:
public class CodePush extends CordovaPlugin {

private static final String DEPLOYMENT_KEY_PREFERENCE = "B1kiIZeeAPJFQCoOiwhEUN3xOBxf4ksvOXqoa"; //改了key(key我做了改动)
private static final String WWW_ASSET_PATH_PREFIX = "file:///android_asset/www/"; 
private static boolean ShouldClearHistoryOnLoad = false;
private CordovaWebView mainWebView;
private CodePushPackageManager codePushPackageManager;
private CodePushReportingManager codePushReportingManager;
private StatusReport rollbackStatusReport;
private boolean pluginDestroyed = false;
private boolean didUpdate = false;
private boolean didStartApp = false;
private long lastPausedTimeMs = 0;

@Override
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
    super.initialize(cordova, webView);
    CodePushPreferences codePushPreferences = new CodePushPreferences(cordova.getActivity());
    codePushPackageManager = new CodePushPackageManager(cordova.getActivity(), codePushPreferences);
    codePushReportingManager = new CodePushReportingManager(cordova.getActivity(), codePushPreferences);
    mainWebView = webView;
}

@Override
public boolean execute(String action, CordovaArgs args, final CallbackContext callbackContext) {
    if ("getAppVersion".equals(action)) {
        return execGetAppVersion(callbackContext);
    } else if ("getBinaryHash".equals(action)) {
        return execGetBinaryHash(callbackContext);
    } else if ("getDeploymentKey".equals(action)) {
        this.returnStringPreference(DEPLOYMENT_KEY_PREFERENCE, callbackContext);
        return true;
    } else if ("getNativeBuildTime".equals(action)) {
        return execGetNativeBuildTime(callbackContext);
    } else if ("getServerURL".equals(action)) {
        this.returnStringPreference("http://10.220.165.145:3000/", callbackContext); //改了ip
        return true;
    } else if ("install".equals(action)) {
        return execInstall(args, callbackContext);
    } else if ("isFailedUpdate".equals(action)) {
        return execIsFailedUpdate(args, callbackContext);
    } else if ("isFirstRun".equals(action)) {
        return execIsFirstRun(args, callbackContext);
    } else if ("isPendingUpdate".equals(action)) {
        return execIsPendingUpdate(args, callbackContext);
    } else if ("notifyApplicationReady".equals(action)) {
        return execNotifyApplicationReady(callbackContext);
    } else if ("preInstall".equals(action)) {
        return execPreInstall(args, callbackContext);
    } else if ("reportFailed".equals(action)) {
        return execReportFailed(args, callbackContext);
    } else if ("reportSucceeded".equals(action)) {
        return execReportSucceeded(args, callbackContext);
    } else if ("restartApplication".equals(action)) {
        return execRestartApplication(args, callbackContext);
    } else {
        return false;
    }
}

2.虽然服务器能够工作,在手机上也能检查更新与否,但是老是提示更新失败,上网也查了很多资料,也没有成功,有没有哪位前辈做过这个,给小弟一点提示,感激不尽。

阅读 3.1k
1 个回答
新手上路,请多包涵

请问下,我的ionic项目一直不能向codepush服务器发请求,有没有碰到过

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题