yarn global add appcenter-cli
yarn global add code-push-cli
아래 과정에서 로그인시 알아서 사이트가 켜지고 임시 키 값이 뜰텐데 해당 키를 복사해놓고 로그인할때 붙혀넣으면 된다.
code-push register
appcenter login
여기서 Production key값이 뜨는데 꼭 각각 메모장에 저장해놓기
code-push app add <안드로이드앱이름(원하는대로)> android react-native
code-push app add <애플앱이름(원하는대로)> ios react-native
code-push app list
apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"
import com.microsoft.codepush.react.CodePush; // 해당 코드는 상단에 추가
protected String getJSMainModuleName() {
return "index";
}
// 위 3줄은 원래 있을거고, 이거 밑에 아래 4줄 추가 하기
@Override
protected String getJSBundleFile() {
return CodePush.getJSBundleFile();
}
<string moduleConfig="true" name="CodePushDeploymentKey">여기에 아까 android꺼 Production key 적기</string>
include ':app', ':react-native-code-push'
project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app')
#import <CodePush/CodePush.h>
#else
// 주석처리하기
// return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
// 추가
return [CodePush bundleURL];
<key>CodePushDeploymentKey</key>
<string>애플 Production key 넣기</string>
yarn add react-native-code-push
import codePush from "react-native-code-push";
...
let codePushOptions = {
// 업데이트를 어떻게 설치할 것인지 (IMMEDIATE는 강제설치를 의미)
installMode: codePush.InstallMode.IMMEDIATE,
// 언제 업데이트를 체크하고 반영할지를 정한다.
// ON_APP_RESUME은 Background에서 Foreground로 오는 것을 의미
// ON_APP_START은 앱이 실행되는(켜지는) 순간을 의미
checkFrequency: codePush.CheckFrequency.ON_APP_RESUME,
mandatoryInstallMode: codePush.InstallMode.ON_NEXT_RESTART,
updateDialog: false,
};
...
export default codePush(codePushOptions)(App);
apk를 말거나 testflight를 올린다음에 해당 터미널에서 (appcenter와 code-push로그인은 되어있어야 한다)
appcenter codepush release-react -a 앱센터사이트유저네임/등록한안드앱이름 -d Production
appcenter codepush release-react -a 앱센터사이트유저네임/등록한애플앱이름 -d Production
apk를 실행하면 native단(java?)가 실행되고 그 안에서 분기로 release-apk라면 MS에 연결해서 js파일을 받아와 실행하는 것. 만약 run-android로 실행했다면 위에 분기를 안타고 순수 코드를 따라간다.