This repository was archived by the owner on Jan 14, 2025. It is now read-only.
This repository was archived by the owner on Jan 14, 2025. It is now read-only.
iOS onNotification data undefined #1488
Open
Description
Bug
When using the example code to create a push notification handler class and a notification service, if you click on a local notification, the onNotification function is being run as expected however the message and badge come back as 'undefined' even though the notification itself clearly has a message on it.
NotificationHandler: {foreground: true, userInteraction: false, message: undefined, data: {…},
badge: undefined, …}
Notification Service constructor:
constructor(onRegister, onNotification) {
this.lastId = 0;
NotificationHandler.attachRegister(onRegister);
NotificationHandler.attachNotification(onNotification);
// Clear badge number at start
PushNotification.getApplicationIconBadgeNumber(function(number) {
if(number > 0) {
PushNotification.setApplicationIconBadgeNumber(0);
}
});
}
Push notification handler constructor:
constructor(props) {
super(props);
this.state = {};
this.notif = new NotifService(
this.onRegister.bind(this),
this.onNotif.bind(this),
);
}
onNotification function:
onNotification(notification) {
console.log('NotificationHandler:', notification);
if (typeof this._onNotification === 'function') {
this._onNotification(notification);
}
notification.finish(PushNotificationIOS.FetchResult.NoData);
}
Environment info
"@react-native-community/push-notification-ios": "^1.2.2",
"react-native-push-notification": "^3.5.2",
"react-native": "0.62.2",
"react": "16.13.1",
react-native info
output:
System:
OS: macOS 10.15.5
CPU: (8) x64 Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz
Memory: 50.45 MB / 16.00 GB
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 14.0.0 - /usr/local/bin/node
Yarn: 1.22.4 - /usr/local/bin/yarn
npm: 6.14.4 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.9.2 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 13.5, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
Android SDK:
API Levels: 28, 29
Build Tools: 28.0.3, 29.0.2
System Images: android-27 | Google Play Intel x86 Atom, android-28 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom, android-29 | Google Play Intel x86 Atom
Android NDK: Not Found
IDEs:
Android Studio: 3.5 AI-191.8026.42.35.6010548
Xcode: 11.5/11E608c - /usr/bin/xcodebuild
Languages:
Java: 1.8.0_232 - /Users/<user>/.jabba/jdk/zulu@1.8.232/Contents/Home/bin/javac
Python: 2.7.16 - /usr/bin/python
npmPackages:
@react-native-community/cli: Not Found
react: 16.13.1 => 16.13.1
react-native: 0.62.2 => 0.62.2
npmGlobalPackages:
*react-native*: Not Found
Metadata
Metadata
Assignees
Labels
No labels