boot method

  1. @override
Future<bool?> boot(
  1. Map<String, dynamic> config
)
override

Implementation

@override
Future<bool?> boot(Map<String, dynamic> config) async {
  for (final option in ['channelButtonOption', 'bubbleOption']) {
    if (config[option] != null) {
      throw UnsupportedError('$option is only supported on Android and iOS.');
    }
  }
  final profile = <String, dynamic>{
    if (config['email'] != null) 'email': config['email'],
    if (config['mobileNumber'] != null)
      'mobileNumber': config['mobileNumber'],
    if (config['name'] != null) 'name': config['name'],
    if (config['avatarUrl'] != null) 'avatarUrl': config['avatarUrl'],
    if (config['customAttributes'] != null) ...config['customAttributes'],
  };
  final Map<String, dynamic> bootOption = {
    'pluginKey': config['pluginKey'],
    'memberId': config['memberId'],
    'customLauncherSelector': config['customLauncherSelector'],
    'hideChannelButtonOnBoot': config['hideChannelButtonOnBoot'],
    'zIndex': config['zIndex'],
    'language': config['language'],
    'trackDefaultEvent': config['trackDefaultEvent'],
    'trackUtmSource': config['trackUtmSource'],
    if (profile.isNotEmpty) 'profile': profile,
    'unsubscribeEmail': config['unsubscribeEmail'],
    'unsubscribeTexting': config['unsubscribeTexting'],
    'memberHash': config['memberHash'],
    'hidePopup': config['hidePopup'],
    'appearance': config['appearance'],
  }..removeWhere((key, value) => value == null);
  return _runWithCallback((callback) {
    channel_talk_service.boot(
      'boot',
      bootOption.jsify(),
      callback,
    );
  });
}