bug: Onesignal notification not shown on iOS with the app in foreground
See original GitHub issueBug Report
Capacitor Version
💊 Capacitor Doctor 💊
Latest Dependencies:
@capacitor/cli: 3.4.3
@capacitor/core: 3.4.3
@capacitor/android: 3.4.3
@capacitor/ios: 3.4.3
Installed Dependencies:
@capacitor/cli: 3.4.3
@capacitor/android: 3.4.3
@capacitor/core: 3.4.3
@capacitor/ios: 3.4.3
[success] iOS looking great! 👌
[success] Android looking great! 👌
Platform(s)
iOS
Current Behavior
After project upgrade (from Capacitor@2.5.0, onesignal-cordova-plugin@2.11.4 to Capacitor@3.4.3, onesignal-cordova-plugin@3.0.2) Onesignal push notification not shown when the app is in foreground. This happens despite having configured the proper handler for foreground notifications like Onesignal wiki suggest.
Expected Behavior
Inbound Push Notification shown by OS
Code Reproduction
- Create a simple project using cordova-onesignal-plugin
- make all necessary configs on Onesignal side.
- Send a test notification from Onesignal dashboard.
Other Technical Details
npm --version
output: 8.5.5
node --version
output: v14.17.0
pod --version
output (iOS issues only): 1.11.3
Additional Context
My workaround is to forcibly disable handleApplicationNotifications member of NotificationRouter class:
import Foundation
@objc(CAPNotificationRouter) public class NotificationRouter: NSObject, UNUserNotificationCenterDelegate {
/*var handleApplicationNotifications: Bool {
get {
return UNUserNotificationCenter.current().delegate === self
}
set {
let center = UNUserNotificationCenter.current()
if newValue {
center.delegate = self
} else if center.delegate === self {
center.delegate = nil
}
}
}*/
var handleApplicationNotifications: Bool = false
...
...
After doing this i was capable to receive push notification on iOS and the app in foreground.
Issue Analytics
- State:
- Created a year ago
- Reactions:3
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Notifications Not Shown - Mobile Push
Common reasons why Mobile Push notifications are not showing on your device. ... "Delivered" notifications in OneSignal means we have successfully sent the ......
Read more >iOS - Notification not shown on with the app in foreground ...
This happens despite having configured the proper handler for foreground notifications like Onesignal wiki suggest. ... Steps to Reproduce Issue:.
Read more >OneSignal does not showing notification when app is in ...
Here you go: OneSignal.shared .setNotificationWillShowInForegroundHandler((OSNotificationReceivedEvent event) { print('FOREGROUND HANDLER ...
Read more >awesome_notifications | Flutter Package
A complete solution to create Local and Push Notifications, customizing buttons, images, sounds, emoticons and applying many different layouts for Flutter ...
Read more >How to perform action when user tap on push notification ...
It has since been replaced with the UNUserNotificationCenter class after iOS 10. To handle push notification in App Delegate, we will set the ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Same problem here, any update?
Hi,
any update?
@jcesarmobile @emawby