wipter_sdk 1.8.1 copy "wipter_sdk: ^1.8.1" to clipboard
wipter_sdk: ^1.8.1 copied to clipboard

A Flutter plugin for the Wipter SDK

Wipter SDK for Flutter #

The Wipter SDK Flutter Plugin provides a wrapper for the Wipter SDK Android library, enabling Flutter apps to utilize the WipterSDK’s features, including managing OAuth authentication, state changes, and starting/stopping SDK functionality.

Installation #

  1. Add the following to your pubspec.yaml file:
dependencies:
  wipter_sdk: ^<latest version>   
  1. Then run
flutter pub get

Android #

Ensure your project is using Maven Central ad Jitpack.io are part of your dependencies' repositories. For example, with:

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven {
            url = uri("https://jitpack.io")
        }
    }
}        

Usage #

  1. Import the library
import 'package:wipter_sdk/wipter_sdk.dart';

Initialization #

To use the SDK, you must first call the setup method with the required parameters:

  • clientId: Your OAuth client ID.
  • clientSecret: Your OAuth client secret.
  • autoStart (optional): If true, the SDK starts immediately after setup with default parameters (default is false).

Example:

await WipterSDK.setup(
  clientId: 'your-client-id',
  clientSecret: 'your-client-secret',
  autoStart: true,
);

Starting the SDK #

The start method initializes the SDK and establishes the necessary WebSocket connections.

Parameters:

  • mode: Determines how the SDK operates:

    • 'FOREGROUND_ONLY' (default): Connection is established only when the app is in the foreground.
    • 'ALWAYS': Connection is maintained while the app is alive (foreground or background).
  • networks: Specifies the network type for connection:

    • 'ONLY_UNMETERED_NETWORKS' (default): Uses Wi-Fi or unmetered connections only.
    • 'ALL_NETWORKS': Allows metered connections like cellular networks.

Example:

await WipterSDK.start(
  mode: 'ALWAYS',
  networks: 'ALL_NETWORKS',
);

Stopping the SDK #

The stop method stops the SDK and disconnects the WebSocket. Once stopped, the SDK cannot resume automatically.

await WipterSDK.stop();

Retrieving Device and Session IDs #

The getDeviceId and getSessionId methods provide unique identifiers associated with the device and the current session, respectively.

String? deviceId = await WipterSDK.getDeviceId();
String? sessionId = await WipterSDK.getSessionId();

Listening to SDK State Changes #

The SDK emits state changes through a stream. Use the stateStream getter to listen to these changes.

Possible states:

  • Uninitialized: SDK is not yet initialized.
  • Initializing: SDK is initializing.
  • Initialized: SDK is initialized but not yet connected.
  • Authenticating: SDK is authenticating.
  • Authenticated: SDK has a valid session.
  • Connecting: SDK is establishing a WebSocket connection.
  • Running: SDK is fully connected and operational.
  • Error: An error occurred in the SDK.
  • Stopped: SDK is stopped or the connection is disconnected.
  • Paused: SDK is paused due to unmet conditions (e.g., network availability).
WipterSDK.stateStream.listen(
  (state) {
    print('SDK State Changed: $state');
  },
  onError: (error) {
    print('Error: $error');
  },
);

Requirements #

Android #

  • Minimum API Level: 24 (Android 7.0)
  • Java Version: 17 or newer

Flutter #

  • Flutter SDK: 3.10 or newer
0
likes
120
points
77
downloads

Publisher

verified publisherwipter.com

Weekly Downloads

A Flutter plugin for the Wipter SDK

Homepage

Documentation

API reference

License

unknown (license)

Dependencies

flutter, permission_handler, plugin_platform_interface

More

Packages that depend on wipter_sdk