2

I seem to have run into a regression in iOS11. I have an app that receives silent push notifications (push notifications with "content-available": 1) every hour in order to refresh itself. It has been working for years now with no problems.

However, after the iOS11 update, my users started reporting that they were seeing visible notifications with no message every hour - e.g.

I verified this.

  • phone on iOS10. Left the phone running overnight - no blank messages.
  • upgraded to iOS11 without reinstalling the app - blank messages

I added a breakpoint to didReceiveRemoteNotification and found that the notification was displayed before didReceiveRemoteNotification started running

The userInfo parameter of didReceiveRemoteNotification was

{
    aps =     {
        alert =         {
            title = "e-mission-phone";
        };
        "content-available" = 1;
    };
    notId = 1506359243823816;
    payload =     {
        notId = 1506359243823816;
    };
}

So basically, it looks like iOS11 has changed the way in which it determines that a notification is silent and displays notifications that were previously hidden in iOS10.

I cannot find any documentation that this behavior is supposed to have changed, or what the new payload should look like. Has anybody else seen this? I am using the phonegap-push-plugin to receive notifications and ionic push to send notifications.

Shankari
  • 389
  • 2
  • 4
  • 14

2 Answers2

1

Answering my own question in the hope that it might help others. This is due to issues in the integration between ionic push and APNS, combined with a change in APNS behavior between iOS10 and iOS11. Basically, ionic push adds an alert title if the user does not specify it, and iOS10 apparently used to ignore the title if content-available: 1 but does not any more in iOS11.

edit #1: I originally thought that this could be fixed by lowering the priority of the message, but that doesn't help. ionic really needs to stop setting a title if one is not provided. I've filed an ionic support ticket, but I am not sure when I will get a response.

edit #2: I can confirm, through extensive experimentation that there is no way to stop ionic from adding an alert title, even by setting the alert title to "". Details, including config messages, are at https://github.com/e-mission/e-mission-phone/issues/290#issuecomment-332049861, but basically, if the spec passed in to ionic has a title, it is used, otherwise, ionic auto-adds a title.

Shankari
  • 389
  • 2
  • 4
  • 14
0

From Apple push notifications doc:

The sending of a silent notification requires a special configuration of the notification’s payload. If your payload is not configured properly, the notification might be displayed to the user instead of being delivered to your app in the background. In your payload, make sure the following conditions are true:

The payload’s aps dictionary must include the content-available key with a value of 1.

The payload’s aps dictionary must not contain the alert, sound, or badge keys.

Important part is The payload’s aps dictionary must not contain the alert key.

That's not new, it was like that before, so probably on iOS 10 it was ignoring it and now on iOS 11 it displays it instead. You should remove the alert from your payload.

jcesarmobile
  • 51,328
  • 11
  • 132
  • 176
  • I answered my own question below. ionic push (which is the push service that I use) is adding the alert automatically - I don't specify it in my configuration. I've filed a help issue asking them to fix it, but I am unsure when they will respond. – Shankari Sep 26 '17 at 18:44
  • I have edited the title to clarify that this only happens for ionic push – Shankari Sep 26 '17 at 19:05