# onemedics-push-app-sdk-test

> This is the App Module of the OneMedics Push SDK 원메딕스인더스트리 Android,ios push notification SDK 를 지원합니다

Latest version **0.0.2** (published 2021-04-13) · ISC license · 0 weekly downloads

## Install

```sh
npm install onemedics-push-app-sdk-test
pnpm add onemedics-push-app-sdk-test
yarn add onemedics-push-app-sdk-test
bun add onemedics-push-app-sdk-test
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2021-04-13 |
| First published | 2021-04-13 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 67.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | devbong |
| Keywords | push, fcm, onemedics, push-sdk |

## Links

- npm: https://www.npmjs.com/package/onemedics-push-app-sdk-test
- npm.io page: https://npm.io/package/onemedics-push-app-sdk-test

## Dependencies (2)

- [ts-node](https://npm.io/package/ts-node.md) 9.1.1
- [cross-fetch](https://npm.io/package/cross-fetch.md) 3.0.6

## Recent versions

- 0.0.2 (latest) — 2021-04-13
- 0.0.1 — 2021-04-13

## README

# OneMedics Push App SDK

## 목차

- 요약
- 기능
- 설치
- 사용
- 참조

## 1. 요약
 FCM 으로 부터 Token 을 할당받고 Onemedics Module Push 서비스를 사용, 사용자를 등록 관리한다.

[FCM](https://firebase.google.com/docs/cloud-messaging/?hl=ko)
``` 
Firebase Cloud Messaging 의 줄임말.
Firebase 클라우드 메시징(FCM)은 무료로 메시지를 안정적으로 전송할 수 있는 교차 플랫폼 메시징 솔루션입니다.
```


[![sequence diagram](https://user-images.githubusercontent.com/61695175/113242943-fe38bb00-92ec-11eb-9db2-7e0433b5ddf5.png)](https://onemedics.atlassian.net/wiki/spaces/develop/pages/1225359361/sequence+diagram)


이 프로젝트는 모바일(react-native) 에서 푸시 기능을 간편하게 만들수 있도록 SDK를 제공하는데 그 목적이 있습니다.
앱에 PushModule을 추가하려면 Firebase 콘솔의 프로젝트 등록이 선행되어야 합니다.
#### ios

> NOTE: [ios 푸시 서비스를 이용하기 위해 IOS Messaging Setup 이 필요합니다.](https://rnfirebase.io/messaging/usage/ios-setup)
>
> NOTE: [Firebase를 iOS 앱에 추가하려면 먼저 iOS 앱에 연결할 Firebase 프로젝트를 만드세요.](https://firebase.google.com/docs/ios/setup)

#### android
> NOTE: [Firebase를 Android 앱에 추가하려면 먼저 Android 앱에 연결할 Firebase 프로젝트를 만드세요.](https://firebase.google.com/docs/android/setup)

## 2. 기능

- [x] [FCM 토큰 등록하기](#4-2-1-로그인-후-토큰-및-리스너-등록)

|기능|설명
|------|---
|registerPushToken() |permission 체크 후 allow 상태라면 사용자를 등록하고 서버에 정보를 전달한다.


- [x] [알림 메시지 구독하기](#4-2-1-로그인-후-토큰-및-리스너-등록)

|기능|설명
|------|---
|getMessage().onMessage | fcm 알림 메시지 message Listener
|getMessage().onNotificationOpenedApp| background 상태에서 푸시 클릭 시 불러오는 message Listener
|getMessage().setbackgroundmessagehandler | background 상태의 푸시 messaging Listener (안드로이드에서만 사용)
- [x] [인증 토큰 세팅하기](#4-2-1-로그인-후-토큰-및-리스너-등록)

|기능|value Type| 설명
|------|:---:|---
| setAccessToken(`ACCESS_TOKEN`)| String |세팅된 Access Token 정보를 업로드 한다.


- [x] [권한수정하기](#4-2-2-권한-수정하기)

|기능|value Type| 설명
|----|:----:|---
| modifyPermission(`true/false`)| Boolean |사용자의 푸시 수신권한을 변경한다

- [x] [로그아웃시 토큰 지우기](#4-2-3-로그아웃시-토큰-지우기)

|기능|설명
|------|---
|deleteUser()|registerPushToken 에서 받아온 userId값을 이용해 해당 사용자의 token값과 userInfo를 삭제한다.

- [ ] [알람 메시지 이력 확인하기](#4-2-4-알림-메시지-이력-확인하기)

## 3. 설치

#### 3-1 npmrc 환경설정
> `[프로젝트]` 폴더에 `.npmrc` 파일을 생성합니다.
> 다운받기 위한 레포지토리 설정을 합니다.
```groovy
@onemedics:registry=https://npm.pkg.github.com/
//npm.pkg.github.com/:_authToken=68d76b2af57014519ea34495aff776f10da084b5
```

#### 3-2 다운로드
```groovy
$ npm install @onemedics/push-app-sdk
```

## 4. 사용

#### 4-1 초기 모듈 생성

##### onemedics-push-app module import :

```javascript
import { PushAppModule, CoreModuleConfig } from '@onemedics/push-app-sdk';
```

```javascript
const coreModuleConfig: CoreModuleConfig = {
  baseToken: 'OAUTH_ACCESS_TOKEN',
  url: 'PUSH_API URL',
  clientId: 'CLIENT_ID',
};

const pushAppModule = PushAppModule.getInstance(coreModuleConfig);
```

#### 4-2. 모듈 사용

#### 4-2-1. 로그인 후 토큰 및 리스너 등록

- 모듈은 로그인 후 다음 순서를 통해 선언되어야 합니다.
     ```js
    // 1. FCM 토큰 발급 및 서버에 토큰 등록하기
     PushAppModule.getInstance().registerPushToken();
  
    // 2. 알림 메시지 구독하기
     PushAppModule.getInstance().getMessage().onMessage((remoteMessage) => console.log(remoteMessage));

     PushAppModule.getInstance()
       .getMessage()
       .onNotificationOpenedApp((remoteMessage) =>{
        // remoteMessage data를 이용해 로드될 페이지를 설정 할 수 있다.
   });  
  
    //푸시서버 ApolloClient 엑세스토큰 세팅
       PushAppModule.getInstance().setAccessToken(`ACCESS_TOKEN`);
     ```

#### 4-2-2. 권한 수정하기

- 사용자가 권한 수정시 해당 호출을 통하여 서버에 저장된 사용유무를 변경합니다.
  ```js
  PushAppModule.getInstance().modifyPermission(boolean);
  ```

#### 4-2-3. 로그아웃시 토큰 지우기

- 로그아웃시 해당 호출을 통하여 웹에 저장된 토큰을 제거합니다.
  ```js
  PushAppModule.getInstance().deleteUser();
  ```

#### 4-2-4. 알림 메시지 이력 확인하기

- 수신된 푸시 알림 이력을 확인합니다.
  ```
  업데이트 예정입니다.
  ```

## 5. 참조

[참고] [리액트 네이티브 파이어베이스](https://rnfirebase.io/)

[⬆ 위로가기](#top)

---
_Source: https://npm.io/package/onemedics-push-app-sdk-test · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
