我想将基于React Native的模块集成到我现有的Android应用程序中。到目前为止,它的工作效果还不错,但我也想集成CodePush,以将更新部署到我的应用程序中。
重要的一点是,模块应该独立于特定的应用程序,因为我有多个应使用这些模块的不同应用程序。因此,模块本身是独立的React Native包,因此它们必须是单独的Code-Push应用程序(我想)。
当前,这样的React Native模块(实现为Fragment)的工作方式如下:
public class ReactFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
ReactRootView mReactRootView = new ReactRootView(getContext());
ReactInstanceManager mReactInstanceManager = ReactInstanceManager.builder()
.setApplication(getActivity().getApplication())
.setBundleAssetName("index.android.bundle")
.setJSMainModuleName("index.android")
.addPackage(new MainReactPackage())
.setUseDeveloperSupport(false)
.setInitialLifecycleState(LifecycleState.RESUMED)
.build();
mReactRootView.startReactApplication(mReactInstanceManager, "HelloWorld", null);
return mReactRootView;
}
}
Run Code Online (Sandbox Code Playgroud)
因此,按照官方CodePush指南,我不知道如何在同一个Android应用程序中使用多个CodePush项目。但是我认为我内部一定有某种东西onCreateView可以让我注入CodePush包或至少一个自定义ReactNativeHost。
我使用应用程序中心网站上的“添加新应用程序”选项添加了一个反应本机 Android 应用程序。现在我需要找到相同的部署密钥。我尝试了
代码推送部署列表 YourAppName --displayKeys
但它没有返回密钥。
尽管当我使用 CLI
code-push app add YourAppName android react-native 添加应用程序
,然后使用之前的命令检索密钥时,它工作正常并提供 staging 和 pro 密钥。
请有人解释一下这一点。
谢谢。
当我尝试实现 codepush 时,收到此错误:
Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings
70 actionable tasks: 7 executed, 63 up-to-date
/Users/lukeschoenberger/Documents/Programming/news-arg/test7/android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:59: error: cannot find symbol
new CodePush(getResources().getString(R.string.reactNativeCodePush_androidDeploymentKey), getApplicationContext(), BuildConfig.DEBUG),
^
symbol: variable reactNativeCodePush_androidDeploymentKey
location: class string
1 error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try: …Run Code Online (Sandbox Code Playgroud) yarn add react-native-codepushandroid/app/build.gradleapply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"
Run Code Online (Sandbox Code Playgroud)
MainApplication.javaapply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"
Run Code Online (Sandbox Code Playgroud)
strings.xml <string name="CodePushDeploymentKey" moduleConfig="true">MYKEY</string>
Run Code Online (Sandbox Code Playgroud)
构建应该成功
实际发生了什么?
$ react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 998 file(s) to forward-jetify. Using 4 workers...
info JS server already running.
info Installing the app...
> Configure project :app
WARNING: BuildType(debug): resValue 'react_native_dev_server_port' value is being replaced: 8081 -> 8081 …Run Code Online (Sandbox Code Playgroud) android react-native code-push react-native-code-push visual-studio-app-center
我已经了解用于Cordova和ReactNative的CodePush。
来源:https : //docs.microsoft.com/zh-cn/appcenter/distribution/codepush/
生产环境上是否有针对FlutterIO的CodePush解决方案?
还是已经支持ReactNative呢?
谢谢。
我的 iOS 应用程序未通过 CodePush 更新。
我已经在我的 iOS 应用程序中添加了 CodePush 依赖项。此外,我还能够使用 CodePush 成功发布 AppCenter 的更新。但我的 iOS 应用程序中的更改并未更新。
我的 React-Native 模块代码如下:
const codePushOptions = {
checkFrequency: codePush.CheckFrequency.ON_APP_RESUME,
installMode: codePush.InstallMode.ON_NEXT_RESUME,
};
export default Dashboard = codePush(codePushOptions)(Dashboard);
Run Code Online (Sandbox Code Playgroud)
并在 iOS Swift 中从 javascript 加载组件:
let jsCodeLocation = CodePush.bundleURL()!
let addRatingView = RCTRootView(bundleURL:jsCodeLocation as URL!, moduleName: "Dashboard", initialProperties: nil, launchOptions:nil)
Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的Visual Studio项目中进行代码推送.我完成了安装cordova插件代码推送并能够查看实例console.log(codePush).
现在我尝试运行codePush.checkForUpdate(),我注意到我需要在config.xml中填写部署密钥.
我阅读了几篇关于部署密钥的文章,但他们都使用Ionic CLI来创建项目,他们可以在CLI中检索部署密钥.但我在Visual Studio中没有看到任何选项,也没有在任何地方看到任何部署密钥信息.
请告知如何获取Visual Studio项目的部署密钥以启用codePush.
我已阅读有关该targetBinary标志的内容,并且我还从致力于CodePush的Microsoft团队成员那里读到了这个内容.
我有版本5.0.1和5.1.0.
5.0.1如果版本出现错误5.0.1,我该如何修复它并仅为此版本部署它?错误可能很关键,并不是每个人都会拥有最新版本的应用程序.
或者,该错误可能仅存在于特定版本上.
是我唯一的选择:
5.1.0为5.0.1然后进行更改,然后更改我的编号?这似乎是一种更新版本的冗长方式.是否有更优雅的方式来管理这个?