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
Creating the Flutter Plugin
Adding Native SDK Dependencies
iOS Dependency Setup
Android Dependency Setup
Implementing Native Code
iOS Implementation
Android Implementation
Creating the Dart Interface
Using the Plugin in Your Flutter App
Testing the Integration
Conclusion
Creating the Flutter Plugin
To integrate the Cloud4Wi SDK, you'll create a Flutter plugin that bridges Flutter and the native SDKs.
Create the Plugin:
Navigate to the Plugin Directory:
Adding Native SDK Dependencies
iOS Dependency Setup
Modify Podspec File:
Open
ios/flutter_cloud4wi_sdk.podspec
.Add the Cloud4Wi SDK dependency:
Android Dependency Setup
Modify build.gradle:
Open
android/build.gradle
and ensure the repositories include the Cloud4Wi SDK repository if required.
Add SDK Dependency:
In
android/src/main/build.gradle
, add the SDK dependency:
Implementing Native Code
iOS Implementation
Open iOS Module in Xcode:
Navigate to
ios/
directory and open the.xcworkspace
file.
Import Cloud4Wi SDK:
In your plugin's main Swift file (e.g.,
SwiftFlutterCloud4wiSdkPlugin.swift
), add:
Implement
createCustomer
Method:
Android Implementation
Open Android Module in Android Studio:
Navigate to
android/
directory and open it in Android Studio.
Import Cloud4Wi SDK:
In your plugin's main Kotlin file (e.g.,
FlutterCloud4wiSdkPlugin.kt
), add:
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
Add Plugin Dependency:
In your app's
pubspec.yaml
:
In app folder call to fetch dependencies listed :
Configure single project (ios and Android):
iOS: Configuration and Required Capabilities
Android: Configuration and Required permissions
Import and Use the Plugin:
Testing the Integration
Run on iOS Simulator or Device:
Ensure that all capabilities and permissions are correctly set.
Monitor the Xcode console for any runtime errors.
Run on Android Emulator or Device:
Check that all permissions are granted.
Use
adb logcat
to view logs and debug issues.
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:
iOS SDK Documentation: Cloud4Wi iOS SDK
Android SDK Documentation: Cloud4Wi Android SDK
Useful references:
Last updated