lisong / code-push-server

CodePush service is hot update services which adapter react-native-code-push and cordova-plugin-code-push - 热更新
MIT License
1.84k stars 546 forks source link

ionic3 code-push-server #96

Open daozun opened 7 years ago

daozun commented 7 years ago

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

daozun commented 7 years ago

因为这个问题我是复制过来的,如有任何冒犯之处说声抱歉,提前致谢大家

anitaihua commented 6 years ago

app.js中请求头Access-Control-Allow-Headers添加X-CodePush-Plugin-Version, X-CodePush-Plugin-Name, X-CodePush-SDK-Version就好了

daozun commented 6 years ago

app.js中请求头Access-Control-Allow-Headers添加X-CodePush-Plugin-Version, X-CodePush-Plugin-Name, X-CodePush-SDK-Version就好了

谢谢回复,虽然我现在不做ionic了,哈哈