Skip to content

Commit

Permalink
docs: update docs [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
mym0404 committed May 6, 2024
1 parent 9ba8dda commit b5b29cc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 30 deletions.
17 changes: 0 additions & 17 deletions docs/docs/user/access-token.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,3 @@ export interface KakaoAccessTokenInfo {
```tsx
getAccessToken()
```

## Access Token 설정하기 (Web)

`setAccessTokenWeb()`함수를 이용해 웹 로그인 성공 시 Redirect URLsearch parameter`code`로 온 값을 Kakao SDK를 사용하기 위해 저장할 수 있습니다.

### 예시

로그인의 Redirect URl로 설정한 페이지에서 다음과 같이 `setAccessTokenWeb`을 호출합니다.

```tsx
const { code } = useGlobalSearchParams<{ code?: string }>();
useEffect(() => {
if (code) {
setAccessTokenWeb(code);
}
}, [code]);
```
33 changes: 20 additions & 13 deletions example/src/app/_layout.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
import { useEffect, useRef } from 'react';
import { Image } from 'react-native';
import FlashMessage from 'react-native-flash-message';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { capitalize } from '@mj-studio/js-util';
import { useMount } from '@mj-studio/react-util';
import Core from '@react-native-kakao/core';
import { issueAccessTokenWithCodeWeb, setAccessTokenWeb } from '@react-native-kakao/user';
import { StyledSystemProvider } from '@react-native-styled-system/core';
import { Link, Slot, useGlobalSearchParams } from 'expo-router';
import { Stack, useGlobalSearchParams } from 'expo-router';
import { StatusBar } from 'expo-status-bar';

import { Box } from '../component/Box';
import { RowCenter } from '../component/Row';
import { Txt } from '../component/Txt';
import AppTheme from '../design/AppTheme';
import { px } from '../util/px';

export default function RootLayout() {
const { top } = useSafeAreaInsets();
Expand Down Expand Up @@ -48,15 +46,24 @@ export default function RootLayout() {
<StyledSystemProvider theme={AppTheme}>
<StatusBar style={'light'} />
<Box flex={1} bg={'bg'}>
<Link href={'/'}>
<RowCenter p={4} pt={px(top + 12)} gap={2}>
<Image source={require('../../assets/icon.png')} style={{ width: 32, height: 32 }} />
<Txt t={'b1'} weight={'700'}>
{'React Native Kakao'}
</Txt>
</RowCenter>
</Link>
<Slot />
{/*<Link href={'/'}>*/}
{/* <RowCenter p={4} pt={px(top + 12)} gap={2}>*/}
{/* <Image source={require('../../assets/icon.png')} style={{ width: 32, height: 32 }} />*/}
{/* <Txt t={'b1'} weight={'700'}>*/}
{/* {'React Native Kakao'}*/}
{/* </Txt>*/}
{/* </RowCenter>*/}
{/*</Link>*/}
<Stack
screenOptions={{
headerShown: true,
contentStyle: { backgroundColor: 'black' },
headerTintColor: 'white',
headerStyle: { backgroundColor: 'black' },
headerTitle: (props) => <Txt weight={'bold'}>{capitalize(props.children)}</Txt>,
animation: 'ios',
}}
/>
</Box>
<FlashMessage position={'top'} duration={5000} type={'success'} />
</StyledSystemProvider>
Expand Down

0 comments on commit b5b29cc

Please sign in to comment.