# V3에서 v4로 마이그레이션 후, push notification이 작동하지 않습니다

**URL:** <https://community.sendbird.com/t/v3-v4-push-notification/7207>\
**Category:** JavaScript\
**Tags:** push-notification, chatsdk, react-native\
**Created:** [May 3, 2023, 3:04am UTC](https://community.sendbird.com/t/v3-v4-push-notification/7207 "2023-05-03T03:04:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Seunghyun\_Lee](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/seunghyun_lee/32/3963_2.png) [@Seunghyun\_Lee](https://community.sendbird.com/u/Seunghyun_Lee)\
**Post date:** [May 3, 2023, 3:04am UTC](https://community.sendbird.com/t/v3-v4-push-notification/7207/1 "2023-05-03T03:04:16Z")

</div>

**[Problem/Question]**  
v3(3.1.22)에서 v4(4.6.2)로 마이그레이션 후, push가 동작하지 않습니다.

**[Reproduction Steps]**  
테스트는 각각 다른 userId로 안드로이드와 iOS 기기에서 하나의 그룹챗 방을 만들어서 했는데, 서로의 메시지에 대한 push가 도착하지 않습니다.(multi device 등 모두 켜 있습니다.)  
(그러나, v3 기반의 app에서는 둘 다, 서로 push가 잘 왔다 갔다 합니다.)

그래서 dashboard의 test push로 테스트 해 보았는데, 특이점이 있었습니다.  
android/iOS 모두, token이 기기에서 등록할 때 보낸 token과 다른 token이 보이며,  
test push를 보내면, test push popup에 둘다 실패가 뜹니다.  
그러나, android는 test message를 받고, iOS는 받지 못합니다.

그래서, test push를 보내기 전에, token을 기기에서 등록할 때 보낸 token을 리스트에서 찾아서 설정한 다음 보내면,  
android는 test push popup에 여전히 실패가 뜨지만, iOS는 성공합니다.  
그리고 push message는 android/iOS 둘 다 받습니다.  
(그리고 해당 test push를 누르면, 채팅창으로 잘 이동해서 보여집니다.)

**[Frequency]**  
위의 경우는 현재 항상 발생하고 있습니다.

**[Current implementation]**  
V4 구현에 대한 요약은 아래와 같습니다.

- 그룹 채널만 사용
- localcache 사용 (AsyncStorage)
  - 채널리스트 - GroupChannelCollection
  - 메시지 - MessageCollection

- push options - 기본으로 MENTION\_ONLY 사용(connect → set push option → register push token)
  - 채팅 방 별 관리
    - 채팅방에 들어오면, 해당 채널에 대해서 OFF로 했다가, 나갈 때, 다시 'MENTION\_ONLY’로 회복
    - 채팅방에 들어와 있는 상태에서, background/inactive가 되면, MENTION\_ONLY로 바꿨다가, 다시 active가 되면, OFF로 복귀

  - push option에 대한 것은 각 단계 별로, 리턴 값을 확인해서 정상적으로 바뀌는 것을 확인했음

기본적으로, uikit의 소스코드를 참조해서 재구성하였습니다.

---

<div class="post-metadata">

**Author:** ![Seunghyun\_Lee](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/seunghyun_lee/32/3963_2.png) [@Seunghyun\_Lee](https://community.sendbird.com/u/Seunghyun_Lee)\
**Post date:** [May 25, 2023, 6:56am UTC](https://community.sendbird.com/t/v3-v4-push-notification/7207/2 "2023-05-25T06:56:32Z")

</div>

mentionType의 문제 였음.  
USER로 되어 있던 것을 CHANNEL로 바꿔서 해결함  
platform SDK쪽에 있는 문서에 조금 이해할 수 있는 설명이 있어서 해결되었음.  
(V3의 code를 migration 하면서, mentionType이 잘못 이식되었었음…)
