Flutter-AssetsAudioPlayer
Flutter-AssetsAudioPlayer copied to clipboard
Throw error when using with plugin firebase_messaging
Platform : Android
I use assets_audio_player: ^3.0.3+2 in my project with firebase_messaging: ^9.1.1. That all ok but when open application by click on notification message from firebase this throw:
MissingPluginException(No implementation found for method open on channel assets_audio_player)
I am facing the same issue also, anyone has got any sollution ?
I had remove this package and use just_audio in my project. assets_audio_player response is too slow :(
I had remove this package and use just_audio in my project. assets_audio_player response is too slow :(
Did you manage to get just_audio to do what you want? I want to play a sound repeatedly when receiving a push notification, and stop it when the user opens the app, I can play the file when receiving a push notification, but couldn't stop it as the firebase message onBackgroundMessage is in an isolate mode, did you had any success?
Nope @Ted-chiptech I just got issue when handle onBackgroundMessage with this plugin. i don't know why but i've remove it 👯
Replacing this package with some other package shouldn't be a reason of closing this issue. In our Sentry logs we also started to see the same exception.
@ulusoyca reopened.
I faced same Issue . could you please advise me . To solve this Problem . Thank You
https://stackoverflow.com/questions/69522573/missingpluginexception-when-using-a-plugins-with-alarm-manager-call-back
I faced same Issue . could you please advise me . To solve this Problem . Thank You
https://stackoverflow.com/questions/69522573/missingpluginexception-when-using-a-plugins-with-alarm-manager-call-back
I use the audio_service package instead, it does the trick.
It seems like I'm facing the same issue: MissingPluginException after the app was started from click on notification :/
Did anyone make any progress there?
Ok, I have a hunch now:
When we're using push messages, FirebaseMessages spins up a new isolate (think: it's own little Dart app) to handle the incoming message.
If the app was not running at that point, it is started, and Firebase's isolate is the first Dart engine to exist. Now, when Flutter starts, it initializes all the plugins, including assets_audio_player
. Initialization happens by calling onAttachedToEngine
on all plugins (that's done by the auto-generated GeneratedPluginRegistrant.java
class). This seems to be done for all Isolates, Firebase's and Flutter's main. Isolates share the same Android process, though.
And here comes the problem:
In AssetsAudioPlayerPlugin.kt
the first line of onAttachedToEngine
reads like this:
if(instance != null)return // bug fix
So, my guess is:
- a push comes in
- Firebase spins up a new Isolate
- In this isolate, plugins are initialized
- the app comes to foreground, running in its main isolate
- plugins are initialized again for the main isolate
- this time, though, assets_audio_player does NOT register its
MethodCallHandler
as there is already an instance running - when we access anything offered by the plugin, it crashes as no MethodCallHandler is registered in Flutter's main isolate.
At least, that's my understanding so far.
@florent37 Does this make sense to you? Can you remember why the if(instance != null)return // bug fix
was introduced in the first place?
Any news?
It got added here - https://github.com/florent37/Flutter-AssetsAudioPlayer/commit/bb106b635a257d107da9dfccf5adaef58ff53cf2
any idea @kalismeras61 ?