JSPM

onemedics-push-app-sdk-test

0.0.2
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 1
    • Score
      100M100P100Q16076F
    • License ISC

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

    Package Exports

    • onemedics-push-app-sdk-test

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (onemedics-push-app-sdk-test) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    OneMedics Push App SDK

    목차

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

    1. 요약

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

    FCM

    Firebase Cloud Messaging 의 줄임말.
    Firebase 클라우드 메시징(FCM)은 무료로 메시지를 안정적으로 전송할 수 있는 교차 플랫폼 메시징 솔루션입니다.

    sequence diagram

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

    ios

    NOTE: ios 푸시 서비스를 이용하기 위해 IOS Messaging Setup 이 필요합니다.

    NOTE: Firebase를 iOS 앱에 추가하려면 먼저 iOS 앱에 연결할 Firebase 프로젝트를 만드세요.

    android

    NOTE: Firebase를 Android 앱에 추가하려면 먼저 Android 앱에 연결할 Firebase 프로젝트를 만드세요.

    2. 기능

    기능 설명
    registerPushToken() permission 체크 후 allow 상태라면 사용자를 등록하고 서버에 정보를 전달한다.
    기능 설명
    getMessage().onMessage fcm 알림 메시지 message Listener
    getMessage().onNotificationOpenedApp background 상태에서 푸시 클릭 시 불러오는 message Listener
    getMessage().setbackgroundmessagehandler background 상태의 푸시 messaging Listener (안드로이드에서만 사용)
    기능 value Type 설명
    setAccessToken(ACCESS_TOKEN) String 세팅된 Access Token 정보를 업로드 한다.
    기능 value Type 설명
    modifyPermission(true/false) Boolean 사용자의 푸시 수신권한을 변경한다
    기능 설명
    deleteUser() registerPushToken 에서 받아온 userId값을 이용해 해당 사용자의 token값과 userInfo를 삭제한다.

    3. 설치

    3-1 npmrc 환경설정

    [프로젝트] 폴더에 .npmrc 파일을 생성합니다. 다운받기 위한 레포지토리 설정을 합니다.

    @onemedics:registry=https://npm.pkg.github.com/
    //npm.pkg.github.com/:_authToken=68d76b2af57014519ea34495aff776f10da084b5

    3-2 다운로드

    $ npm install @onemedics/push-app-sdk

    4. 사용

    4-1 초기 모듈 생성

    onemedics-push-app module import :
    import { PushAppModule, CoreModuleConfig } from '@onemedics/push-app-sdk';
    const coreModuleConfig: CoreModuleConfig = {
      baseToken: 'OAUTH_ACCESS_TOKEN',
      url: 'PUSH_API URL',
      clientId: 'CLIENT_ID',
    };
    
    const pushAppModule = PushAppModule.getInstance(coreModuleConfig);

    4-2. 모듈 사용

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

    • 모듈은 로그인 후 다음 순서를 통해 선언되어야 합니다.
        // 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. 권한 수정하기

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

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

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

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

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

    5. 참조

    [참고] 리액트 네이티브 파이어베이스

    ⬆ 위로가기