registerAPICall method

Future<void> registerAPICall(
  1. String apiKey
)

Registers an API call with the provided apiKey.

This method invokes the native method registerAPI with the API key.

Throws a PlatformException if the registration fails.

apiKey: The API key to register.

Implementation

Future<void> registerAPICall(String apiKey) async {
  if(Platform.isAndroid){
    try {
      final String message =
      await methodChannel.invokeMethod('registerAPI', {"apiKey": apiKey});
      print(message);
    } on PlatformException catch (e) {
      print("Failed to get register API Method: '${e.message}'.");
    }}
  else if(Platform.isIOS){
    try {
      // Sending the clientApiKey to the iOS side via the platform channel
      await methodChannel.invokeMethod('registerAPI', {'apiKey': apiKey});
      print("API registered successfully with apiKey: $apiKey");
    } on PlatformException catch (e) {
      print("Failed to register API: '${e.message}'.");
    }
  }
}