728x90
local notification 안드로이드 알람이 멈추지 않을 때 (react-native-push-notification)
- 사용 라이브러리
https://github.com/zo0r/react-native-push-notification
- 환경
RN 0.61.5
- 버그
안드로이드 설치 따라하고, local notification을 실행시켜 봤는데, 알림이 멈추지 않고 계속 왔다.
Android Notification Keep showing infinitely.
- Usage
PushNotification.localNotification({
/* Android Only Properties */
id: '0', // (optional) Valid unique 32 bit integer specified as string. default: Autogenerated Unique ID
ticker: "My Notification Ticker", // (optional)
autoCancel: true, // (optional) default: true
largeIcon: "ic_launcher", // (optional) default: "ic_launcher"
smallIcon: "ic_notification", // (optional) default: "ic_notification" with fallback for "ic_launcher"
bigText: "My big text that will be shown when notification is expanded", // (optional) default: "message" prop
subText: "This is a subText", // (optional) default: none
color: "red", // (optional) default: system default
vibrate: true, // (optional) default: true
vibration: 300, // vibration length in milliseconds, ignored if vibrate=false, default: 1000
tag: 'some_tag', // (optional) add tag to message
group: "group", // (optional) add group to message
ongoing: false, // (optional) set whether this is an "ongoing" notification
priority: "high", // (optional) set notification priority, default: high
visibility: "private", // (optional) set notification visibility, default: private
importance: "high", // (optional) set notification importance, default: high
/* iOS only properties */
alertAction: // (optional) default: view
category: // (optional) default: null
userInfo: // (optional) default: null (object containing additional notification data)
/* iOS and Android properties */
title: "My Notification Title", // (optional)
message: "My Notification Message", // (required)
playSound: false, // (optional) default: true
soundName: 'default', // (optional) Sound to play when the notification is shown. Value of 'default' plays the default sound. It can be set to a custom sound such as 'android.resource://com.xyz/raw/my_sound'. It will look for the 'my_sound' audio file in 'res/raw' directory and play it. default: 'default' (default sound is played)
number: '10', // (optional) Valid 32 bit integer specified as string. default: none (Cannot be zero)
repeatType: 'day', // (optional) Repeating interval. Check 'Repeating Notifications' section for more info.
actions: '["Yes", "No"]', // (Android only) See the doc for notification actions to know more
});
코드 위와 같았다. (깃헙 예제 그대로 사용)
그래서 아래 링크를 보고 repeatType을 주석 처리 해봤더니 알림이 한 번만 왔다.
repeatType에 버그가 있는걸까?
https://github.com/zo0r/react-native-push-notification/issues/374
근데 localSchedule? 이거 쓰면 repeat 할 수 있는 것 같음.
그리고 date set을 잘해야한다. 이거는 알람 반복설정? 같은거 시도할 때 문제 생기면 다시 참고해보자.
https://github.com/zo0r/react-native-push-notification/issues/270
같은 분이 date set을 강조하신다. 참고!
'Solve Problem > Troubleshooting' 카테고리의 다른 글
앱 종료 시 푸시 알림 클릭했을 때 초기 렌더링이 2번 발생하는 문제 (0) | 2020.06.15 |
---|---|
@react-navigation/routers/src/index.tsx: Unexpected token (9:12) 해결법 (0) | 2020.05.20 |
[React Native] build가 영원히 되지 않을 때 (2) | 2020.05.10 |
[React Native] 에러 모음 (2) | 2020.03.28 |
run-android 되지 않을 때 / Could not compile settings file /JDK 문제 (2) | 2020.03.17 |