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.

[iOS] onMessageReceivedCallback not called when app is in background

See original GitHub issue

I’m having an issue with onMessageReceivedCallback not called when app is in background or is reopened from background on iOS (tested on real device). In the callback function, I save the notification details so users can check back in the app. It works great when app is in foreground. I can receive the notifications when app is in background. If the app is reopened by clicking the notification, I can see the notification in the plugin output from console (attached below).

[320:22412] didReceiveNotification

But the details won’t be saved. I’m sure I already did what here says. ‘Background App Refresh’ is switched open on my device.

Some version info… iOS: 10.3.1 Xcode: 8.3.2

"dependencies": {
    "nativescript-drop-down": "^1.5.3",
    "nativescript-geolocation": "0.0.19",
    "nativescript-orientation": "^1.6.1",
    "nativescript-platform-css": "^1.4.0",
    "nativescript-plugin-firebase": "^3.11.4",
    "nativescript-sidedrawer": "^1.0.5",
    "nativescript-sqlite": "^1.1.3",
    "nativescript-telerik-ui": "^1.6.2",
    "nativescript-theme-core": "~1.0.2",
    "nativescript-zxing": "^1.5.2",
    "tns-core-modules": "2.5.2",
    "ts-promise": "^0.3.4"
  },
  "devDependencies": {
    "babel-traverse": "6.4.5",
    "babel-types": "6.4.5",
    "babylon": "6.4.5",
    "lazy": "1.0.11",
    "nativescript-dev-android-snapshot": "^0.*.*",
    "nativescript-dev-typescript": "~0.3.5",
    "typescript": "~2.1.0"
  }

Am I missing something? Or has anyone had same issue and found ways to work around of this?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
simba4everyoungcommented, Jun 19, 2017

Using correct silent notification message format resolved this issue.

{
	"to": "/topics/ios",
	"content-available": 1,
	"sound": "default",
	"data":{
		"title":"Notification Title",
		"body":"text"
	},
	"priority": "High"
}
0reactions
BMwanzacommented, Aug 22, 2018

@simba4everyoung Hey, what version of Firebase are you using? I am still struggling with this

Read more comments on GitHub >

github_iconTop Results From Across the Web

NativeScript Firebase onMessageReceivedCallback does not ...
I understand there are complications in implementing background push notifications in iOS but in foreground when app is running, why isn't it ...
Read more >
Developers - onMessageReceivedCallback not called when the app ...
I am getting notification when the app is in the background but when the notification is tapped the callback method is not called....
Read more >
Receive messages in an Android app - Firebase - Google
Notification messages delivered when your app is in the background. ... may be shorter depending on OS delays incurred ahead of calling onMessageReceived...
Read more >
nativescript-community/push
Copy that file to app/App_Resources/iOS/app.entitlements (if it doesn't exist ... app was not in the foreground) will trigger the onMessageReceivedCallback ...
Read more >
NativeScript Firebase onMessageReceivedCallback does not ...
I understand there are complications in implementing background push notifications in iOS but in foreground when app is running, why isn't it receiving...
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