0.1.1 • Published 3 years ago

onemedics-push-app v0.1.1

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

요약

이 프로젝트는 모바일(react-native) 에서 푸시 기능을 간편하게 만들수 있도록 SDK를 제공하는데 그 목적이 있습니다.

목차

  • 기능
  • 설치
  • NOTE
  • 사용예제
  • 참조

기능

This is the App Module of the OneMedics Push SDK

  • initializeToken
  • getMessaging
  • modifyPermission
  • deleteUserToken

설치

npm i onemedics-push-app

NOTE

NOTE: Firebase를 iOS 앱에 추가하려면 먼저 iOS 앱에 연결할 Firebase 프로젝트를 만드세요. Firebase 프로젝트에 대한 자세한 내용은 아래 링크를 참조하세요. https://firebase.google.com/docs/cloud-messaging/ios/client

NOTE: Firebase 클라우드 메시징 Android 클라이언트 앱을 만들려면 FirebaseMessaging API와 Gradle이 있는 Android 스튜디오 1.4 이상을 사용하세요. 아래 링크를 참조하세요. https://firebase.google.com/docs/cloud-messaging/android/client

사용예제

초기세팅

index.ts

GraphQL API의 접속 정보, access 토큰설정으로 ApolloClient 생성

import { PushCoreModule, CoreModuleConfig } from 'onemedics-push-app';
const coreModuleConfig: CoreModuleConfig = {
  baseToken: 'OAUTH_ACCESS_TOKEN',
  url: 'PUSH_API URL',
  clientId: 'CLIENT_ID',
};

const pushCoreModule = new PushCoreModule(coreModuleConfig);

//access token, client id가 바뀌는 경우 pushCoreModule.refreshAccessToken('OAUTH_ACCESS_TOKEN','dosoo-app');

const PushApp = () => { return ( ); };

AppRegistry.registerComponent(appName, () => PushApp);

  

app.tsx
>  appPushModule을 사용하기 위한 인스턴스 생성 후 API통신을 위한 coreModule 세팅
```javascript
import { PushAppModule } from 'onemedics-push-app';
const pushModule = new PushAppModule(pushCoreModule);

푸시모듈 호출

- 토큰 등록 및 메시지 수신 설정

pushModule.initializeToken('CLIENT_ID').then((FCM_TOKEN) => console.log(FCM_TOKEN));
pushModule.onMessage((PAYLOAD) => {
  console.log('PAYLOAD', PAYLOAD);
});

- 권한 수정 및 토큰 삭제

// 유저 권한 수정
pushModule
  .modifiedPermission(true/false)
  .then((result) => console.log(result));

// 유저아이디 삭제
// Async Storage에서 받아온 UserId값으로 삭제처리 
pushModule
  .deleteUser()
  .then((result) => console.log(result));

참조

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

https://rnfirebase.io/

0.1.1

3 years ago

0.1.0

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.23

3 years ago

0.0.22

3 years ago

0.0.21

3 years ago

0.0.20

3 years ago

0.0.2

3 years ago

0.0.19

3 years ago

0.0.18

3 years ago

0.0.17

3 years ago

0.0.16

3 years ago

0.0.15

3 years ago

0.0.14

3 years ago

0.0.13

3 years ago

0.0.12

3 years ago

0.0.11

3 years ago

0.0.10

3 years ago

0.0.1

3 years ago