question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: Push notifications plugin on iOS doesn't work when app is in background

See original GitHub issue

Bug Report

On iOS if the app is in background none of the registered callbacks get called when a push notification is sent to the device.

Capacitor Version

💊   Capacitor Doctor  💊 

Latest Dependencies:

  @capacitor/cli: 2.4.2
  @capacitor/core: 2.4.2
  @capacitor/android: 2.4.2
  @capacitor/electron: 2.4.2
  @capacitor/ios: 2.4.2

Installed Dependencies:

  @capacitor/cli 2.4.0
  @capacitor/core 2.4.0
  @capacitor/android 2.4.0
  @capacitor/ios 2.4.0
  @capacitor/electron not installed

[success] Android looking great! 👌
  Found 3 Capacitor plugins for ios:
    @capacitor-community/camera-preview (1.0.4)
    cordova-plugin-audioinput (1.0.2)
    cordova-plugin-email-composer (0.9.2)
[success] iOS looking great! 👌

Platform(s)

Tested on iPhone 7 Plus with iOS 13.5.1

Current Behavior

  1. Launch the app, wait for the home screen to be displayed, then put it in the background
  2. Push a notification to the app
  3. None of the app callbacks get called

Expected Behavior

  1. At least the pushNotificationReceived callback get called

Code Reproduction

Use the example guide to create a demo app, then try to send the following notification payloads (I tried both a “normal” payload and a “background mode” payload, see docs here):

normal payload

{
  "APNS_SANDBOX": {
    "aps":{
      "alert":{
        "title": "A title", 
        "body":"A notification for you"
      },
      "sound":"default"
    },
    "additionalData": "my additional data"
  }
}

background mode payload

{
  "APNS_SANDBOX": {
    "aps":{
      "content-available": 1
    },
    "additionalData": "my additional data"
  }
}

Other Technical Details

npm --version output: 6.13.4

node --version output: v12.16.1

pod --version output (iOS issues only): 1.9.1

Additional Context

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

12reactions
sertal70commented, Oct 28, 2020

thank @jcesarmobile for your answer, I’ll switch back my app to Cordova push plugin.

I’m in the process to migrate an app from Ionic3+Cordova to Ionic5+Capacitor, at the end of the journey this will result in a mixed Capacitor+Cordova app, a very unpleasant result.

If Capacitor does not implement the “feature parity” toward Cordova and its plugin ecosystem, then the Ionic team should avoid to advertise Capacitor as a Cordova replacement, because it is not.

6reactions
jcesarmobilecommented, Oct 28, 2020

pushNotificationReceived is only fired if the app is in foreground, if in background the OS will display the push notification and if you tap it pushNotificationActionPerformed will be called.

Silent push are not supported by Capacitor push plugin

Read more comments on GitHub >

github_iconTop Results From Across the Web

Silent Push Notifications doesn't work properly on iOS 14
I found it by checking the device log using console.app. But seems they are NOT delivered to the app. And like you folks,...
Read more >
Push notification is not working when app is in background ...
I'd also make sure all the correct capabilities in Xcode are set (Enabled Remote notification, Background Fetches in Xcode setup, Enabled Push ......
Read more >
Notifications Not Shown - Mobile Push
Step 2: Settings --> Apps or Notification Manager --> Advanced or Notify for your app --> Ignore Battery Optimizations, select the app and...
Read more >
awesome_notifications | Flutter Package - Pub.dev
Working progress percentages of awesome notifications plugin ... Extra iOS Setup for Background Actions; Example Apps; Awesome Notification's ...
Read more >
Troubleshooting Duo Push notification issues on iOS devices
Closing or force quitting the app and reopening it will also fetch the notification. You may also try swiping down from the top...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found