H5W3
当前位置:H5W3 > 其他技术问题 > 正文

【前端问题精选】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.虽然服务器能够工作,在手机上也能检查更新与否,但是老是提示更新失败,上网也查了很多资料,也没有成功,有没有哪位前辈做过这个,给小弟一点提示,感激不尽。

回答:

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

本文地址:H5W3 » 【前端问题精选】ionic3 code-push 搭建自己服务器的问题

评论 0

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址