link library: microsoft
/
react-native-code-push
link error:Unable to resolve module code-push/script/acquisition-sdk
link youtobe: https://www.youtube.com/watch?v=Jo7AV5etOsA
follow the link of document to create an account code push for create center for app https://docs.microsoft.com/en-us/appcenter/distribution/codepush/rn-get-started
init project
npm install --save react-native-code-push
then link project and config follow the above link
react-native link react-native-code-push
link config
Install the App Center CLI:
npm install -g appcenter-cli
first, create an account, you can sign in with github or gmail, ...
appcenter login or code-push login
if it is not run you can run code-push to see detail command line
create application in code push server
appcenter apps create -d MyApp-Android -o Android -p React-Native
appcenter apps create -d MyApp-iOS -o iOS -p Cordova
create deployment default for all staging and production for and app
code-push deployment add JoJoAndroid --default
and can get token of this app with environment,if you forgot can use this command line to get this information
code-push deployment ls JoJoAndroid -k
second, wrap application with code push libraries
import React from 'react';
import type { Node } from 'react';
import {
SafeAreaView,
StyleSheet,
Text,
View,
} from 'react-native';
import codePush from "react-native-code-push";
const App: () => Node = () => {
return (
<SafeAreaView>
<View
style={styles.sectionContainer}>
<Text>Check your code push example</Text>
</View>
</SafeAreaView>
);
};
const styles = StyleSheet.create({
sectionContainer: {
flex: 1,
justify-content: 'center',
alignItem: 'center',
backgroundColor: 'red',
},
});
export default codePush(App)
check code,if it run you can build a apk file and then install in a device
change some style for app, and then push this change by this command line and then you can check for your app it is installed
code-push release-react CodePushExample(App name) android -d Production
check command line and + platform and status of application
fix error 1 - In the node_modules/react-native-code-push/CodePush.js file, change the import path from "code-push/script/acquisition-sdk" to "code-push/src/script acquisition-sdk".
2 - In the node_modules/code-push/src/script/acquisition-sdk.ts file and change file follow below
export module Http {
export const Verb = {
GET: "GET",
HEAD: "HEAD",
POST: "POST",
PUT: "PUT",
DELETE: "DELETE",
TRACE: "TRACE",
OPTIONS: "OPTIONS",
CONNECT: "CONNECT",
PATCH: "PATCH"
}
type VerbProps = keyof typeof Verb;
}
with ios, i get an error: Error: Command 'codepush release-react -a name/app_name -d Staging' failed with exception "The "CFBundleShortVersionString" key in the "ios/app_name/Info.plist" file needs to specify a valid semver string, containing both a major and minor version (e.g. 1.3.2, 1.1)."
and i fix it by change {{CFBundleShortVersionString}} by a number of current verion of app and it run follow link
and push it for ios
code-push release-react JoJoIos ios -d Staging