방법: 앱의 앱 바 항목 가져오기 및 설정하기

게시일 4. 10월 2025 작성자 Jan Bunk


일부 웹사이트에서는 앱 바의 버튼을 동적으로 수정하는 기능이 유용할 수 있어요. 다음 JavaScript 함수를 사용하면 돼요.

JavaScript 함수 사용하기

다음의 executeWhenAppReady() 함수를 확인해 보세요. 앱 도우미 스크립트예요.. 이 함수는 앱이 준비되기 전이나 웹사이트가 일반 브라우저에서 로드되었을 때 웹사이트에서 앱과 상호작용을 시도하지 않도록 해줘요(ReferenceError, 함수가 정의되지 않음).

getAppBarItems

현재 표시되고 있는 모든 앱 바 항목을 나타내는 객체 목록을 가져오려면 이 함수를 사용하세요.


<script>
    try {
        // returns a list of objects representing the app bar items
        let appBarItems = (await getAppBarItems())["appBarItems"];
    }
    catch (e) {
        // Can occur if:
        // - the app couldn't connect to the native code. Should be very unlikely.
        console.log(e);
    }
</script>
    

setAppBarItems

표시할 앱 바 항목을 수정하려면 이 함수를 사용하세요.


<script>
    try {
        // example for an app bar item object
        let newAppBarItem = {
            action: {
                urlToRedirectTo: "https://webtoapp.design/contact",
                javascriptToExecute: null,
                elementToClickSelector: null,
                isFavoriteAction: false,
                isShareAction: false,
                isOpenExternallyAction: false,
                isSettingsAction: false,
                isRateAction: false,
                isPastNotificationsAction: false,
            },
            icon: {
                name: "list"
            }
        };

        // get the currently displayed app bar items
        let allAppBarItems = (await getAppBarItems())["appBarItems"];

        // add the new app bar item to the list of app bar items
        allAppBarItems.push(newAppBarItem);

        // display the list of app bar items, including the new app bar item
        await setAppBarItems(allAppBarItems);
    }
    catch (e) {
        // Can occur if:
        // - the app couldn't connect to the native code. Should be very unlikely.
        console.log(e);
    }
</script>
    

앱 메뉴 수정하기

앱 메뉴를 동적으로 변경하는 방법과 관련된 개발자 문서 목록은 다음과 같아요. 앱 레이아웃에 해당하는 문서를 보고 있는지 확인하세요.