reportOpen method

Future<void> reportOpen(
  1. Map<String, dynamic> data
)

Report a notification open. Reads nexus_campaign_id from the payload (Nexus stamps it on every campaign push) to power open-rate + A/B outcomes. With pushEnabled this is wired for you; call it manually only for BYO setups.

Implementation

Future<void> reportOpen(Map<String, dynamic> data) async {
  // Surface the open (incl. action button + url) to the app.
  final campaignId = data['nexus_campaign_id'];
  onOpened?.call(NexusPushOpen(
    data: data,
    campaignId: campaignId is String ? campaignId : null,
    actionId: data['nexus_action_id']?.toString(),
    actionUrl: data['nexus_action_url']?.toString(),
  ));
  if (campaignId is! String || _token == null) return;
  NexusLog.debug('push.reportOpen — campaign $campaignId');
  await _http.post('/partner/push/opened', {'campaignId': campaignId, 'token': _token});
}