Skip to content

Commit

Permalink
Merge pull request #1 from mym0404/navi
Browse files Browse the repository at this point in the history
Kakao Navi SDK
  • Loading branch information
mym0404 authored Apr 24, 2024
2 parents 04bb32e + f696709 commit 93b7480
Show file tree
Hide file tree
Showing 40 changed files with 1,153 additions and 56 deletions.
6 changes: 5 additions & 1 deletion .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ runs:
using: composite
steps:
- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc

Expand All @@ -25,3 +25,7 @@ runs:
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn install --immutable
shell: bash

# - name: Generate Example Project
# shell: bash
# run: yarn gen:android && yarn gen:ios
65 changes: 38 additions & 27 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,61 @@ name: CI
on:
push:
branches:
- main-noop
- main
pull_request:
branches:
- main-noop
- main

jobs:
lint:
runs-on: ubuntu-latest
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup
uses: ./.github/actions/setup

- name: Lint files
run: yarn lint

- name: Typecheck files
run: yarn typecheck
- name: Install ClangFormat
shell: bash
run: brew install clang-format

test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup
uses: ./.github/actions/setup
- name: Install Ktlint
shell: bash
run: brew install ktlint

- name: Run unit tests
run: yarn test --maxWorkers=2 --coverage
- name: Lint files
run: yarn lint

build-library:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
# - name: Codegen
# run: yarn codegen

- name: Setup
uses: ./.github/actions/setup
- name: Build
run: yarn build

- name: Build package
run: yarn prepare
# test:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v3
#
# - name: Setup
# uses: ./.github/actions/setup
#
# - name: Run unit tests
# run: yarn test --maxWorkers=2 --coverage
#
# build-library:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v3
#
# - name: Setup
# uses: ./.github/actions/setup
#
# - name: Build package
# run: yarn prepare

# build-android:
# runs-on: ubuntu-latest
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ please select the package link from below.

