Skip to content

iOS 10 completionHandler called twice? #148

@mohpor

Description

@mohpor

I need some help here guys.

My implementation of notifications is very simple:

OneSignal.initWithLaunchOptions(launchOptions, appId: "46b495af-9a8c-4af8-937a-3e57d78a0029", handleNotificationReceived: { result in
      print("Notification received: \(result)")
      guard let typedic = result?.payload.additionalData else {
        print("No additional data found, ignoring notif.")
        return
      }
//...
    }, handleNotificationAction: { result in

      print("Notification opened: \(result)")
     //...
    }, settings: [kOSSettingsKeyInFocusDisplayOption:OSNotificationDisplayType.none.rawValue])

But, when I get the notification in the background and I tap an action button, I get this exception:

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'this request has been neutered - you can't call -sendResponse: twice nor after encoding it'

I have searched a lot around and the reason seems to be the fact that the fetchCompletion is getting called twice.

More Details:

  • My notification payload is actually contains both contents and content-available, but removing either one didn't help the case.
    Example:
{
  "app_id": "...",
  "included_segments": ["All"],
  "data": {"type":"..."},
  "headings": {"en": "Heading"},
  "subtitle": {"en": "subtitle"},
  "contents": {"en": "body"},
  "buttons": [{"id": "view_button", "text": "details"}]
}
  • I have no other code or 3rd party library concerning push notifications whatsoever.
  • If I enable in-app notification's alert, the action works perfectly fine.

What am I doing wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions