Skip to content

Commit

Permalink
docs(channel): docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mym0404 committed Apr 30, 2024
1 parent 3c71fc8 commit c98a7eb
Show file tree
Hide file tree
Showing 17 changed files with 329 additions and 43 deletions.
8 changes: 8 additions & 0 deletions docs/docs/channel/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"label": "Package - Channel",
"position": 104,
"link": {
"type": "generated-index",
"description": "Channel 패키지 사용법"
}
}
41 changes: 41 additions & 0 deletions docs/docs/channel/add-channel.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
sidebar_position: 102
---

# 카카오톡 채널 추가하기

## 카카오톡 채널 추가하기

사용자가 카카오톡 채널을 친구 추가하러 이동합니다.

[공식 문서](https://developers.kakao.com/docs/latest/ko/kakaotalk-channel/ios#add-channel)

`addChannel`함수로 카카오톡 채널 추가를 할 수 있습니다.

```tsx
export function addChannel(channelPublicId: string): Promise<void>
```

- `channelPublicId`: 추가하려는 카카오톡 채널의 ID입니다.


## 카카오톡 채널 추가 URL 얻어오기

`getAddChannelUrl`함수로 카카오톡 채널 추가를 할 수 있는 URL을 얻어올 수 있습니다.

```tsx
export function getAddChannelUrl(channelPublicId: string): Promise<string>
```

- `channelPublicId`: 추가하려는 카카오톡 채널의 ID입니다.


## 카카오톡 채널 추가 URL 브라우저에서 열기

`openAddChannelUrl`함수로 카카오톡 채널 추가를 할 수 있는 URL을 브라우저에서 열 수 있습니다.

```tsx
export function openAddChannelUrl(channelPublicId: string): Promise<string>
```

- `channelPublicId`: 추가하려는 카카오톡 채널의 ID입니다.
41 changes: 41 additions & 0 deletions docs/docs/channel/chat-channel.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
sidebar_position: 103
---

# 카카오톡 채널 채팅하기

## 카카오톡 채널 채팅하기

사용자가 서비스의 카카오톡 채널과 1:1 채팅을 시작합니다.

[공식 문서](https://developers.kakao.com/docs/latest/ko/kakaotalk-channel/ios#add-chat)

`chatChannel`함수로 카카오톡 채널 채팅을 할 수 있습니다.

```tsx
export function chatChannel(channelPublicId: string): Promise<void>
```

- `channelPublicId`: 채팅하려는 카카오톡 채널의 ID입니다.


## 카카오톡 채널 채팅 URL 얻어오기

`getChatChannelUrl`함수로 카카오톡 채널 채팅을 할 수 있는 URL을 얻어올 수 있습니다.

```tsx
export function getChatChannelUrl(channelPublicId: string): Promise<string>
```

- `channelPublicId`: 채팅하려는 카카오톡 채널의 ID입니다.


## 카카오톡 채널 채팅 URL 브라우저에서 열기

`openChatChannelUrl`함수로 카카오톡 채널 채팅을 할 수 있는 URL을 브라우저에서 열 수 있습니다.

```tsx
export function openChatChannelUrl(channelPublicId: string): Promise<string>
```

- `channelPublicId`: 채팅하려는 카카오톡 채널의 ID입니다.
7 changes: 7 additions & 0 deletions docs/docs/channel/faq.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
sidebar_position: 999
---

# Troubleshooting & FAQ

모든 에러 코드는 [공식 문서의 문제 해결](https://developers.kakao.com/docs/latest/ko/kakaotalk-channel/trouble-shooting)에서 확인합니다.
19 changes: 19 additions & 0 deletions docs/docs/channel/follow-channel.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
sidebar_position: 101
---

# 카카오톡 채널 간편 추가하기(권장)

## 카카오톡 채널 간편 추가하기

[공식 문서](https://developers.kakao.com/docs/latest/ko/kakaotalk-channel/android#follow-channel)

`followChannel`함수로 카카오톡 간편 채널 추가를 할 수 있습니다.

```tsx
export function followChannel(channelPublicId: string): Promise<boolean>;
```

결과값은 간편 채널 추가에 성공했는지 여부입니다.

- `channelPublicId`: 추가하려는 카카오톡 채널의 ID입니다.
28 changes: 28 additions & 0 deletions docs/docs/channel/get-channels.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
sidebar_position: 104
---

# 카카오톡 채널 관계 확인하기

## 카카오톡 채널 관계 확인하기

[공식 문서](https://developers.kakao.com/docs/latest/ko/kakaotalk-channel/ios#check-relationship)

`channels`함수로 카카오톡 채널 관계를 확인할 수 있습니다.

```tsx
export function channels(params: { channelPublicIds?: string[] } = {}): Promise<KakaoChannel[]>
```

- `channelPublicIds`: 관계를 확인하려는 채널들의 ID들입니다. 전달하지 않을 시 모든 채널을 확인합니다.

사용되는 타입은 다음과 같습니다.

```tsx
export interface KakaoChannel {
uuid: string;
encodedId: string;
relation: 'added' | 'none' | 'blocked' | 'unknown';
updatedAt?: number; // unix
}
```
31 changes: 31 additions & 0 deletions docs/docs/channel/intro-android.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
sidebar_position: 2
---

# Android 설정

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

## 커스텀 URL 스킴 설정

[공식 문서](https://developers.kakao.com/docs/latest/ko/kakaotalk-channel/android#set-custom-url-scheme)

카카오톡 채널 간편 추가하기를 사용하려면 `AndroidManifest.xml`에 액티비티(`Activity`) 설정을 해야 합니다.
해당 기능의 내부 동작에 사용되는 액티비티 리다이렉션(Redirection)을 지원하기 위한 설정입니다. 아래 예제를 참고합니다.

```xml
<activity
android:name="com.kakao.sdk.talk.FollowChannelHandlerActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<!-- Redirect URI: "kakao${NATIVE_APP_KEY}://channel" -->
<data android:host="channel" android:scheme="kakao${NATIVE_APP_KEY}" />
</intent-filter>
</activity>
```
27 changes: 27 additions & 0 deletions docs/docs/channel/intro-expo.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
sidebar_position: 4
---

# Expo 설정

## Android - 채널 추가 이후 앱 실행을 위한 Activity 등록

[공식 문서](https://developers.kakao.com/docs/latest/ko/kakaotalk-channel/android#set-custom-url-scheme)

카카오톡 채널 간편 추가하기를 사용하려면 `AndroidManifest.xml`에 액티비티(`Activity`) 설정을 해야 합니다.
해당 기능의 내부 동작에 사용되는 액티비티 리다이렉션(Redirection)을 지원하기 위한 설정입니다. 아래 예제를 참고합니다.

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

```json title='app.json'
[
"@react-native-kakao/core",
{
"nativeAppKey": "{{native app key}}",
"android": {
// highlight-next-line
"followChannelHandlerActivity": true
}
}
],
```
25 changes: 25 additions & 0 deletions docs/docs/channel/intro-ios.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
sidebar_position: 3
---

# iOS 설정

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

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

`Info.plist``LSApplicationQueriesSchemes``kakaoplus`를 추가합니다.

:::tip
기본적으로 `kakaokompassauth`, `kakaolink`, `kakaoplus`가 추가되어 있으면 됩니다.
:::

[공식 문서](https://developers.kakao.com/docs/latest/ko/ios/getting-started#project-plist)

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

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

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


# 시작하기

## 시작하기 전에

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

## 시작하기

`channel` 패키지는 카카오톡 채널과 상호작용하는 기능을 사용할 수 있는 패키지입니다.

카카오톡 채널(구:플러스친구)은 카카오톡 사용자들에게 다양한 서비스 소식을 메시지와 게시물 형태로 전파할 수 있는 서비스입니다.

카카오톡 채널은 친구인 사용자들에게 마케팅(Marketing) 메시지를 보내는 기능을 제공합니다.
친구란 카카오톡 채널을 친구로 추가한 사용자를 말합니다.

카카오톡 채널 메시지는 비용 절감을 위해 사용자의 성별, 나이, 지역, 등급 등 정보를 토대로 친구 그룹을 만들어서 보다 높은 효과가 기대되는 사용자들에게만 발송하는 것도 가능합니다.

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

## 설치하기

<Tabs>
<TabItem value="npm" label="NPM" default>
```shell
npm install --save @react-native-kakao/channel
```
</TabItem>
<TabItem value="yarn" label="Yarn">
```shell
yarn add @react-native-kakao/channel
```
</TabItem>
<TabItem value="expo" label="Expo">
```shell
npx expo install @react-native-kakao/channel
```
</TabItem>
</Tabs>
2 changes: 1 addition & 1 deletion docs/docs/navi/_category_.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"label": "Package - Navi",
"position": 104,
"position": 105,
"link": {
"type": "generated-index",
"description": "Navi 패키지 사용법"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import android.content.ActivityNotFoundException
import com.facebook.react.bridge.Promise
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.ReactMethod
import com.facebook.react.bridge.ReadableArray
import com.kakao.sdk.common.util.KakaoCustomTabsClient
import com.kakao.sdk.talk.TalkApiClient
import net.mjstudio.rnkakao.core.util.RNCKakaoResponseNotFoundException
import net.mjstudio.rnkakao.core.util.argArr
import net.mjstudio.rnkakao.core.util.argMap
import net.mjstudio.rnkakao.core.util.filterIsInstance
import net.mjstudio.rnkakao.core.util.onMain
import net.mjstudio.rnkakao.core.util.pushMapList
import net.mjstudio.rnkakao.core.util.putL
Expand Down Expand Up @@ -149,29 +151,31 @@ class RNCKakaoChannelModule internal constructor(context: ReactApplicationContex
}

@ReactMethod
override fun channels(promise: Promise) =
onMain {
TalkApiClient.instance.channels { relations, error ->
if (error != null) {
promise.rejectWith(error)
} else if (relations?.channels == null) {
promise.rejectWith(RNCKakaoResponseNotFoundException("channels"))
} else {
promise.resolve(
argArr().pushMapList(
relations.channels!!.map {
argMap().apply {
putS("uuid", it.uuid)
putS("encodedId", it.encodedId)
putS("relation", it.relation.name.lowercase())
putL("updateAt", it.updatedAt?.unix)
}
},
),
)
}
override fun channels(
channelPublicIds: ReadableArray?,
promise: Promise,
) = onMain {
TalkApiClient.instance.channels(publicIds = channelPublicIds?.filterIsInstance<String>()) { relations, error ->
if (error != null) {
promise.rejectWith(error)
} else if (relations?.channels == null) {
promise.rejectWith(RNCKakaoResponseNotFoundException("channels"))
} else {
promise.resolve(
argArr().pushMapList(
relations.channels!!.map {
argMap().apply {
putS("uuid", it.uuid)
putS("encodedId", it.encodedId)
putS("relation", it.relation.name.lowercase())
putL("updateAt", it.updatedAt?.unix)
}
},
),
)
}
}
}

companion object {
const val NAME = "RNCKakaoChannel"
Expand Down
6 changes: 5 additions & 1 deletion packages/channel/android/src/oldarch/KakaoChannelSpec.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package net.mjstudio.rnkakao.channel

import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.ReactContextBaseJavaModule
import com.facebook.react.bridge.ReadableArray

abstract class KakaoChannelSpec internal constructor(context: ReactApplicationContext) :
ReactContextBaseJavaModule(context) {
Expand Down Expand Up @@ -40,5 +41,8 @@ abstract class KakaoChannelSpec internal constructor(context: ReactApplicationCo
promise: Promise,
)

abstract fun channels(promise: Promise)
abstract fun channels(
channelPublicIds: ReadableArray?,
promise: Promise,
)
}
3 changes: 2 additions & 1 deletion packages/channel/ios/RNCKakaoChannel.mm
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ - (RNCKakaoChannelManager*)manager {
}

RCT_EXPORT_METHOD(channels
: (nullable NSArray*)channelPublicIds resolve
: (RCTPromiseResolveBlock)resolve reject
: (RCTPromiseRejectBlock)reject) {
[[self manager] channels:resolve reject:reject];
[[self manager] channels:channelPublicIds resolve:resolve reject:reject];
}

// Don't compile this code when we build for the old architecture.
Expand Down
Loading

0 comments on commit c98a7eb

Please sign in to comment.