mirror of
https://gitcode.com/gh_mirrors/re/react-native-pushy.git
synced 2025-09-17 22:36:09 +08:00
Compare commits
1 Commits
v6.0.4
...
v6.0.0-bet
Author | SHA1 | Date | |
---|---|---|---|
![]() |
6da2d7d2d7 |
@@ -36,8 +36,6 @@ project.xcworkspace
|
|||||||
.idea
|
.idea
|
||||||
.gradle
|
.gradle
|
||||||
local.properties
|
local.properties
|
||||||
android/build
|
|
||||||
android/obj
|
|
||||||
|
|
||||||
# node.js
|
# node.js
|
||||||
#
|
#
|
||||||
@@ -45,6 +43,7 @@ node_modules/
|
|||||||
npm-debug.log
|
npm-debug.log
|
||||||
Example
|
Example
|
||||||
yarn.lock
|
yarn.lock
|
||||||
|
android/jni
|
||||||
|
|
||||||
domains.json
|
domains.json
|
||||||
endpoints.json
|
endpoints.json
|
3
Example/testHotUpdate/.gitignore
vendored
3
Example/testHotUpdate/.gitignore
vendored
@@ -57,6 +57,3 @@ buck-out/
|
|||||||
|
|
||||||
# CocoaPods
|
# CocoaPods
|
||||||
/ios/Pods/
|
/ios/Pods/
|
||||||
|
|
||||||
|
|
||||||
.pushy
|
|
@@ -139,9 +139,9 @@ android {
|
|||||||
splits {
|
splits {
|
||||||
abi {
|
abi {
|
||||||
reset()
|
reset()
|
||||||
enable true
|
enable enableSeparateBuildPerCPUArchitecture
|
||||||
universalApk false // If true, also generate a universal APK
|
universalApk false // If true, also generate a universal APK
|
||||||
include "x86", "arm64-v8a"
|
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
signingConfigs {
|
signingConfigs {
|
||||||
|
@@ -8,12 +8,11 @@
|
|||||||
|
|
||||||
### 优势
|
### 优势
|
||||||
|
|
||||||
1. 基于阿里云高速 CDN 分发,对比其他在服务器在国外的热更新服务,分发更稳定,更新成功率极高。
|
1. 命令行工具&网页双端管理,版本发布过程简单便捷,完全可以集成 CI。
|
||||||
2. 基于 bsdiff/hdiff 算法创建的**超小更新包**,通常版本迭代后在 1-10KB 之间,避免数百 KB 的流量消耗。
|
2. 基于 bsdiff/hdiff 算法创建的**超小更新包**,通常版本迭代后在 1-10KB 之间,避免数百 KB 的流量消耗。
|
||||||
3. 跨越多个版本进行更新时,只需要下载**一个更新包**,不需要逐版本依次更新。
|
3. 支持崩溃回滚,安全可靠。
|
||||||
4. 命令行工具&网页双端管理,版本发布过程简单便捷,完全可以集成 CI。
|
4. meta 信息及开放 API,提供更高扩展性。
|
||||||
5. 支持崩溃回滚,安全可靠。
|
5. 跨越多个版本进行更新时,只需要下载**一个更新包**,不需要逐版本依次更新。
|
||||||
6. meta 信息及开放 API,提供更高扩展性。
|
|
||||||
|
|
||||||
### 本地开发
|
### 本地开发
|
||||||
|
|
||||||
|
@@ -2,8 +2,6 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="cn.reactnative.modules.update">
|
package="cn.reactnative.modules.update">
|
||||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
|
||||||
<application>
|
<application>
|
||||||
<meta-data android:name="pushy_build_time" android:value="@string/pushy_build_time" />
|
<meta-data android:name="pushy_build_time" android:value="@string/pushy_build_time" />
|
||||||
<provider
|
<provider
|
||||||
|
@@ -4,10 +4,7 @@ import android.content.Context;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Environment;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.facebook.react.ReactInstanceManager;
|
import com.facebook.react.ReactInstanceManager;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -16,6 +13,7 @@ import java.util.concurrent.Executor;
|
|||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by tdzl2003 on 3/31/16.
|
* Created by tdzl2003 on 3/31/16.
|
||||||
@@ -109,14 +107,7 @@ public class UpdateContext {
|
|||||||
params.url = url;
|
params.url = url;
|
||||||
params.hash = hash;
|
params.hash = hash;
|
||||||
params.listener = listener;
|
params.listener = listener;
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N && fileName.equals("update.apk")) {
|
|
||||||
params.targetFile = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "pushy_update.apk");
|
|
||||||
|
|
||||||
} else {
|
|
||||||
params.targetFile = new File(rootDir, fileName);
|
params.targetFile = new File(rootDir, fileName);
|
||||||
|
|
||||||
}
|
|
||||||
// params.unzipDirectory = new File(rootDir, hash);
|
// params.unzipDirectory = new File(rootDir, hash);
|
||||||
new DownloadTask(context).executeOnExecutor(this.executor, params);
|
new DownloadTask(context).executeOnExecutor(this.executor, params);
|
||||||
}
|
}
|
||||||
|
@@ -125,14 +125,15 @@ public class UpdateModule extends ReactContextBaseJavaModule {
|
|||||||
intent.setData(apkUri);
|
intent.setData(apkUri);
|
||||||
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
mContext.startActivity(intent);
|
||||||
} else {
|
} else {
|
||||||
apkUri = Uri.fromFile(toInstall);
|
apkUri = Uri.fromFile(toInstall);
|
||||||
intent = new Intent(Intent.ACTION_VIEW);
|
intent = new Intent(Intent.ACTION_VIEW);
|
||||||
intent.setDataAndType(apkUri, "application/vnd.android.package-archive");
|
intent.setDataAndType(apkUri, "application/vnd.android.package-archive");
|
||||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
}
|
|
||||||
mContext.startActivity(intent);
|
mContext.startActivity(intent);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
private void downloadPatchFromPackage(ReadableMap options, final Promise promise) {
|
private void downloadPatchFromPackage(ReadableMap options, final Promise promise) {
|
||||||
|
29
lib/index.js
29
lib/index.js
@@ -3,12 +3,7 @@ import {
|
|||||||
getCheckUrl,
|
getCheckUrl,
|
||||||
setCustomEndpoints,
|
setCustomEndpoints,
|
||||||
} from './endpoint';
|
} from './endpoint';
|
||||||
import {
|
import { NativeEventEmitter, NativeModules, Platform } from 'react-native';
|
||||||
NativeEventEmitter,
|
|
||||||
NativeModules,
|
|
||||||
Platform,
|
|
||||||
PermissionsAndroid,
|
|
||||||
} from 'react-native';
|
|
||||||
export { setCustomEndpoints };
|
export { setCustomEndpoints };
|
||||||
const {
|
const {
|
||||||
version: v,
|
version: v,
|
||||||
@@ -166,20 +161,11 @@ export async function downloadUpdate(options, eventListeners) {
|
|||||||
}
|
}
|
||||||
if (options.diffUrl) {
|
if (options.diffUrl) {
|
||||||
logger('downloading diff');
|
logger('downloading diff');
|
||||||
try {
|
|
||||||
await Pushy.downloadPatchFromPpk({
|
await Pushy.downloadPatchFromPpk({
|
||||||
updateUrl: options.diffUrl,
|
updateUrl: options.diffUrl,
|
||||||
hash: options.hash,
|
hash: options.hash,
|
||||||
originHash: currentVersion,
|
originHash: currentVersion,
|
||||||
});
|
});
|
||||||
} catch (e) {
|
|
||||||
logger(e.message);
|
|
||||||
logger('diff error, try pdiff');
|
|
||||||
await Pushy.downloadPatchFromPackage({
|
|
||||||
updateUrl: options.pdiffUrl,
|
|
||||||
hash: options.hash,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else if (options.pdiffUrl) {
|
} else if (options.pdiffUrl) {
|
||||||
logger('downloading pdiff');
|
logger('downloading pdiff');
|
||||||
await Pushy.downloadPatchFromPackage({
|
await Pushy.downloadPatchFromPackage({
|
||||||
@@ -188,7 +174,6 @@ export async function downloadUpdate(options, eventListeners) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
progressHandler && progressHandler.remove();
|
progressHandler && progressHandler.remove();
|
||||||
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
||||||
return options.hash;
|
return options.hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,18 +197,6 @@ export function markSuccess() {
|
|||||||
|
|
||||||
export async function downloadAndInstallApk({ url, onDownloadProgress }) {
|
export async function downloadAndInstallApk({ url, onDownloadProgress }) {
|
||||||
logger('downloadAndInstallApk');
|
logger('downloadAndInstallApk');
|
||||||
if (Platform.OS === 'android' && Platform.Version <= 23) {
|
|
||||||
try {
|
|
||||||
const granted = await PermissionsAndroid.request(
|
|
||||||
PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,
|
|
||||||
);
|
|
||||||
if (granted !== PermissionsAndroid.RESULTS.GRANTED) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.warn(err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let hash = Date.now().toString();
|
let hash = Date.now().toString();
|
||||||
let progressHandler;
|
let progressHandler;
|
||||||
if (onDownloadProgress) {
|
if (onDownloadProgress) {
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "react-native-update",
|
"name": "react-native-update",
|
||||||
"version": "6.0.4",
|
"version": "6.0.0-beta0",
|
||||||
"description": "react-native hot update",
|
"description": "react-native hot update",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
Reference in New Issue
Block a user