[//]: # (The main package that you interface with is `App` (`@react-native-kakao/app`))

| Name | Android | iOS | Downloads | Status |
|------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------:|--------|
| Name | Android | iOS | Downloads | Status |
|-------------------------------------------------|---------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------:|--------|
| [Core](https://rnkakao.dev/docs/intro) | ![common-android](https://img.shields.io/badge/common-2.20.1-green?style=flat-square) | ![common-ios](https://img.shields.io/badge/common-2.22.0-lightblue?style=flat-square) | [![badge](https://img.shields.io/npm/dm/@react-native-kakao/core.svg?style=for-the-badge&logo=npm)](https://www.npmjs.com/package/@react-native-kakao/core) ||
| [Share](https://rnkakao.dev/docs/share/intro) | ![share-android](https://img.shields.io/badge/share-2.20.1-green?style=flat-square) | ![share-ios](https://img.shields.io/badge/share-2.22.0-lightblue?style=flat-square) | [![badge](https://img.shields.io/npm/dm/@react-native-kakao/share.svg?style=for-the-badge&logo=npm)](https://www.npmjs.com/package/@react-native-kakao/share) ||
| [User](https://rnkakao.dev/docs/user/intro) | ![user-android](https://img.shields.io/badge/user-2.20.1-green?style=flat-square) | ![user-ios](https://img.shields.io/badge/user-2.22.0-lightblue?style=flat-square) | [![badge](https://img.shields.io/npm/dm/@react-native-kakao/user.svg?style=for-the-badge&logo=npm)](https://www.npmjs.com/package/@react-native-kakao/user) ||
| [Friend](https://rnkakao.dev/docs/friend/intro) | | | [![badge](https://img.shields.io/npm/dm/@react-native-kakao/friend.svg?style=for-the-badge&logo=npm)](https://www.npmjs.com/package/@react-native-kakao/friend) | 📦 |
| [Navi](https://rnkakao.dev/docs/navi/intro) | ![navi-android](https://img.shields.io/badge/navi-2.20.1-green?style=flat-square) | ![navi-ios](https://img.shields.io/badge/navi-2.22.0-lightblue?style=flat-square) | [![badge](https://img.shields.io/npm/dm/@react-native-kakao/navi.svg?style=for-the-badge&logo=npm)](https://www.npmjs.com/package/@react-native-kakao/navi) | 🔥 |
| [Navi](https://rnkakao.dev/docs/navi/intro) | ![navi-android](https://img.shields.io/badge/navi-2.20.1-green?style=flat-square) | ![navi-ios](https://img.shields.io/badge/navi-2.22.0-lightblue?style=flat-square) | [![badge](https://img.shields.io/npm/dm/@react-native-kakao/navi.svg?style=for-the-badge&logo=npm)](https://www.npmjs.com/package/@react-native-kakao/navi) | |
| [Cert](https://rnkakao.dev/docs/cert/intro) | | | [![badge](https://img.shields.io/npm/dm/@react-native-kakao/cert.svg?style=for-the-badge&logo=npm)](https://www.npmjs.com/package/@react-native-kakao/cert) | 📦 |
| [Talk](https://rnkakao.dev/docs/talk/intro) | | | [![badge](https://img.shields.io/npm/dm/@react-native-kakao/talk.svg?style=for-the-badge&logo=npm)](https://www.npmjs.com/package/@react-native-kakao/talk) | 📦 |
| [Map](https://rnkakao.dev/docs/map/intro) | | | [![badge](https://img.shields.io/npm/dm/@react-native-kakao/map.svg?style=for-the-badge&logo=npm)](https://www.npmjs.com/package/@react-native-kakao/map) | 📦 |
Expand Down
8 changes: 8 additions & 0 deletions docs/docs/navi/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"label": "Package - Navi",
"position": 10,
"link": {
"type": "generated-index",
"description": "Navi 패키지 사용법"
}
}
22 changes: 22 additions & 0 deletions docs/docs/navi/intro-expo.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
sidebar_position: 3
---

# Expo 설정

## iOS - 카카오내비 앱 실행을 위한 스키마 등록

`app.json`에 다음과 같이 추가합니다.

```json title='app.json'
[
"@react-native-kakao/core",
{
"nativeAppKey": "5a9383961eadba5496cb4ff895e91a89",
"ios": {
// highlight-next-line
"naviApplicationQuerySchemes": true
}
}
],
```
19 changes: 19 additions & 0 deletions docs/docs/navi/intro-ios.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
sidebar_position: 2
---

# iOS 설정

:::info
이 문서는 Expo를 사용한다면 건너뛰어야합니다.
:::

## 카카오내비 앱 실행을 위한 스키마 등록

`Info.plist``LSApplicationQueriesSchemes``kakaonavi-sdk`를 추가합니다.

![figure](https://raw.githubusercontent.com/mym0404/image-archive/master/202404242110641.webp)

:::note
더 자세한 내용은 [공식 문서](https://developers.kakao.com/docs/latest/ko/kakaonavi/ios)를 참고해주세요.
:::
47 changes: 47 additions & 0 deletions docs/docs/navi/intro.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
sidebar_position: 1
---






import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';


# 시작하기

## 시작하기 전에

[`Core`패키지에 대한 의존성을 설치](/docs/install-core)하고 관련된 [플랫폼별 설정](/docs/install-android)이 완료되어야 합니다.

## 시작하기

`navi` 패키지는 카카오 내비게이션 기능을 사용할 수 있는 패키지입니다.

카카오내비는 서비스에서 내비게이션 기능을 사용할 수 있도록 SDK 및 API를 제공합니다. 간단히 카카오내비 애플리케이션(이하 앱)을 실행해 내비게이션 기능을 사용하거나,
서비스 앱 안에서 내비게이션 및 경로 정보 활용 기능을 구현할 수 있습니다.

[공식 문서](https://developers.kakao.com/docs/latest/ko/kakaonavi/common)를 참고해주시기 바랍니다.

## 설치하기

<Tabs>
<TabItem value="npm" label="NPM" default>
```shell
npm install --save @react-native-kakao/navi
```
</TabItem>
<TabItem value="yarn" label="Yarn">
```shell
yarn add @react-native-kakao/navi
```
</TabItem>
<TabItem value="expo" label="Expo">
```shell
npx expo install @react-native-kakao/navi
```
</TabItem>
</Tabs>
31 changes: 31 additions & 0 deletions docs/docs/navi/navigate-destination.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
sidebar_position: 5
---

# 목적지까지 경로 안내 시작하기
## 목적지까지 경로 안내 시작하기

[공식 문서](https://developers.kakao.com/docs/latest/ko/kakaonavi/android)

## Usage

`navigateTo()` 함수를 이용해 카카오내비 앱을 실행시켜 경로안내를 시작할 수 있습니다.

이 함수는 다음과 같이 정의됩니다.

```tsx
export function navigateTo(params: {
destination: KakaoNaviLocation;
option?: KakaoNaviOption;
viaList?: KakaoNaviLocation[];
openWebInstallUrlIfNaviAppNotAvailable?: boolean;
})
```

- `destination`: 목적지 정보입니다. 필수값입니다.
- `option`: 옵션입니다.
- `viaList`: 경유지 리스트입니다.
- `openWebInstallUrlIfNaviAppNotAvailable`: 카카오내비 앱을 실행할 수 없다면 자동으로 설치 화면으로 보낼지 여부입니다.
기본값은 `true`입니다.

옵션에 대한 자세한 설명은 [공식 문서](https://developers.kakao.com/docs/latest/ko/kakaonavi/android#set-parameter)를 참고해주세요.
31 changes: 31 additions & 0 deletions docs/docs/navi/share-destination.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
sidebar_position: 6
---

# 목적지까지 경로 공유하기
## 목적지까지 경로 공유하기

[공식 문서](https://developers.kakao.com/docs/latest/ko/kakaonavi/android)

## Usage

`shareTo()` 함수를 이용해 카카오내비 앱을 실행시켜 경로를 공유할 수 있습니다.

이 함수는 다음과 같이 정의됩니다.

```tsx
export function shareTo(params: {
destination: KakaoNaviLocation;
option?: KakaoNaviOption;
viaList?: KakaoNaviLocation[];
openWebInstallUrlIfNaviAppNotAvailable?: boolean;
})
```

- `destination`: 목적지 정보입니다. 필수값입니다.
- `option`: 옵션입니다.
- `viaList`: 경유지 리스트입니다.
- `openWebInstallUrlIfNaviAppNotAvailable`: 카카오내비 앱을 실행할 수 없다면 자동으로 설치 화면으로 보낼지 여부입니다.
기본값은 `true`입니다.

옵션에 대한 자세한 설명은 [공식 문서](https://developers.kakao.com/docs/latest/ko/kakaonavi/android#set-parameter)를 참고해주세요.
3 changes: 2 additions & 1 deletion example/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@
"forwardKakaoLinkIntentFilterToMainActivity": true
},
"ios": {
"handleKakaoOpenUrl": true
"handleKakaoOpenUrl": true,
"naviApplicationQuerySchemes": true
}
}
],
Expand Down
3 changes: 3 additions & 0 deletions example/src/app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ export default function Page() {
<Link href={'/share'}>
<Txt textDecorationLine={'underline'}>{'@react-native-kakao/share'}</Txt>
</Link>
<Link href={'/navi'}>
<Txt textDecorationLine={'underline'}>{'@react-native-kakao/navi'}</Txt>
</Link>
</Box>
</StyledScrollView>
);
Expand Down
52 changes: 52 additions & 0 deletions example/src/app/navi.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { navigateTo, shareTo } from '@react-native-kakao/navi';

import { Btn } from '../component/Btn';
import { StyledScrollView } from '../component/StyledScrollView';

export default function Page() {
return (
<StyledScrollView
flex={1}
contentContainerSx={{ pt: 12, pb: 48, alignItems: 'center', px: 4, gap: 4 }}
>
<Btn
title={'Navigate to Gangnam Station'}
onPress={() => {
navigateTo({
option: {
coordType: 'WGS84',
},
destination: {
x: 129.340842223,
y: 35.5449848249,
name: 'Gangnam',
},
}).then(console.log);
}}
/>
<Btn
title={'Share to Gangnam Station'}
onPress={() => {
shareTo({
option: {
coordType: 'WGS84',
},
destination: {
x: 129.340842223,
y: 35.5449848249,
name: 'Gangnam',
},
viaList: [
{
x: 126.340842223,
y: 34.5449848249,
name: 'Gangnam',
},
],
openWebInstallUrlIfNaviAppNotAvailable: false,
}).then(console.log);
}}
/>
</StyledScrollView>
);
}
1 change: 1 addition & 0 deletions example/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{ "path": "../packages/core" },
{ "path": "../packages/share" },
{ "path": "../packages/user" },
{ "path": "../packages/navi" },
],
"compilerOptions": {
// Avoid expo-cli auto-generating a tsconfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ fun ReadableMap.getDoubleElseNull(key: String): Double? {
return null
}

fun ReadableMap.getBooleanElseNull(key: String): Boolean? {
if (hasKey(key)) return getBoolean(key)
return null
}

fun onMain(fn: () -> Unit) {
if (Looper.myLooper() == Looper.getMainLooper()) {
fn()
Expand Down
1 change: 1 addition & 0 deletions packages/core/expo-config-plugin/src/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export type KakaoAndroidConfig = {
};
export type KakaoIosConfig = {
handleKakaoOpenUrl?: boolean;
naviApplicationQuerySchemes?: boolean;
};
Loading

0 comments on commit 93b7480

Please sign in to comment.