openZaloOA static method

Future<bool> openZaloOA(
  1. String oaId, {
  2. BuildContext? context,
})

Zalo OA (Official Account) - Mở trang Zalo OA

Implementation

static Future<bool> openZaloOA(String oaId, {BuildContext? context}) async {
  try {
    // Zalo OA deep link
    final deepLinkUri = Uri.parse('zalo://oa/$oaId');
    if (await canLaunchUrl(deepLinkUri)) {
      await launchUrl(deepLinkUri, mode: LaunchMode.externalApplication);
      return true;
    }

    // Fallback to web
    final webUri = Uri.parse('https://zalo.me/$oaId');
    if (await canLaunchUrl(webUri)) {
      await launchUrl(webUri, mode: LaunchMode.externalApplication);
      return true;
    }

    if (context != null && context.mounted) {
      _showError(context, 'Không thể mở Zalo OA');
    }
    return false;
  } catch (e) {
    if (context != null && context.mounted) {
      _showError(context, 'Lỗi: $e');
    }
    return false;
  }
}