Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push notifications disappear if app is opened #406

Closed
christopheblin opened this issue Aug 31, 2018 · 7 comments
Closed

Push notifications disappear if app is opened #406

christopheblin opened this issue Aug 31, 2018 · 7 comments

Comments

@christopheblin
Copy link

christopheblin commented Aug 31, 2018

Description:

If my app is opened and a notification is received, the app is briefly displayed on the top of the screen => OK
Now, if I open the iOS notification panel by dragging the top of the screen to the bottom, I can see the notification but it immediately disappear.

From what I've seen, this may be due to https://documentation.onesignal.com/v5.0/docs/troubleshooting-ios#section-previous-push-notifications-disappear
=> this is not the case, the notification is sent with "Badges | Increment by 1" (notif id = 43cc6863-4def-438d-9296-ee284c1b39c4) and I also tried using this flag

The closest issue I find about this here is #338, however this does not occur (i.e I correctly receive push when app is closed and app correctly opens when notif is clicked)

Environment
iOS SDK installed with pod 'OneSignal', '>= 2.6.2', '< 3.0'

Steps to Reproduce Issue:

  1. Open the app
  2. Send a push from our server to one signal
  3. Notif is received and small popup is displayed
  4. Opening notif history => notif immediately disappear
@Nightsd01
Copy link
Contributor

@christopheblin does this occur for you for all notifications, even where you dont set any badge count related fields?

@Nightsd01
Copy link
Contributor

@christopheblin also, are you opening the app at any point before pulling down Notification Center?

@christopheblin
Copy link
Author

@Nightsd01

does this occur for you for all notifications, even where you dont set any badge count related fields?
-> No, if I do not set the ios_badgeCount / ios_badgeType, the notification stays opened if the app is opened and disappears only when the user clicks on it or dismisses it (this is what I want, but I also want the bdge on the app if the app is closed).

are you opening the app at any point before pulling down Notification Center?
-> Yes, the problem occurs ONLY if the app is opened

@christopheblin
Copy link
Author

OK I got it working, I was misled by the doc saying "OneSignal_disable_badge_clearing = false in your application's Info.plist." at https://documentation.onesignal.com/v5.0/docs/troubleshooting-ios#section-previous-push-notifications-disappear

Indeed, you must set this flag to true (instead of false) -> OneSignal does not clear the badge automatically anymore when the flag is true.

This is done at

+ (BOOL) clearBadgeCount:(BOOL)fromNotifOpened {

The counterpart, of course, is that you have to do decrement/clear the badge count manually because the operating system does not automatically decrement the badge count when you open the app !

All that said, the only thing that really works for badges (be it for iOS or Android) is that the server must send the number of unread notifications to display.
Doing that, you also support multi-devices correctly.

@Nightsd01
Copy link
Contributor

Thanks for noticing that, we've fixed our doc

@lethianqt94
Copy link

lethianqt94 commented Apr 16, 2019

@Nightsd01 It still happens. https://documentation.onesignal.com/docs/troubleshooting-ios#section-previous-push-notifications-disappear. This solution is not working. My notifications, which come when app opens, disappear in Notification Center.

@DhirenBharadava143
Copy link

Push notifications disappear if app is opened

Hello everyone please try this below snippet

func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
        completionHandler([.sound, .badge, .banner,.list])
}

Note :- just need to add .list in this method so you will get disappear push notification

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants