registerHeadlessDispatcher method
Registering callback raw handle for calling dart callback in background
Implementation
@override
Future registerHeadlessDispatcher(Function dispatcher) async {
print("$_METHOD_CHANNEL_LOG_TAG registerHeadlessDispatcher: called");
if (!_bgHandlerInitialized) {
//Check if the dispatcher raw handle is valid
final callback = PluginUtilities.getCallbackHandle(dispatcher);
assert(callback != null,
"The dispatcher needs to be a static function or a top level function to be accessible as a Flutter entry point.");
if (callback != null) {
final CallbackHandle internalChannelCallbackHandle =
PluginUtilities.getCallbackHandle(_pluginInternalChannel)!;
await _methodChannel.invokeMethod<void>('registerHeadlessDispatcher', {
"appCallbackHandle": callback.toRawHandle(),
"internalChannelHandle": internalChannelCallbackHandle.toRawHandle(),
"internalEntryPoint": "_pluginInternalChannel"
});
_bgHandlerInitialized = true;
}
}
}