handleNotification method
- Map<
Object?, Object?> data, { - BuildContext? context,
Opens the conversation a Hatang notification points at. Returns false
for foreign payloads. Without context the navigatorKey is used; when
the SDK is not ready yet (cold start) the intent is parked until it is.
Returns as soon as the chat is pushed (or parked), not when it closes, so awaiting it in app start-up code never blocks.
Implementation
Future<bool> handleNotification(Map<Object?, Object?> data, {BuildContext? context}) async {
if (!isHatangPayload(data)) return false;
final id = conversationIdOf(data);
if (context != null && context.mounted) {
unawaited(open(context, conversationId: id));
return true;
}
if (engine.state.phase == ChatPhase.ready && _openWithNavigator(conversationId: id)) return true;
_parkedConversation = id ?? '';
if (!engine.isStarted) unawaited(engine.start());
return true;
}