MaikuB / flutter_local_notifications

A Flutter plugin for displaying local notifications on Android, iOS, macOS and Linux
2.47k stars 1.4k forks source link

[iOS] Custom Audio Stops Playing When Notification Moves to Background #2473

Open ShinasNajeerKoya opened 1 week ago

ShinasNajeerKoya commented 1 week ago

Summary

I am encountering an issue with scheduled notifications using a custom audio file in an iOS application. The audio playback ceases prematurely when the notification popup moves to the background. This behavior is consistent across various app states: foreground, background, and terminated. The issue is not present on Android, where the custom audio plays as expected.


Details

Expected Behavior

The custom audio file (30 seconds in length, .aiff format) should play for its full duration, regardless of the app state, when a scheduled notification is triggered.


Observed Behavior

  1. The custom audio begins to play when the scheduled notification is triggered.
  2. The audio stops playing as soon as the notification popup moves to the background (approximately 2 seconds after triggering).
  3. This behavior is observed under the following conditions:
    • App is in the foreground.
    • App is in the background.
    • App is terminated (killed).

Environment

Platform: iOS

Custom Audio File Details : .aiff format, 30 seconds length.

Android Behavior : Functions as expected; the custom audio plays in full.


Steps Taken

  1. Ensured all necessary permissions are included, including for background tasks and isolates, as specified in the documentation.
  2. Tested notifications across all app states.
  3. Verified that the issue is specific to iOS.

Potential Cause

The issue might be related to limitations or missing configurations for background task execution or audio playback in iOS notifications.


Request for Assistance

Please confirm if additional permissions, configurations, or code adjustments are required to ensure the custom audio file continues playing in the background once the notification popup moves out of view. Any guidance or documentation references would be greatly appreciated.

Thank you for your assistance.

Levi-Lesches commented 1 week ago

Does this help?

https://forums.developer.apple.com/forums/thread/66925

ShinasNajeerKoya commented 1 week ago

Hello Levi,

Yes, it helped me debug the issue.

I will be disabling the banner, and after doing so, it will remain at the top for 30 seconds, even if the user is actively using the phone. Instead of showing the banner, I will disable it to achieve this behavior.