im making audio player with flutter and i wanna make undraggable notification in which i ll have next, prev, play/pause, add to favorite, change looping mod and dispose the notification actions (last not important). how i can do it?
i use assets_audio_player package but there i can not add all my action and i looked for in flutter_local_notifications package but also found nothing yet
Related
I have developed a flutter app where it has calling feature with Agora SDK. In the latest version of firebase_messaging package, the method onBackgroundMessageHandler is made a separate isolate which will have its own context and memory.
Isolates should be
Top level methods or
Static methods inside the class.
when onBackgroundMessageHandler is made top-level function, the method doesn't get called in killed state in release mode. The solution for release mode issue is being solved as per most of the solutions provided by the flutter community.
The solution is to use #pragma like below
#pragma('vm:entry-point')
Future<void> onBackgroundMessageHandler(RemoteMessage message){}
This #pragma('vm:entry-point') is used to indicate the compiler that this method will be used from native code.
Using #pragma('vm:entry-point') poses an issue of not able to access the navigator context to show the incoming call.
Libraries used to achieve calling feature
Agora SDK for voice calling : agora_rtc_engine
Flutter Incoming Call for calling notification : flutter_incoming_call
GetX for navigation: get
Problems
Adding #pragma('vm:entry-point') does not provide Navigator in killed state to push a new screen.
Not Adding #pragma('vm:entry-point') does not work in the killed state.
I'm using flutter_incoming_call for showing the calling notification where I'm showing "Accept" and "Decline" buttons. Tapping on "Accept" button somehow I'm able to navigate to Incoming call screen but the next time when I'm trying to navigate to any screen without relaunching the app, throws an error as below
You are trying to use contextless navigation without
a GetMaterialApp or Get.key.
If you are testing your app, you can use:
[Get.testMode = true], or if you are running your app on
a physical device or emulator, you must exchange your [MaterialApp]
for a [GetMaterialApp].
I tried replacing this with global key implementation.
GlobalKey<NavigationState> navigatorKey = GlobalKey<NavigationState>();
This gives navigorKey.currentState as null.
I would need the help from Flutter community to resolve this issue of navigating to any screen from killed state in onBackgroundMessageHandler method of firebase.
If there are any other solutions, I'd like to hear them too. Please provide any suggestions.
I am trying to find a way to send keyboard events from my flutter app to a WebView that I have open in app. For example, the WebView has some JS code with an Observer that waits for key events to happen. Any idea how could I do that?
You can use the KeyboardListener class and send the data on the WebView javaScriptChannels property (considering you are using webview_flutter package).
Currently, the only way to close the notification is by pressing the stop button. But I wonder how can I wrap up the notification widget with a swipeable "thing". Can you tell me any package that would work on this or code that I have to wrap up a thing from the audio_service package?
The audio_service package publisher is - ryanheise.com
As a useful tip, the easiest way to search the entire documentation of audio_service to find an answer to some question is to navigate into the audio_service.dart file (which contains the whole plugin), and then search for the word "swipe". You will find this option on AudioServiceConfig:
/// Whether the Android service should switch to a lower priority state when
/// playback is paused allowing the user to swipe away the notification. Note
/// that while in this lower priority state, the operating system will also be
/// able to kill your service at any time to reclaim resources.
final bool androidStopForegroundOnPause;
And then inside the AudioHandler:
/// Handle the notification being swiped away (Android).
Future<void> onNotificationDeleted();
(You may find this easier to search than reading the online HTML documentation.)
What the above means is that you need to pass androidStopForegroundOnPause: true as a parameter to AudioServiceConfig and then if you want to handle any special behaviour other than the default (stop the service) when the user swipes away the notification, you can optionally override onNotificationDeleted in your own audio handler. There is no equivalent for iOS.
Note that it is not possible to swipe away the Android notification while audio is playing, but the option mentioned above will allow you to swipe away the notification from the paused state.
So my project has the different navigation logic based on how user launch my app: by tap the icon laucher or via FCM's notification's tap. The case is I don't know if the FCM's onLaunch callback is gonna be called or not to decide which logic to use. Is there any good approach to this problem?
You can check how your activitiy is started like this (You can use invoke method of flutter to get this result in flutter)
if("android.intent.action.MAIN".equals(getIntent().getAction())){
// By taping the icon launcher
}else{
//By other source
}
I am at a point where I need to detect if any of the hardware buttons was presses when the flutter app is in foreground or when it is open.*
For example, when someone presses a volume or another button (even if it is the power off one) I want to perform some action in my app.
I know that when a flutter app is open and I am looking at the app logs and I tap any hardware button is tapped the lops related to that tap is printed in the logs.
Like when I press Vol down Key Down Tap Detected related logs are printed in logs.
How do can I perform a function when any of the above specified action is performed?
New plugin called Hardware Buttons was released just a few days ago.
It supports volume button events and power button events, which seems like fits your need.
Maybe have a go with this?
You will need find the proper flutter packages to do so.
Any system level call needs to use the platform channel api
https://flutter.io/platform-channels/
Here is the repository
https://pub.dartlang.org/flutter/
Here is an example of a method channel.
https://github.com/flutter/plugins/blob/master/packages/device_info/lib/device_info.dart
Here is an example of a stream listener.
https://github.com/flutter/plugins/tree/master/packages/sensors
The stream listener wasn't really well documented when I tried to grab mic fragments.