43

I've noticed that sending a Push notification results in the following behavior:

Push Banner is shown twice?

See how the banner is shown a second time, after a short delay?

At first I thought that our backend was mistakenly sending 2 push notifications, one after the other.

However, this appears to be default iOS behavior for a single Push notification. The banner is shown, then immediately "shown again". This results in this jittery UI shown in the gif. The banner appears to be received twice.

Tested using iOS 9.0.2.

I do not recall seeing this behavior from other apps that send me Push Notifications. Am I doing something wrong that would cause the banner to show twice?

Radar:

Engineering has determined that your bug report (23133694) is a duplicate of another issue (23130766) and will be closed.

Cœur
  • 37,241
  • 25
  • 195
  • 267
pkamb
  • 33,281
  • 23
  • 160
  • 191
  • This is weird. You could try testing push notifications with a different backend (i.e. Parse), just to see if it results in the same behaviour. I tested push notifications few days ago, and I didn't encounter such glitches. Did you try testing on different devices? – FreeNickname Oct 14 '15 at 20:53
  • Definetly not an issue with iOS, since other poeple would've reported it if it was. Either your server is sending it twice, or the event which triggers the server to send the notifications is being fired twice – Hamzah Malik Oct 15 '15 at 20:27
  • @FreeNickname In addition to our backend I've tested this using a single Push from the [NWPusher](https://github.com/noodlewerk/NWPusher) tool, same issue. – pkamb Oct 15 '15 at 21:08
  • @HamzahMalik The method `didReceiveRemoteNotification:fetchCompletionHandler:` is called only once. Our iOS app also has no control over the display of that banner, so I don't think the app could be triggering it. – pkamb Oct 15 '15 at 21:08
  • 1
    I am also experiencing this. It's strange because if you look at the notification center, the notification is only listed once. This issue only affects the number of times the banner is shown. It also appears twice for me. – gmat1014 Nov 12 '15 at 19:40
  • 1
    @ilanbt did RukyO's answer below help, calling `register...` twice? It did not fix my problem (and I think you **should** be able to call it twice) but the answer has many upvotes from others it must have helped. If that *didn't* fix your issue, a comment there would be helpful. – pkamb Feb 16 '16 at 19:05
  • 1
    We had the same problem switching to OneSignal from Parse. Their implementation code is super simple, and we had to remove the [application registerForRemoteNotifications]; from our didRegisterUserNotificationSettings to stop the double notifications from showing up. – Nicholas John Martin Mar 20 '16 at 07:03

8 Answers8

33

I was experiencing the same issue, but after countless hours trying to debug, I realized that I was calling registerUserNotificationSettings(settings) twice in didFinishLaunchingWithOptions:. Verify that you're not doing the same

pkamb
  • 33,281
  • 23
  • 160
  • 191
RukyO
  • 339
  • 2
  • 3
  • Thanks for the answer, I will check this. This would seem to be a workaround for an iOS bug... there should be valid use cases for calling `registerUserNotificationSettings:` twice, such as requesting Badges as well as previously requested Alerts. – pkamb Nov 19 '15 at 16:02
  • We did the same mistake and unfortunately have submitted the app. What can we do now to fix this with a new version without having to ask users to un-install the app? We have tried calling `unregisterForRemoteNotifications` and then `registerUserNotificationSettings` but we are not seeing Notification Permissions Alert Dialog again. – Kaushal Panjwani Mar 16 '16 at 06:37
  • 2
    I'm chasing after this bug as well. The thing that I'm concerned about is that Apple suggest to register for remote notifications on every application launch since the token may change (read here: https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/IPhoneOSClientImp.html) Calling registerUserNotificationSettings only once goes against Apple's suggestion here. – Erez Rabih Jul 07 '16 at 14:34
3

Are you sure you are doing all your setup right?
if you will provide more code it will be easier to find the bug. It's definitely not an iOS bug.


Basic things to check when you have trouble with server notifications:

1. Check your provisioning profile and clean up all unused certificates.
2. Be sure your server configuration is alright. Again, more details are needed for full answer.

If you are doing this offline then usually you missed something in your code or your handler for secluded posts is called two times.

  • I'm fairly certain that my setup is correct. Only one Push is sent via the NWPusher tool, but two banners appear. A coworker confirmed the issue, as did someone in the comments of this question. – pkamb Nov 12 '15 at 19:54
  • @pkamb it's also definitely not an iOS issue. Then if backend is ok just take a look at you push handling in your code – Bagrat Kirakosian Nov 12 '15 at 19:57
  • Push handling in my code has little to do with this... a different app is open, and iOS shows the push notification banner on top of that app. Push handling in an app can not cause the banner to show twice... – pkamb Nov 12 '15 at 21:05
  • @BagratKirakosian, i have the same problem, what could be the problem with the provisioning profile? how do i fix it? – ilan Feb 21 '16 at 20:12
3

Got this issue for two devices we were using with versions ios 9.3.3 and ios 9.2. But this issue was not coming for a device running ios 8.2 and another running for iOS 10 (tested on 10.3)

Issue occurred on devices with 9.3.3 and 9.2 on every fresh install. But restarting the device seemed to fix the issue. Although that is NOT a solution we can propose to customers.

On the console logs for the system we got 'Unbalanced calls to begin/end appearance transitions for SBBannerButtonViewController' message when this occured.

This seems like an issue with some devices having 9.x versions and should be working fine for devices running iOS 10.0 and above.

Swasidhant
  • 1,231
  • 1
  • 12
  • 13
2

Are you using database to store device id?

If yes then may be store device id two times.if possible clean db and try to send it again

2

I think the wrong answer is accepted here (If this is about migrating from Parse to OneSignal). Because for OneSignal there doesn't seem to by any proper solution for this. I am also looking for the solution if any one is having. The only workaround for this was, to restart the phone.

But its weird. We can't ask all the users to reboot their device.

Bhumi Goklani
  • 603
  • 1
  • 8
  • 18
1

We were facing the same issue on IOS 9.3.1

We used urban airship for managing notifications and this was our setup

let config = UAConfig.default()

UAirship.setLogging(false)
UAirship.takeOff(config)
UAirship.push().userPushNotificationsEnabled = true
UAirship.push().notificationOptions = [.alert, .badge, .sound]
UAirship.push().backgroundPushNotificationsEnabled = false
UAirship.push().pushNotificationDelegate = self

After many attempts we simply removed the following line and it worked!

UAirship.push().notificationOptions = [.alert, .badge, .sound]

I hope this will help someone.

Melvin John
  • 71
  • 1
  • 3
1

I know this answer is a couple years after the original post, but in case this helps anyone...

In my case, I was using CloudKit notifications and had accidentally created two subscriptions that tracked the same record type!

mlecoz
  • 409
  • 4
  • 17
0

According to this answer on a similar question, this issue was reported as rdar://23569779 and should be fixed in the iOS 9.3 public release.

Please leave a comment if you reproduce this issue in iOS 9.3+

Supposedly fixed in:

iOS 9.2.1 beta (Build: 13D11)

Community
  • 1
  • 1
pkamb
  • 33,281
  • 23
  • 160
  • 191