This topic describes how to integrate Push SDK for Flutter.
Prerequisites
Android Studio or Visual Studio Code is installed.
Environment requirements
Item | Requirement |
Flutter version | Versions from 2.8.0 to 3.27.0, with 2.8.0 recommended |
Dart version | Versions from 2.15.0 to 3.6.0 |
System version |
|
CPU architecture | armeabi-v7a or arm64-v8a |
Development tool |
Procedure
Integrate the SDK.
Choose one of the following methods:
Add dependency
Add the following dependency to the
pubspec.yamlfile of your local project:dependencies: flutter_livepush_plugin: ^x.y.zNoteReplace
x.y.zwith the actual version number of the Push SDK, such as 7.1.0. For the latest version, see Sdk download.Use command-line tool
flutter pub add flutter_livepush_pluginThis command automatically updates your
pubspec.yamlfile.Local Integration
Create a
pluginsdirectory in your project and place the SDK in this directory. Then, add the following dependency to thepubspec.yamlfile:flutter_livepush_plugin: path: "./plugins/flutter_livepush_plugin" // SDK storage pathNoteFor latest SDK version, see Sdk download.
Run the following command to install the dependency.
flutter pub getAdd relevant system permission statements.
Android
Open the ./android/app/src/main/AndroidManifest.xml file and declare the required permissions.
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.RECORD_AUDIO" />iOS
Add the configurations that authorize access to the camera and microphone to the Info.plist file of the project.
<key>NSCameraUsageDescription</key> <string>Authorize access to the camera for video streaming</string> <key>NSMicrophoneUsageDescription</key> <string>Authorize access to the microphone for audio streaming</string>Configure other project settings.
In Android, add the following rules to the obfuscation rule file.
NoteIf obfuscation is enabled for your application, you must configure obfuscation rules. Otherwise, a crash occurs when you use Push SDK. For the latest obfuscation configuration, see the source code of the demo.
-keep class org.webrtc.** { *; } -keep class com.alivc.** { *; } -keep class com.aliyun.** { *; } -keep class com.cicada.** { *; }Configure a license.
For information about how to integrate a license, see Integrate a Push SDK license.
References
For information about the SDK methods, see Push SDK for Flutter API Documentation.
For sample code of the methods, see Use Push SDK for Flutter.