Integrating WiFi SDK in Flutter apps

This article is intended to illustrate, at a high level, the process required to create a Flutter plugin for the Cloud4Wi SDK. It is not necessarily exhaustive in code examples. A prerequisite for this project is to be a knowledgeable Flutter developer.

The guide is divided into two parts. The first part focuses on creating a Flutter plugin from the two SDKs (Android and iOS), using the registerUser method as an example implementation. The second part demonstrates how to integrate the newly created plugin into a sample Flutter app, properly configuring both projects to initialize the SDKs.

Prerequisites

  • Flutter Setup: Ensure you have Flutter installed and configured on your development machine.

  • Development Knowledge:

    • Proficiency in Flutter and Dart.

    • Familiarity with native iOS (Swift/Objective-C) and Android (Kotlin/Java) development.

  • Cloud4Wi SDK Access:

    • Obtain the Cloud4Wi SDK for both iOS and Android.

    • Acquire necessary API keys or credentials required by the SDK.

  • Development Tools:

    • Xcode for iOS development.

    • Android Studio for Android development.


Table of Contents

  1. Creating the Flutter Plugin

  2. Adding Native SDK Dependencies

    • iOS Dependency Setup

    • Android Dependency Setup

  3. Implementing Native Code

    • iOS Implementation

    • Android Implementation

  4. Creating the Dart Interface

  5. Using the Plugin in Your Flutter App

  6. Testing the Integration

  7. Conclusion


Creating the Flutter Plugin

To integrate the Cloud4Wi SDK, you'll create a Flutter plugin that bridges Flutter and the native SDKs.

  1. Create the Plugin:

  2. Navigate to the Plugin Directory:


Adding Native SDK Dependencies

iOS Dependency Setup

  1. Modify Podspec File:

    • Open ios/flutter_cloud4wi_sdk.podspec.

    • Add the Cloud4Wi SDK dependency:

Android Dependency Setup

  1. Modify build.gradle:

    • Open android/build.gradle and ensure the repositories include the Cloud4Wi SDK repository if required.

  2. Add SDK Dependency:

    • In android/src/main/build.gradle, add the SDK dependency:


Implementing Native Code

iOS Implementation

  1. Open iOS Module in Xcode:

    • Navigate to ios/ directory and open the .xcworkspace file.

  2. Import Cloud4Wi SDK:

    • In your plugin's main Swift file (e.g., SwiftFlutterCloud4wiSdkPlugin.swift), add:

  3. Implement createCustomer Method:

Android Implementation

  1. Open Android Module in Android Studio:

    • Navigate to android/ directory and open it in Android Studio.

  2. Import Cloud4Wi SDK:

    • In your plugin's main Kotlin file (e.g., FlutterCloud4wiSdkPlugin.kt), add:

  3. Implement createCustomer Method:


Creating the Dart Interface

Create a Dart interface that exposes the native methods to Flutter code.


Using the Plugin in Your Flutter App

  1. Add Plugin Dependency:

    • In your app's pubspec.yaml:

  2. In app folder call to fetch dependencies listed :

  3. Configure single project (ios and Android):

  4. Import and Use the Plugin:


Testing the Integration

  1. Run on iOS Simulator or Device:

    • Ensure that all capabilities and permissions are correctly set.

    • Monitor the Xcode console for any runtime errors.

  2. Run on Android Emulator or Device:

    • Check that all permissions are granted.

    • Use adb logcat to view logs and debug issues.

  3. Validate createCustomer Functionality:

    • Verify that customers are being created successfully.

    • Handle any errors gracefully.

For more detailed information on SDK features and methods, please refer to the official Cloud4Wi SDK documentation:

Useful references:

Last updated

Was this helpful?