react-native-notifications: Android dead/killed app not receiving any notification, and in foreground/background banner now show
Helo, im moving from React Native Push Notification to this package because there is a lot of issue on that package.
i have several question here :
-
How to show the banner of notification on Android (Not Testing on IOS) ? since we can customize the layout but still i cannot understand how to implement this one https://github.com/wix/react-native-notifications/wiki/Android:-Layout-Customization
-
In dead/killed states, im not receiving any notirifcation until i open the application it self. how can i manage this ?
Code :
class App extends Component {
constructor(props) {
super(props);
this.state = {};
this.pushNotificationListener();
//Testing Local Push Notification but still NO BANNER appear
Notifications.postLocalNotification({
body: "Local notification!",
title: "Local Notification Title",
sound: "chime.aiff",
silent: false,
category: "SOME_CATEGORY",
userInfo: { }
});
}
pushNotificationListener = async () => {
Notifications.getInitialNotification()
.then((notification) => {
console.log("Initial notification was:", (notification ? notification.payload : 'N/A'));
})
.catch((err) => console.error("getInitialNotifiation() failed", err));
Notifications.registerRemoteNotifications();
Notifications.events().registerRemoteNotificationsRegistered((event: Registered) => {
// TODO: Send the token to my server so it could send back push notifications...
console.log("Device Token Received", event.deviceToken);
});
Notifications.events().registerRemoteNotificationsRegistrationFailed((event: RegistrationError) => {
console.error(event);
});
Notifications.events().registerNotificationReceivedForeground((notification: Notification, completion) => {
console.log(`Notification received in foreground: ${notification}`);
completion({alert: true, sound: true, badge: true});
});
Notifications.events().registerNotificationOpened((notification: Notification, completion) => {
console.log(`Notification opened: ${notification.payload}`);
completion();
});
Notifications.events().registerNotificationReceivedBackground((notification: Notification, completion: (response: NotificationCompletion) => void) => {
console.log("Notification Received - Background", notification.payload);
// Calling completion on iOS with `alert: true` will present the native iOS inApp notification.
completion({alert: true, sound: true, badge: false});
});
}
}
What i have done so far ?
- I have tried to use
Master
Branch to see the update for this one but got Error while Running :
Error :
bundling failed: Error: While trying to resolve module `react-native-notifications` from file `/Users/bobbyrinaldy/Project/React/Mobile/src/app.js`, the package `/Users/bobbyrinaldy/Project/React/Mobile/node_modules/react-native-notifications/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`/Users/bobbyrinaldy/Project/React/Mobile/node_modules/react-native-notifications/lib/dist/index.js`.
Enviroment 👍
"@react-native-firebase/app": "6.7.1",
"@react-native-firebase/messaging": "6.7.1",
"react-native-notifications": "wix/react-native-notifications#master", // or "react-native-notifications": "^3.1.4",
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 16 (6 by maintainers)
@bobbyrinaldy i did 1). Don’t forget to generate and push into your fork
dist
folder (It’s ignored in.gitignore
) if you are not going to publish into npm.ahhh that clear for me, thanks for your time btw. try to check if im can do something about it
@bobbyrinaldy