Comments (5)
@kamil-floqsta In order to not display the notification you just call event.preventDefault();
If you would then like to display the notification after delaying the default display you call event.getNotifications.display();
If you never want to show the notification do not call display
from react-native-onesignal.
@kamil-floqsta In order to not display the notification you just call
event.preventDefault();
If you would then like to display the notification after delaying the default display you callevent.getNotifications.display();
If you never want to show the notification do not call display
@emawby Unfortunately it doesn't work. Here is a code sample:
OneSignal.Notifications.addEventListener(
'foregroundWillDisplay',
(notificationReceivedEvent: NotificationWillDisplayEvent) => {
const notification = notificationReceivedEvent.getNotification();
if (
// some condition
) {
notificationReceivedEvent.preventDefault();
return;
}
}
notification.display();
}
);
The listener receives a notification, then notificationReceivedEvent.preventDefault()
is called but after about ~10 seconds the notification is displayed anyway.
from react-native-onesignal.
@emawby I turned on logs with LogLevel.Verbose
And here is the Xcode outcome for the notification with preventDefault()
:
2023-10-26 21:32:17.300081+0200 PROJECT_NAME[85270:18154602] VERBOSE: OSNotificationWillDisplayEvent.preventDefault called.
2023-10-26 21:32:42.256768+0200 PROJECT_NAME[85270:18154435] WARNING: OSNotificationLifecycleListener:onWillDisplayNotification timed out. Display was not called within 25.000000 seconds. Continue with display notification: 0
2023-10-26 21:32:42.263611+0200 PROJECT_NAME[85270:18154435] VERBOSE: finishProcessingNotification: Fired!
2023-10-26 21:32:42.263806+0200 PROJECT_NAME[85270:18154435] VERBOSE: Notification display type: 0
2023-10-26 21:32:42.264041+0200 PROJECT_NAME[85270:18154435] VERBOSE: notificationReceived called! opened: NO
2023-10-26 21:32:42.264601+0200 PROJECT_NAME[85270:18154435] VERBOSE: finishProcessingNotification: call completionHandler with options: 0
from react-native-onesignal.
@emawby Even if e. preventDefault()
is removed the loggs says it was called:
2023-10-27 12:10:15.873749+0200 PROJECT_NAME[86156:18319475] VERBOSE: OSNotificationWillDisplayEvent.preventDefault called.
from react-native-onesignal.
@kamil-floqsta hello, any solution?
from react-native-onesignal.
Related Issues (20)
- (OneSignalNotificationServiceExtension )I got error on build with recat native sdk. How to fix it and what did i do wrong ? HOT 1
- [Bug]: Build fails with Framework not found OneSignalUser after adding onesignal. HOT 3
- [Bug]: Empty subscription id HOT 2
- [Bug]: Problem with addEventListener removeEventListener HOT 3
- [question]: OneSignal + Multi Stage/Flavour Environment HOT 1
- [Bug]: fallback to settings prompt is shown when calling requestPermission(false) HOT 3
- [Bug]: calling requestPermission() returns array with boolean HOT 1
- [question]: Can we use the same bundle ID for development and production with different OneSignal app IDs?
- [question]: How to get `getPushSubscriptionId` in the next line of code HOT 5
- [Bug]: Onesignal push notification with status Failed on iOS HOT 3
- [bug]: why is user tags not added or linked on subscriptions HOT 2
- [question]: How to customize notification prompts based on user language preference? HOT 1
- [Bug]: reactNativeOnesignal.OneSignal.clearHandlers is unedfined HOT 1
- [question]: Multiple commands produce '/Users/hamzabakaran/Library/Developer/Xcode/DerivedData/mobile..../Build/Products/Debug-iphonesimulator/.../Frameworks/OneSignalExtension.framework' HOT 3
- [Bug]: `OneSignal.Notifications.canRequestPermission` not working [Android 11, Android 12] HOT 1
- Closed
- [Bug]: opted in state stops updating on Android after app restarted HOT 6
- [question]: App stopped due to OneSignal?.Notifications?.requestPermission(true); HOT 2
- [Bug]: `getInAppMessages` causing `initWithContext` exception HOT 1
- [Bug]: Doesn't return to the app (crashes) if user rejects notification permission HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-onesignal.