mirror of
https://gitcode.com/gh_mirrors/re/react-native-pushy.git
synced 2025-10-23 09:38:52 +08:00
support 0.81 android
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"react-native-paper": "^5.14.5",
|
||||
"react-native-safe-area-context": "^5.6.1",
|
||||
"react-native-svg": "^15.13.0",
|
||||
"react-native-update": "^10.31.0-beta.3",
|
||||
"react-native-update": "^10.31.0-beta.4",
|
||||
"react-native-vector-icons": "^10.3.0",
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -1430,7 +1430,7 @@
|
||||
|
||||
"react-native-svg": ["react-native-svg@15.13.0", "", { "dependencies": { "css-select": "^5.1.0", "css-tree": "^1.1.3", "warn-once": "0.1.1" }, "peerDependencies": { "react": "*", "react-native": "*" } }, "sha512-/YPK+PAAXg4T0x2d2vYPvqqAhOYid2bRKxUVT7STIyd1p2JxWmsGQkfZxXCkEFN7TwLfIyVlT5RimT91Pj/qXw=="],
|
||||
|
||||
"react-native-update": ["react-native-update@10.31.0-beta.3", "", { "dependencies": { "nanoid": "^3.3.3", "react-native-url-polyfill": "^2.0.0" }, "peerDependencies": { "react": ">=16.8.0", "react-native": ">=0.59.0" } }, "sha512-ApbK7pFY9E9zbpxKFdCUqYTmzwVhKjAdw6JysWRLZKCxRBwdhifN4vc8QGCKXF/WTQDRdKNX/3M0FKlMNnetQA=="],
|
||||
"react-native-update": ["react-native-update@10.31.0-beta.4", "", { "dependencies": { "nanoid": "^3.3.3", "react-native-url-polyfill": "^2.0.0" }, "peerDependencies": { "react": ">=16.8.0", "react-native": ">=0.59.0" } }, "sha512-6TdSq9PdxH07IHFcMkhMaPxA81teike++PZtgVWbL1GJiZJ5MXpLhwsxD2Nd4x+eHJY8pj4wgMBC8iCAfqVJlg=="],
|
||||
|
||||
"react-native-url-polyfill": ["react-native-url-polyfill@2.0.0", "", { "dependencies": { "whatwg-url-without-unicode": "8.0.0-3" }, "peerDependencies": { "react-native": "*" } }, "sha512-My330Do7/DvKnEvwQc0WdcBnFPploYKp9CYlefDXzIdEaA+PAhDYllkvGeEroEzvc4Kzzj2O4yVdz8v6fjRvhA=="],
|
||||
|
||||
|
@@ -22,7 +22,7 @@
|
||||
"react-native-paper": "^5.14.5",
|
||||
"react-native-safe-area-context": "^5.6.1",
|
||||
"react-native-svg": "^15.13.0",
|
||||
"react-native-update": "^10.31.0-beta.3",
|
||||
"react-native-update": "^10.31.0-beta.4",
|
||||
"react-native-vector-icons": "^10.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@@ -41,6 +41,7 @@ function App() {
|
||||
currentHash,
|
||||
parseTestQrCode,
|
||||
progress: { received, total } = {},
|
||||
currentVersionInfo,
|
||||
} = useUpdate();
|
||||
const [useDefaultAlert, setUseDefaultAlert] = useState(true);
|
||||
const [showTestConsole, setShowTestConsole] = useState(false);
|
||||
@@ -114,6 +115,7 @@ function App() {
|
||||
{'\n'}
|
||||
当前热更新版本Hash: {currentHash || '(空)'}
|
||||
{'\n'}
|
||||
当前热更新版本信息: {JSON.stringify(currentVersionInfo) || '(空)'}
|
||||
</Text>
|
||||
<Text>
|
||||
下载进度:{received} / {total}
|
||||
|
@@ -24,6 +24,38 @@ public class UpdateModuleImpl {
|
||||
|
||||
public static final String NAME = "Pushy";
|
||||
|
||||
/**
|
||||
* 获取字段的兼容性方法,尝试带m前缀和不带m前缀的字段名
|
||||
* @param clazz 目标类
|
||||
* @param fieldName 基础字段名(不带m前缀)
|
||||
* @return 找到的字段对象
|
||||
* @throws NoSuchFieldException 如果两种命名都找不到字段
|
||||
*/
|
||||
private static Field getCompatibleField(Class<?> clazz, String fieldName) throws NoSuchFieldException {
|
||||
// 首先尝试带m前缀的字段名
|
||||
try {
|
||||
return clazz.getDeclaredField("m" + capitalize(fieldName));
|
||||
} catch (NoSuchFieldException e) {
|
||||
// 如果找不到带m前缀的,尝试不带m前缀的
|
||||
try {
|
||||
return clazz.getDeclaredField(fieldName);
|
||||
} catch (NoSuchFieldException e2) {
|
||||
// 如果都找不到,抛出异常并包含两种尝试的信息
|
||||
throw new NoSuchFieldException("Field not found with either name: m" + capitalize(fieldName) + " or " + fieldName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 首字母大写的辅助方法
|
||||
*/
|
||||
private static String capitalize(String str) {
|
||||
if (str == null || str.length() == 0) {
|
||||
return str;
|
||||
}
|
||||
return str.substring(0, 1).toUpperCase() + str.substring(1);
|
||||
}
|
||||
|
||||
public static void downloadFullUpdate(UpdateContext updateContext, final ReadableMap options, final Promise promise) {
|
||||
String url = options.getString("updateUrl");
|
||||
String hash = options.getString("hash");
|
||||
@@ -143,16 +175,16 @@ public class UpdateModuleImpl {
|
||||
ReactDelegate reactDelegate = (ReactDelegate)
|
||||
getReactDelegateMethod.invoke(currentActivity);
|
||||
|
||||
Field reactHostField = ReactDelegate.class.getDeclaredField("mReactHost");
|
||||
Field reactHostField = getCompatibleField(ReactDelegate.class, "reactHost");
|
||||
reactHostField.setAccessible(true);
|
||||
Object reactHost = reactHostField.get(reactDelegate);
|
||||
|
||||
Field devSupport = reactHost.getClass().getDeclaredField("mUseDevSupport");
|
||||
Field devSupport = getCompatibleField(reactHost.getClass(), "useDevSupport");
|
||||
devSupport.setAccessible(true);
|
||||
devSupport.set(reactHost, false);
|
||||
|
||||
// Access the mReactHostDelegate field
|
||||
Field reactHostDelegateField = reactHost.getClass().getDeclaredField("mReactHostDelegate");
|
||||
// Access the ReactHostDelegate field (compatible with mReactHostDelegate/reactHostDelegate)
|
||||
Field reactHostDelegateField = getCompatibleField(reactHost.getClass(), "reactHostDelegate");
|
||||
reactHostDelegateField.setAccessible(true);
|
||||
Object reactHostDelegate = reactHostDelegateField.get(reactHost);
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "react-native-update",
|
||||
"version": "10.31.0-beta.3",
|
||||
"version": "10.31.0-beta.4",
|
||||
"description": "react-native hot update",
|
||||
"main": "src/index",
|
||||
"scripts": {
|
||||
|
Reference in New Issue
Block a user