mirror of
https://gitcode.com/gh_mirrors/re/react-native-pushy.git
synced 2025-09-16 12:11:39 +08:00
support 0.76
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
apply plugin: "com.android.application"
|
apply plugin: "com.android.application"
|
||||||
|
apply plugin: "org.jetbrains.kotlin.android"
|
||||||
apply plugin: "com.facebook.react"
|
apply plugin: "com.facebook.react"
|
||||||
apply plugin: "kotlin-android"
|
|
||||||
apply plugin: "kotlin-android-extensions"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the configuration block to customize your React Native Android app.
|
* This is the configuration block to customize your React Native Android app.
|
||||||
@@ -50,6 +49,7 @@ react {
|
|||||||
//
|
//
|
||||||
// The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
|
// The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
|
||||||
// hermesFlags = ["-O", "-output-source-map"]
|
// hermesFlags = ["-O", "-output-source-map"]
|
||||||
|
autolinkLibrariesWithApp()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -106,21 +106,14 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// The version of react-native is set by the React Native Gradle Plugin
|
// The version of react-native is set by the React Native Gradle Plugin
|
||||||
implementation("com.facebook.react:react-android")
|
implementation("com.facebook.react:react-android")
|
||||||
|
|
||||||
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
|
|
||||||
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
|
|
||||||
exclude group:'com.squareup.okhttp3', module:'okhttp'
|
|
||||||
}
|
|
||||||
|
|
||||||
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}")
|
|
||||||
if (hermesEnabled.toBoolean()) {
|
if (hermesEnabled.toBoolean()) {
|
||||||
implementation("com.facebook.react:hermes-android")
|
implementation("com.facebook.react:hermes-android")
|
||||||
} else {
|
} else {
|
||||||
implementation jscFlavor
|
implementation jscFlavor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
|
|
||||||
|
@@ -1,73 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
||||||
*
|
|
||||||
* <p>This source code is licensed under the MIT license found in the LICENSE file in the root
|
|
||||||
* directory of this source tree.
|
|
||||||
*/
|
|
||||||
package com.awesomeproject;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import com.facebook.flipper.android.AndroidFlipperClient;
|
|
||||||
import com.facebook.flipper.android.utils.FlipperUtils;
|
|
||||||
import com.facebook.flipper.core.FlipperClient;
|
|
||||||
import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin;
|
|
||||||
import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin;
|
|
||||||
import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin;
|
|
||||||
import com.facebook.flipper.plugins.inspector.DescriptorMapping;
|
|
||||||
import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin;
|
|
||||||
import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor;
|
|
||||||
import com.facebook.flipper.plugins.network.NetworkFlipperPlugin;
|
|
||||||
import com.facebook.flipper.plugins.react.ReactFlipperPlugin;
|
|
||||||
import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin;
|
|
||||||
import com.facebook.react.ReactInstanceEventListener;
|
|
||||||
import com.facebook.react.ReactInstanceManager;
|
|
||||||
import com.facebook.react.bridge.ReactContext;
|
|
||||||
import com.facebook.react.modules.network.NetworkingModule;
|
|
||||||
import okhttp3.OkHttpClient;
|
|
||||||
|
|
||||||
public class ReactNativeFlipper {
|
|
||||||
public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
|
|
||||||
if (FlipperUtils.shouldEnableFlipper(context)) {
|
|
||||||
final FlipperClient client = AndroidFlipperClient.getInstance(context);
|
|
||||||
|
|
||||||
client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));
|
|
||||||
client.addPlugin(new ReactFlipperPlugin());
|
|
||||||
client.addPlugin(new DatabasesFlipperPlugin(context));
|
|
||||||
client.addPlugin(new SharedPreferencesFlipperPlugin(context));
|
|
||||||
client.addPlugin(CrashReporterPlugin.getInstance());
|
|
||||||
|
|
||||||
NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin();
|
|
||||||
NetworkingModule.setCustomClientBuilder(
|
|
||||||
new NetworkingModule.CustomClientBuilder() {
|
|
||||||
@Override
|
|
||||||
public void apply(OkHttpClient.Builder builder) {
|
|
||||||
builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
client.addPlugin(networkFlipperPlugin);
|
|
||||||
client.start();
|
|
||||||
|
|
||||||
// Fresco Plugin needs to ensure that ImagePipelineFactory is initialized
|
|
||||||
// Hence we run if after all native modules have been initialized
|
|
||||||
ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
|
|
||||||
if (reactContext == null) {
|
|
||||||
reactInstanceManager.addReactInstanceEventListener(
|
|
||||||
new ReactInstanceEventListener() {
|
|
||||||
@Override
|
|
||||||
public void onReactContextInitialized(ReactContext reactContext) {
|
|
||||||
reactInstanceManager.removeReactInstanceEventListener(this);
|
|
||||||
reactContext.runOnNativeModulesQueueThread(
|
|
||||||
new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
client.addPlugin(new FrescoFlipperPlugin());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
client.addPlugin(new FrescoFlipperPlugin());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -65,6 +65,5 @@ public class MainApplication extends Application implements ReactApplication {
|
|||||||
// If you opted-in for the New Architecture, we load the native entry point for this app.
|
// If you opted-in for the New Architecture, we load the native entry point for this app.
|
||||||
DefaultNewArchitectureEntryPoint.load();
|
DefaultNewArchitectureEntryPoint.load();
|
||||||
}
|
}
|
||||||
ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,15 +1,11 @@
|
|||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
ext {
|
ext {
|
||||||
buildToolsVersion = "34.0.0"
|
buildToolsVersion = "35.0.0"
|
||||||
minSdkVersion = 23
|
minSdkVersion = 24
|
||||||
compileSdkVersion = 34
|
compileSdkVersion = 35
|
||||||
targetSdkVersion = 34
|
targetSdkVersion = 34
|
||||||
ndkVersion = "26.1.10909125"
|
ndkVersion = "26.1.10909125"
|
||||||
kotlinVersion = "1.9.24"
|
kotlinVersion = "1.9.24"
|
||||||
|
|
||||||
kotlin_version = '1.9.24'
|
|
||||||
}
|
}
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
@@ -21,3 +17,5 @@ buildscript {
|
|||||||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
|
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
apply plugin: "com.facebook.react.rootproject"
|
||||||
|
@@ -21,11 +21,6 @@ org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m
|
|||||||
# Android operating system, and which are packaged with your app's APK
|
# Android operating system, and which are packaged with your app's APK
|
||||||
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
||||||
android.useAndroidX=true
|
android.useAndroidX=true
|
||||||
# Automatically convert third-party libraries to use AndroidX
|
|
||||||
android.enableJetifier=true
|
|
||||||
|
|
||||||
# Version of flipper SDK to use with React Native
|
|
||||||
FLIPPER_VERSION=0.182.0
|
|
||||||
|
|
||||||
# Use this property to specify which architecture you want to build.
|
# Use this property to specify which architecture you want to build.
|
||||||
# You can also override it from the CLI using
|
# You can also override it from the CLI using
|
||||||
|
34
Example/testHotUpdate/android/gradlew
vendored
34
Example/testHotUpdate/android/gradlew
vendored
@@ -15,6 +15,8 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
#
|
||||||
@@ -55,7 +57,7 @@
|
|||||||
# Darwin, MinGW, and NonStop.
|
# Darwin, MinGW, and NonStop.
|
||||||
#
|
#
|
||||||
# (3) This script is generated from the Groovy template
|
# (3) This script is generated from the Groovy template
|
||||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
# within the Gradle project.
|
# within the Gradle project.
|
||||||
#
|
#
|
||||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
@@ -83,10 +85,9 @@ done
|
|||||||
# This is normally unused
|
# This is normally unused
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
APP_BASE_NAME=${0##*/}
|
APP_BASE_NAME=${0##*/}
|
||||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
|
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
' "$PWD" ) || exit
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD=maximum
|
MAX_FD=maximum
|
||||||
@@ -133,10 +134,13 @@ location of your Java installation."
|
|||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
JAVACMD=java
|
JAVACMD=java
|
||||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
if ! command -v java >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
location of your Java installation."
|
location of your Java installation."
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
# Increase the maximum file descriptors if we can.
|
||||||
@@ -144,7 +148,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
|||||||
case $MAX_FD in #(
|
case $MAX_FD in #(
|
||||||
max*)
|
max*)
|
||||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||||
# shellcheck disable=SC3045
|
# shellcheck disable=SC2039,SC3045
|
||||||
MAX_FD=$( ulimit -H -n ) ||
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
warn "Could not query maximum file descriptor limit"
|
warn "Could not query maximum file descriptor limit"
|
||||||
esac
|
esac
|
||||||
@@ -152,7 +156,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
|||||||
'' | soft) :;; #(
|
'' | soft) :;; #(
|
||||||
*)
|
*)
|
||||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||||
# shellcheck disable=SC3045
|
# shellcheck disable=SC2039,SC3045
|
||||||
ulimit -n "$MAX_FD" ||
|
ulimit -n "$MAX_FD" ||
|
||||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
esac
|
esac
|
||||||
@@ -197,11 +201,15 @@ if "$cygwin" || "$msys" ; then
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Collect all arguments for the java command;
|
|
||||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
# shell script including quotes and variable substitutions, so put them in
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
# double quotes to make sure that they get re-expanded; and
|
|
||||||
# * put everything else in single quotes, so that it's not re-expanded.
|
# Collect all arguments for the java command:
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||||
|
# and any embedded shellness will be escaped.
|
||||||
|
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||||
|
# treated as '${Hostname}' itself on the command line.
|
||||||
|
|
||||||
set -- \
|
set -- \
|
||||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
|
22
Example/testHotUpdate/android/gradlew.bat
vendored
22
Example/testHotUpdate/android/gradlew.bat
vendored
@@ -13,6 +13,8 @@
|
|||||||
@rem See the License for the specific language governing permissions and
|
@rem See the License for the specific language governing permissions and
|
||||||
@rem limitations under the License.
|
@rem limitations under the License.
|
||||||
@rem
|
@rem
|
||||||
|
@rem SPDX-License-Identifier: Apache-2.0
|
||||||
|
@rem
|
||||||
|
|
||||||
@if "%DEBUG%"=="" @echo off
|
@if "%DEBUG%"=="" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
|
|||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if %ERRORLEVEL% equ 0 goto execute
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
echo location of your Java installation.
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
@@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
|||||||
|
|
||||||
if exist "%JAVA_EXE%" goto execute
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
echo location of your Java installation.
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
|
@@ -1,3 +1,6 @@
|
|||||||
|
pluginManagement { includeBuild("../node_modules/@react-native/gradle-plugin") }
|
||||||
|
plugins { id("com.facebook.react.settings") }
|
||||||
|
extensions.configure(com.facebook.react.ReactSettingsExtension){ ex -> ex.autolinkLibrariesFromCommand() }
|
||||||
rootProject.name = 'AwesomeProject'
|
rootProject.name = 'AwesomeProject'
|
||||||
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
|
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
|
||||||
include ':app'
|
include ':app'
|
||||||
|
@@ -1,7 +1,8 @@
|
|||||||
/* eslint-disable react-native/no-inline-styles */
|
/* eslint-disable react-native/no-inline-styles */
|
||||||
/* eslint-disable react/react-in-jsx-scope */
|
/* eslint-disable react/react-in-jsx-scope */
|
||||||
import {useCallback, useMemo, useState} from 'react';
|
import {useState} from 'react';
|
||||||
import {
|
import {
|
||||||
|
Alert,
|
||||||
ActivityIndicator,
|
ActivityIndicator,
|
||||||
Modal,
|
Modal,
|
||||||
TextInput,
|
TextInput,
|
||||||
@@ -13,132 +14,127 @@ import {
|
|||||||
TouchableOpacity,
|
TouchableOpacity,
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
|
|
||||||
import {PushyModule} from 'react-native-update';
|
import {PushyModule} from 'react-native-update/src/core';
|
||||||
const Hash = '9D5CE6EBA420717BE7E7D308B11F8207681B066C951D68F3994D19828F342474';
|
const Hash = '9D5CE6EBA420717BE7E7D308B11F8207681B066C951D68F3994D19828F342474';
|
||||||
const UUID = '00000000-0000-0000-0000-000000000000';
|
const UUID = '00000000-0000-0000-0000-000000000000';
|
||||||
const DownloadUrl =
|
const DownloadUrl =
|
||||||
'http://cos.pgyer.com/697913e94d7441f20c686e2b0996a1aa.apk?sign=7a8f11b1df82cba45c8ac30b1acec88c&t=1680404102&response-content-disposition=attachment%3Bfilename%3DtestHotupdate_1.0.apk';
|
'http://cos.pgyer.com/697913e94d7441f20c686e2b0996a1aa.apk?sign=7a8f11b1df82cba45c8ac30b1acec88c&t=1680404102&response-content-disposition=attachment%3Bfilename%3DtestHotupdate_1.0.apk';
|
||||||
|
|
||||||
const CustomDialog = ({title, visible, onConfirm}) => {
|
export default function TestConsole({visible, onClose}) {
|
||||||
if (!visible) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<View style={styles.overlay}>
|
|
||||||
<View style={styles.dialog}>
|
|
||||||
<Text style={styles.title}>{title}</Text>
|
|
||||||
<TouchableOpacity
|
|
||||||
testID="done"
|
|
||||||
style={styles.button}
|
|
||||||
onLongPress={onConfirm}>
|
|
||||||
<Text style={styles.buttonText}>确认</Text>
|
|
||||||
</TouchableOpacity>
|
|
||||||
</View>
|
|
||||||
</View>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
export default function TestConsole({visible}) {
|
|
||||||
const [text, setText] = useState('');
|
const [text, setText] = useState('');
|
||||||
const [running, setRunning] = useState(false);
|
const [running, setRunning] = useState(false);
|
||||||
const [options, setOptions] = useState();
|
const convertCommands = (cmd, params) => {
|
||||||
const [alertVisible, setAlertVisible] = useState(false);
|
if (typeof params === 'string') {
|
||||||
const [alertMsg, setAlertMsg] = useState('');
|
return `${cmd}\n${params}`;
|
||||||
const NativeTestMethod = useMemo(() => {
|
}
|
||||||
return [
|
let paramText = '';
|
||||||
|
for (const [k, v] of Object.entries(params)) {
|
||||||
|
paramText += `\n${k}\n${v}`;
|
||||||
|
}
|
||||||
|
return `${cmd}${paramText}`;
|
||||||
|
};
|
||||||
|
const shortCuts = [
|
||||||
{
|
{
|
||||||
name: 'setLocalHashInfo',
|
name: 'setLocalHashInfo',
|
||||||
invoke: () => {
|
invoke: () => {
|
||||||
setText(
|
setText(
|
||||||
`setLocalHashInfo\n${Hash}\n{\"version\":\"1.0.0\",\"size\":\"19M\"}`,
|
convertCommands('setLocalHashInfo', {
|
||||||
|
version: '1.0.0',
|
||||||
|
size: '19M',
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'getLocalHashInfo',
|
name: 'getLocalHashInfo',
|
||||||
invoke: () => {
|
invoke: () => {
|
||||||
setText(`getLocalHashInfo\n${Hash}`);
|
setText(convertCommands('getLocalHashInfo', Hash));
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'setUuid',
|
name: 'setUuid',
|
||||||
invoke: () => {
|
invoke: () => {
|
||||||
setText(`setUuid\n${UUID}`);
|
setText(convertCommands('setUuid', UUID));
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'reloadUpdate',
|
name: 'reloadUpdate',
|
||||||
invoke: () => {
|
invoke: () => {
|
||||||
setText('reloadUpdate');
|
setText(convertCommands('reloadUpdate', {hash: Hash}));
|
||||||
setOptions({hash: Hash});
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'setNeedUpdate',
|
name: 'setNeedUpdate',
|
||||||
invoke: () => {
|
invoke: () => {
|
||||||
setText('setNeedUpdate');
|
setText(convertCommands('setNeedUpdate', {hash: Hash}));
|
||||||
setOptions({hash: Hash});
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'markSuccess',
|
name: 'markSuccess',
|
||||||
invoke: () => {
|
invoke: () => {
|
||||||
setText('markSuccess');
|
setText(convertCommands('markSuccess'));
|
||||||
setOptions(undefined);
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'downloadPatchFromPpk',
|
name: 'downloadPatchFromPpk',
|
||||||
invoke: () => {
|
invoke: () => {
|
||||||
setText('downloadPatchFromPpk');
|
setText(
|
||||||
setOptions({updateUrl: DownloadUrl, hash: Hash, originHash: Hash});
|
convertCommands('downloadPatchFromPpk', {
|
||||||
|
updateUrl: DownloadUrl,
|
||||||
|
hash: Hash,
|
||||||
|
originHash: Hash,
|
||||||
|
}),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'downloadPatchFromPackage',
|
name: 'downloadPatchFromPackage',
|
||||||
invoke: () => {
|
invoke: () => {
|
||||||
setText('downloadPatchFromPackage');
|
setText(
|
||||||
setOptions({updateUrl: DownloadUrl, hash: Hash});
|
convertCommands('downloadPatchFromPackage', {
|
||||||
|
updateUrl: DownloadUrl,
|
||||||
|
hash: Hash,
|
||||||
|
}),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'downloadFullUpdate',
|
name: 'downloadFullUpdate',
|
||||||
invoke: () => {
|
invoke: () => {
|
||||||
setText('downloadFullUpdate');
|
setText(
|
||||||
setOptions({updateUrl: DownloadUrl, hash: Hash});
|
convertCommands('downloadFullUpdate', {
|
||||||
|
updateUrl: DownloadUrl,
|
||||||
|
hash: Hash,
|
||||||
|
}),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'downloadAndInstallApk',
|
name: 'downloadAndInstallApk',
|
||||||
invoke: () => {
|
invoke: () => {
|
||||||
setText('downloadAndInstallApk');
|
setText(
|
||||||
setOptions({url: DownloadUrl, target: Hash, hash: Hash});
|
convertCommands('downloadAndInstallApk', {
|
||||||
|
url: DownloadUrl,
|
||||||
|
target: Hash,
|
||||||
|
hash: Hash,
|
||||||
|
}),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}, []);
|
|
||||||
|
|
||||||
const renderTestView = useCallback(() => {
|
|
||||||
const views = [];
|
|
||||||
for (let i = 0; i < NativeTestMethod.length; i++) {
|
|
||||||
views.push(
|
|
||||||
<TouchableOpacity
|
|
||||||
key={i}
|
|
||||||
testID={NativeTestMethod[i].name}
|
|
||||||
onLongPress={() => {
|
|
||||||
NativeTestMethod[i].invoke();
|
|
||||||
}}>
|
|
||||||
<Text>{NativeTestMethod[i].name}</Text>
|
|
||||||
</TouchableOpacity>,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return <View>{views}</View>;
|
|
||||||
}, [NativeTestMethod]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal visible={visible}>
|
<Modal visible={visible}>
|
||||||
<SafeAreaView style={{flex: 1, padding: 10}}>
|
<SafeAreaView style={{flex: 1, padding: 10}}>
|
||||||
<Text>调试Pushy方法(方法名,参数,值换行)</Text>
|
<View
|
||||||
|
style={{
|
||||||
|
flexDirection: 'row',
|
||||||
|
justifyContent: 'space-between',
|
||||||
|
alignItems: 'center',
|
||||||
|
}}>
|
||||||
|
<Text>调试Pushy方法(方法名,参数,值换行)</Text>
|
||||||
|
<Button title="Close" onPress={onClose} />
|
||||||
|
</View>
|
||||||
<TextInput
|
<TextInput
|
||||||
autoCorrect={false}
|
autoCorrect={false}
|
||||||
autoCapitalize="none"
|
autoCapitalize="none"
|
||||||
@@ -167,46 +163,49 @@ export default function TestConsole({visible}) {
|
|||||||
marginBottom: 5,
|
marginBottom: 5,
|
||||||
}}
|
}}
|
||||||
testID="submit"
|
testID="submit"
|
||||||
onLongPress={async () => {
|
onPress={async () => {
|
||||||
setRunning(true);
|
setRunning(true);
|
||||||
try {
|
try {
|
||||||
const inputs = text.split('\n');
|
const inputs = text.split('\n');
|
||||||
const methodName = inputs[0];
|
const methodName = inputs[0];
|
||||||
let params = [];
|
let params;
|
||||||
if (inputs.length === 1) {
|
if (inputs.length === 1) {
|
||||||
if (options) {
|
await PushyModule[methodName]();
|
||||||
await PushyModule[methodName](options);
|
|
||||||
} else {
|
|
||||||
await PushyModule[methodName]();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (inputs.length === 2) {
|
if (inputs.length === 2) {
|
||||||
params = [inputs[1]];
|
params = inputs[1];
|
||||||
} else {
|
} else {
|
||||||
params = [inputs[1], inputs[2]];
|
params = {};
|
||||||
|
for (let i = 1; i < inputs.length; i += 2) {
|
||||||
|
params[inputs[i]] = inputs[i + 1];
|
||||||
|
}
|
||||||
console.log({inputs, params});
|
console.log({inputs, params});
|
||||||
}
|
}
|
||||||
await PushyModule[methodName](...params);
|
await PushyModule[methodName](params);
|
||||||
}
|
}
|
||||||
setAlertVisible(true);
|
Alert.alert('done');
|
||||||
setAlertMsg('done');
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setAlertVisible(true);
|
Alert.alert(e.message);
|
||||||
setAlertMsg(e.message);
|
|
||||||
}
|
}
|
||||||
setRunning(false);
|
setRunning(false);
|
||||||
}}>
|
}}>
|
||||||
<Text style={{color: 'white'}}>执行</Text>
|
<Text style={{color: 'white'}}>执行</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
<Button title="重置" onPress={() => setText('')} />
|
<Button title="重置" onPress={() => setText('')} />
|
||||||
{renderTestView()}
|
{
|
||||||
<CustomDialog
|
<View>
|
||||||
title={alertMsg}
|
{shortCuts.map(({name, invoke}, i) => (
|
||||||
visible={alertVisible}
|
<TouchableOpacity
|
||||||
onConfirm={() => {
|
key={i}
|
||||||
setAlertVisible(false);
|
testID={name}
|
||||||
}}
|
onPress={() => {
|
||||||
/>
|
invoke();
|
||||||
|
}}>
|
||||||
|
<Text>{name}</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
))}
|
||||||
|
</View>
|
||||||
|
}
|
||||||
</SafeAreaView>
|
</SafeAreaView>
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
|
@@ -124,7 +124,10 @@ function App() {
|
|||||||
react-native-update版本:{client?.version}
|
react-native-update版本:{client?.version}
|
||||||
</Text>
|
</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
<TestConsole visible={showTestConsole} />
|
<TestConsole
|
||||||
|
visible={showTestConsole}
|
||||||
|
onClose={() => setShowTestConsole(false)}
|
||||||
|
/>
|
||||||
{snackbarVisible && (
|
{snackbarVisible && (
|
||||||
<Snackbar
|
<Snackbar
|
||||||
visible={snackbarVisible}
|
visible={snackbarVisible}
|
||||||
|
@@ -1,6 +1,10 @@
|
|||||||
#import "RCTPushy.h"
|
#import "RCTPushy.h"
|
||||||
#import "RCTPushyDownloader.h"
|
#import "RCTPushyDownloader.h"
|
||||||
#import "RCTPushyManager.h"
|
#import "RCTPushyManager.h"
|
||||||
|
|
||||||
|
#if __has_include("RCTReloadCommand.h")
|
||||||
|
#import "RCTReloadCommand.h"
|
||||||
|
#endif
|
||||||
// Thanks to this guard, we won't import this header when we build for the old architecture.
|
// Thanks to this guard, we won't import this header when we build for the old architecture.
|
||||||
#ifdef RCT_NEW_ARCH_ENABLED
|
#ifdef RCT_NEW_ARCH_ENABLED
|
||||||
#import "RCTPushySpec.h"
|
#import "RCTPushySpec.h"
|
||||||
@@ -311,14 +315,17 @@ RCT_EXPORT_METHOD(reloadUpdate:(NSDictionary *)options
|
|||||||
if (hash.length) {
|
if (hash.length) {
|
||||||
[self setNeedUpdate:options resolver:resolve rejecter:reject];
|
[self setNeedUpdate:options resolver:resolve rejecter:reject];
|
||||||
|
|
||||||
// reload 0.62+
|
#if __has_include("RCTReloadCommand.h")
|
||||||
// RCTReloadCommandSetBundleURL([[self class] bundleURL]);
|
// reload 0.62+
|
||||||
// RCTTriggerReloadCommandListeners(@"pushy reload");
|
RCTReloadCommandSetBundleURL([[self class] bundleURL]);
|
||||||
|
RCTTriggerReloadCommandListeners(@"pushy reload");
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
#else
|
||||||
[self.bridge setValue:[[self class] bundleURL] forKey:@"bundleURL"];
|
// reload in earlier version
|
||||||
[self.bridge reload];
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
});
|
[self.bridge setValue:[[self class] bundleURL] forKey:@"bundleURL"];
|
||||||
|
[self.bridge reload];
|
||||||
|
});
|
||||||
|
#endif
|
||||||
resolve(@true);
|
resolve(@true);
|
||||||
}else{
|
}else{
|
||||||
reject(@"执行报错", nil, nil);
|
reject(@"执行报错", nil, nil);
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "react-native-update",
|
"name": "react-native-update",
|
||||||
"version": "10.17.1",
|
"version": "10.18.0",
|
||||||
"description": "react-native hot update",
|
"description": "react-native hot update",
|
||||||
"main": "src/index",
|
"main": "src/index",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
Reference in New Issue
Block a user