Develop/React & React Native

react-native-push-notification 사용 시 주의점 (안드로이드 id)

안다희 2023. 6. 9. 17:09
728x90

https://github.com/zo0r/react-native-push-notification

 

GitHub - zo0r/react-native-push-notification: React Native Local and Remote Notifications

React Native Local and Remote Notifications. Contribute to zo0r/react-native-push-notification development by creating an account on GitHub.

github.com

이 라이브러리를 사용할 때 주의점이 있다.

보다시피 id를 설정할 수 있는데, 한번 지정된 id는 다시 사용하지 않는 것이 좋다.

안그러면 이 푸시에 넣은 데이터를 꺼내올 때 예전 id의 데이터를 꺼내오기 때문이다.

 

이 문제 때문에 서비스에서 불편을 겪은 유저가 한둘이 아니다ㅠ.ㅠ 이제라도 발견해 해결해서 다행이다.

부디 항상 새로운 id를 부여하시길!!!!

 

 

또는, id가 optional이기 때문에 아예 부여 안하면 이렇게 알아서부여해준다.

아래 데이터는 이 함수로 가져왔다.

PushNotification.getScheduledLocalNotifications

 

 

 

https://github.com/zo0r/react-native-push-notification/issues/2368

 

[FYI] If the ID used once is given again, the old data is loaded. Be careful. · Issue #2368 · zo0r/react-native-push-notificat

Give this id an unused id. Otherwise, the old data comes from the cached data that was used in the past.

github.com

모두의 소중한 시간을 위해 이슈에도 올림ㅎ