Skip to content

Commit

Permalink
background push notification
Browse files Browse the repository at this point in the history
  • Loading branch information
deptno committed Jan 27, 2024
1 parent 8e5417f commit fe7ea7f
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 3 deletions.
37 changes: 37 additions & 0 deletions diary/2024-01-27.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
- [X] [[../ios|ios]] [[../push-notification|push-notification]] 백그라운드에서 뱃지 업데이트 못함
- `@react-native-firebase/messaging`
- `setBackgroundMessageHandler` 가 호출되지 않는다
- 문제
- 백그라운드 핸들러를 통해서 노티피케이션을 띄우는게 아닌 os 에서 직접 띄움
- 직접띄우면서 백그라운드 핸들러가 호출되지 않기 때문에 여기서 처리하려던 로직을 처리할 수 없음
- 처리 하려던 것
- increment badge count
```json
{
"apns": {
"headers": {
"apns-priority": "10",
"apns-push-type": "background" // 우선순위 낮음의 background 처리
},
"payload": {
"aps": {
"content-available": 1,
"badge": 3, // 보내면서 badge 를 set 해버릴 수 있다. increment 가 안된다
"sound": "default"
}
},
},
}
```
- `content-available` 로도 `setBackgroundMessageHandler` 핸들러가 호출되는 것은 확인, 다만 100%는 아닌것으로 보인다
- 조건
- [[../ios|ios]]
- `notification` 없이 `sound` 만 보내면 `sound` 는 무시된다
- `apns-push-type: background` 는 apns-priority: 10 에서 에러라고 문서에 명시되어있다
- `apns-push-type: background` 는 ios 에서 notification 을 띄우지 않는다.
- `content-available` 이 설정되지 않으면 `apns-push-type: background` 설정을 하지 **않았을 때** `setBackgroundMessageHandler` 에 도달하지 않는다
- android 는 notifee 의 뱃지 관련 api 는 사용할 수 없다

- [ ] [[../@todo|@todo]] [[../fcm|fcm]]
- [ ] 로그아웃 관리 https://rnfirebase.io/messaging/server-integration#signing-out-users
- [ ] [[../ios|ios]] 이미지 전송 설정
5 changes: 5 additions & 0 deletions flipper.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
# flipper

## install
```sh
brew install --cask flipper
```

### [[ios]]
- `idb` 설치 필요
- mac 에서는 `pip3` 사용

## [[error]]
### Failed to start flipper-server
```sh
Expand Down
16 changes: 13 additions & 3 deletions push-notification.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
# push-notification
## 작업 기록
+ [[diary:2024-01-27]]

## 동작
- app: active
- 수신: onMessage
- 수신: onMessage -> noficiation 을 띄운다
- app: active 가 아닌경우
- notification 자체는 시스템에서 띄우는 것으로 *추측*
- 수신: setBackgroundMessageHandler
- [[ios]] 수신 조건
- `contentAvailble: true` + `apns-priority: '10'`
- `cpns-push-type: 'background'` + **not** `apns-priority: '10'`
- ~~getInitialNotification~~ `@notifee/react-native` 사용시 `notifee.getInitialNotification`
- remote notification 이 눌린경우
- 수신: ~~onNotificationOpenedApp~~ `@notifee/react-native` 사용시 `notifee.onForegroundEvent` - `type: 'PRESS'`
Expand All @@ -18,10 +26,11 @@ flowchart
style react-native fill:#e91
fcm --payload--> onMessage
fcm -.payload.-> setBackgroundMessageHandler
fcm -.payload, :ios:contentAvailable:true\n.-> setBackgroundMessageHandler
fcm -.payload :ios:apns-push-type-background\niOS ONLY 추측.-> notification
setBackgroundMessageHandler -.-> app
setBackgroundMessageHandler -.notification 띄우는 주체가 아직 불확실.-> notification
setBackgroundMessageHandler -.:background: 경우 notification 은 시스템에서 의해서 뜨는 것으로 추측.-> notification
onMessage --> app
app --show--> notification
Expand Down Expand Up @@ -119,3 +128,4 @@ flowchart TD

## link
- [[fcm]]
- [[react-native]]

0 comments on commit fe7ea7f

Please sign in to comment.