MaikuB / MaikuB/flutter_local_notifications
[IOS] Notification not shown when the app is in foreground state
Nobody has claimed this yet.
- Dominant language
- Dart
- Stars
- 2.7k
- Forks
- 1.6k
- Avg merge
- 4d 8h
- Merged PRs (30d)
- 4
Description
**Describe the bug**
Notification did not shown when the app is in foreground state on IOS
**To Reproduce**
Here is the code i use, i am setting all present option to true, but the notification did not show up. it's only showing up when the app is minimized.
```dart
await flutterLocalNotificationsPlugin.show(
99,
'title'
'notification body',
NotificationDetails(
android: AndroidNotificationDetails(),
iOS: DarwinNotificationDetails(
sound: "adzan.aiff",
interruptionLevel: InterruptionLevel.timeSensitive,
presentSound: true,
presentList: true,
presentAlert: true,
presentBadge: true,
presentBanner: true,
)
),
);
```
**Expected behavior**
As stated on readme, default behavior for IOS is to show notification even on foreground. But even after setting the presentation option to true it didn't show up.
> For iOS 10+, use the presentation options to control the behaviour for when a notification is triggered while the app is in the foreground. The default settings of the plugin will configure these such that a notification will be displayed when the app is in the foreground.
**Sample code to reproduce the problem**
```dart
/// initialization part
final InitializationSettings initializationSettings = InitializationSettings(,
iOS: DarwinInitializationSettings(
defaultPresentAlert: true,
defaultPresentBadge: true,
defaultPresentBanner: true,
defaultPresentSound: true,
onDidReceiveLocalNotification: (int id, String? title, String? body, String? payload){
print([id, title, body, payload]);
},
defaultPresentList: true
)
);
await flutterLocalNotificationsPlugin.initialize(
initializationSettings,
onDidReceiveNotificationResponse: (response){
print(["onDidReceiveNotificationResponse", response.actionId]);
},
onDidReceiveBackgroundNotificationResponse: notificationTapBackground,
);
/// Calling notification part
await flutterLocalNotificationsPlugin.show(
99,
'title'
'notification body',
NotificationDetails(
android: AndroidNotificationDetails(),
iOS: DarwinNotificationDetails(
sound: "adzan.aiff",
interruptionLevel: InterruptionLevel.timeSensitive,
presentSound: true,
presentList: true,
presentAlert: true,
presentBadge: true,
presentBanner: true,
)
),
);
```
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the README's iOS foreground-notification guidance and the example app, then reproduce the supplied initialization and show sequence on iOS. Compare the default presentation settings with the explicit DarwinNotificationDetails options; done means the notification is displayed while the app is foregrounded as documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart, flutter
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100