NativeScript / NativeScript/plugins

[@nativescript/local-notifications] Android - Message received callback fires multiple times

Open
#341 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
206
Forks
123
Avg merge
2d 1h
Merged PRs (30d)
1

Description

Android version: 11

nativescript CLI: 8.2.3
@nativescript/android: 8.2.2
@nativescript/local-notifications: 6.0.0

When I tap a local notification, the onReceived function is called and all data is present.

LocalNotifications.addOnMessageReceivedCallback((message) => {
    // message: { id: 6471, title: 'TITLE', body: `BODY`, payload: {...}, badge: 1, ...}
  });

However, if I open to the app switcher and return to my app, the function is called again but the data object is almost empty. Every time I switch back to the app the callback fires.

{ event: 'default', foreground: true }

I have not tested yet on iOS or different Android versions.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue on Android 11 with @nativescript/android 8.2.2 and @nativescript/local-notifications 6.0.0. Start by tracing addOnMessageReceivedCallback when returning from the app switcher; done means the callback fires for the notification tap but not for subsequent app-switcher returns, while preserving the notification data.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, javascript, typescript
Domain
mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.