본문 바로가기
React-Native

[RN/Android] CodePush 세팅(2)

by 배잼 2022. 10. 28.

App Update를 해주자.

1. Staging/Production 환경설정

이전 포스트에서 codePush 세팅을 staging만 해주었는데, release 환경까지 생각해서 Production을 추가해주자.

다음을 통해 key값을 확인하고

appcenter codepush deployment list -a 사용자이름/앱이름  --displayKeys

아래와 같이 설정해주자

android {
    ...
    buildTypes {
        debug {
            ...
            // Note: CodePush updates should not be tested in Debug mode as they are overriden by the RN packager. However, because CodePush checks for updates in all modes, we must supply a key.
            resValue "string", "CodePushDeploymentKey", '""'
            ...
        }

        releaseStaging {
            ...
            resValue "string", "CodePushDeploymentKey", '"<INSERT_STAGING_KEY>"'

            // Note: It is a good idea to provide matchingFallbacks for the new buildType you create to prevent build issues
            // Add the following line if not already there
            matchingFallbacks = ['release']
            ...
        }

        release {
            ...
            resValue "string", "CodePushDeploymentKey", '"<INSERT_PRODUCTION_KEY>"'
            ...
        }
    }
    ...
}

gradle를 수정하고 나서 android studio를 켜줘서 sync를 해준다.

 

위와 같이 설정을 하고 다시 앱을 빌드하려고 하는데 여태까지의 뷰 작업사항이 전혀 반영되지 않았다. 탭도 두개 더 추가했는데, 최초 빌드 이후의 뷰가 전혀 바뀌지 않은 상태여서 몹시 당황스러웠다. 캐시 문제인가 싶어 ./gradlew clean 을 해도 해결이 되지 않았다.

이유는 이에 release 환경으로 배포할때 bundle를 만들었는데, 이번에 빌드하면서 bundle를 다시 만들지 않은 문제였다.

react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/

를 쳐줘서 Bundle를 꼭 다시 만들어주자.

(이걸 몰라서 마켓에 세번 배포했고 세번 다 업데이트를 받아보니 수정사항이 전혀 반영되지 않았었다.)

 

이제 ./gradlew assembleRelease 를 작성해서 .apk를 빌드하고 한번 다운받아보자. (에뮬레이터 혹은 공기계)

2. CodePush 적용

현재 내가 만든 앱을 보면 입력창에 placeholder가 빠진 상태로 있다.

이걸 codepush로 해결해주자!

 

먼저 코드를 고쳐준다.

<TextInput
	description={'알람 이름'}
	onChangeText={}
	value={}
	placeholder={'알람 이름을 입력해주세요'}
/>

저기 placeholder의 값을 추가해줬다.

 

그리고 터미널에 커맨드로

appcenter codepush release-react -a {user name}/{앱 이름} -d {type(Production or Staging)}

를 쳐준다.

 

Staging으로 올리면 개발 환경에서 테스트를 거친 뒤, Production으로 단계를 올릴 수 있다. Production으로 올리면 release 환경에 곧바로 반영된다.

특별한 test는 필요없을것 같아 production 환경으로 바로 올리고 AppCenter에서 확인해보니

이렇게 잘 올라온걸 확인할 수 있다~

apk를 다운받은 기기에서 앱을 재실행해보니

이렇게 정상적으로 placeholder가 생긴걸 확인할 수 있다. 앱 업데이트도, 재다운로드도 하지 않았다.

3. CodePush를 사용할 수 없는 경우

Google play

Third paragraph of Device and Network Abuse topic describe that updating source code by any method other than Google Play's update mechanism is restricted. But this restriction does not apply to updating javascript bundles.

This restriction does not apply to code that runs in a virtual machine and has limited access to Android APIs (such as JavaScript in a webview or browser).

That fully allow CodePush as it updates just JS bundles and can't update native code part.

App Store

Paragraph 3.3.2, since back in 2015's Apple Developer Program License Agreement fully allowed performing over-the-air updates of JavaScript and assets - and in its latest version (20170605) downloadable here this ruling is even broader:

Interpreted code may be downloaded to an Application but only so long as such code: (a) does not change the primary purpose of the Application by providing features or functionality that are inconsistent with the intended and advertised purpose of the Application as submitted to the App Store, (b) does not create a store or storefront for other code or applications, and (c) does not bypass signing, sandbox, or other security features of the OS.

CodePush allows you to follow these rules in full compliance so long as the update you push does not significantly deviate your product from its original App Store approved intent.

To further remain in compliance with Apple's guidelines we suggest that App Store-distributed apps don't enable the updateDialog option when calling sync, since in the App Store Review Guidelines it is written that:

Apps must not force users to rate the app, review the app, download other apps, or other similar actions in order to access functionality, content, or use of the app.

This is not necessarily the case for updateDialog, since it won't force the user to download the new version, but at least you should be aware of that ruling if you decide to show it.

 

https://github.com/microsoft/react-native-code-push

codepush readme에 적혀 있다 🙂

Android의 경우 JS딴에서의 변경은 허용하지만, 네이티브 코드를 수정할때는 앱 심사가 필요하다.

Apple의 경우 최초 앱의 목적과 GuildLines에 벗어나지 않으면 문제없는것으로 보인다.

 

참 신기한 리액트 네이티브..

'React-Native' 카테고리의 다른 글

[RN/Android] CodePush 사용기(1)  (0) 2022.10.14

댓글