SingularConfig constructor

SingularConfig(
  1. String _apiKey,
  2. String _secretKey
)

Implementation

SingularConfig(this._apiKey, this._secretKey) {
  _channel.setMethodCallHandler((MethodCall call) async {
    try {
      switch (call.method) {
        case 'singularLinksHandlerName':
          if (singularLinksHandler != null) {
            singularLinksHandler!(SingularLinkParams.fromMap(call.arguments));
          }
          break;
        case 'shortLinkCallbackName':
          if (shortLinkCallback != null){
            shortLinkCallback?.call(call.arguments['data'], call.arguments['error']);
            shortLinkCallback = null;
          }
          break;
        case 'conversionValueUpdatedCallbackName':
          if (conversionValueUpdatedCallback != null) {
            conversionValueUpdatedCallback!(call.arguments);
          }
          break;
        case 'conversionValuesUpdatedCallbackName':
          if (conversionValuesUpdatedCallback != null) {
            conversionValuesUpdatedCallback!(call.arguments['conversionValue'], call.arguments['coarse'], call.arguments['lock']);
          }
          break;
        case 'deviceAttributionCallbackName':
          if (deviceAttributionCallback != null) {
            Map<String, dynamic>? decodedData = jsonDecode(call.arguments);
            if (decodedData != null) {
              deviceAttributionCallback!(decodedData);
            }
          }
          break;
        case 'sdidReceivedCallbackName':
          if(sdidReceivedCallback != null) {
            sdidReceivedCallback!(call.arguments);
          }
          break;
        case 'didSetSdidCallbackName':
          if(didSetSdidCallback != null) {
            didSetSdidCallback!(call.arguments);
          }
          break;
        default:
          print('Received unknown native method: ${call.method}');
          break;
      }
    } catch (e) {
      print(e.toString());
    }
  });
}