Skip to content

3.0.2

Choose a tag to compare

@mb-kyle-k mb-kyle-k released this 15 Oct 01:35

Shoplive SDK for Flutter 3.0.2 is built on Shoplive Android SDK 3.0.2 and iOS SDK 3.0.2.

Important

This is a major rewrite. The 1.x Dart API is removed. To upgrade from 1.x, read Migrating from 1.x before you update your dependencies.

Highlights

  • Three packages. Add only the packages your app needs. All three must use the same version.

    Package Provides
    shoplive_core Shoplive.initialize, user, stream token, logout, conversion events
    shoplive_player ShoplivePlayer live/VOD player (re-exports shoplive_core)
    shoplive_streamer ShopliveStreamer broadcast (re-exports shoplive_core)

    An app that only plays videos adds only shoplive_player. The streamer binaries are then not included in the app.

  • Async API with typed errors. All methods return a Future. Failures throw a PlatformException with a code: INVALID_ARGUMENT, NO_HOST_SCREEN, NOT_RUNNING or SDK_ERROR. In 1.x, some void methods ignored errors.

  • Coupon and custom-action responses. Listen to couponRequests / customWebActionRequests and call request.respond(...). In 1.x, coupon requests got no response. Custom actions are no longer answered with success automatically: if there is no listener, or no respond before the timeout (default 10 s, range 1–120 s), the SDK receives success: false.

  • Configuration. start / setConfiguration merge the given configuration with the current settings. The new getConfiguration returns the current settings.

  • In-app PIP fixes on Android.

    • Playback no longer stops when the player changes from fullscreen to in-app PIP on a default FlutterActivity host. You do not need to change MainActivity.
    • The ClassCastException during the PIP transition is fixed.
  • Streamer. shoplive_streamer is now a separate package (it was part of shoplive_player).

Installation

dependencies:
  shoplive_player: 3.0.2      # player, includes shoplive_core
  # shoplive_streamer: 3.0.2  # broadcast, includes shoplive_core
import 'package:shoplive_player/shoplive_player.dart';

await Shoplive.initialize(const ShopliveConfiguration(accessKey: 'YOUR_ACCESS_KEY'));
await Shoplive.setUser(const ShopliveUser.guest());

final player = ShoplivePlayer.instance;
player.events.listen((event) { /* ShoplivePlayerEvent */ });
await player.start('CAMPAIGN_KEY');

Requirements

Minimum
Flutter / Dart 3.22 / 3.4
Android Gradle Plugin / Gradle / JDK 8.7 / 8.9 / 17
Android minSdk / compileSdk 23 / 36
iOS 15.0 (Xcode with Swift 5.9 or later)

Required setup

Android

  • The plugins get the SDK from https://sdk.shoplive.cloud/maven-repo. If your project declares repositories itself, restrict the cloud.shoplive group to that repository with exclusiveContent. Maven Central has a conflicting shoplive-media3:1.10.1.2. Refer to "Android: Maven repository setup" in the package README.
  • For in-app PIP to continue as system PIP when the app goes to the background, add android:supportsPictureInPicture="true" to your host Activity. If you do not, the player reports PIP_ACTIVITY_NOT_DECLARED.

iOS

  • Set platform :ios, '15.0' in ios/Podfile. During pod install, the plugins download the iOS SDK 3.0.2 XCFrameworks and verify their sha256 checksums. If you run pod install manually, use a UTF-8 locale (for example, LANG=en_US.UTF-8).
  • If you use shoplive_streamer, add NSCameraUsageDescription and NSMicrophoneUsageDescription to Info.plist. If they are missing, iOS terminates the app when the broadcast screen requests the camera.

Streamer

  • Call Shoplive.setStreamToken(token) before ShopliveStreamer.instance.start. Without a token, the server returns no ingest address and the broadcast screen shows a "failed to start" dialog.

Migrating from 1.x

Breaking changes:

  • The 1.x Dart API (ShopLivePlayer, ShopLiveCommon and their data and event classes) is removed. Class names change from ShopLive* to Shoplive*.
  • ShopLiveCommon (setAccessKey, setAuth, setAuthToken, setUser, setUtm*, clearAuth) is replaced by Shoplive.initialize, setUser, setStreamToken, logout and sendConversionEvent. The profile id is now required.
  • The Shortform API is removed. Shortform is not available in SDK 3.x.
  • showPreview is replaced by start with presentationStyle: pip and configuration.type: preview.
  • These APIs have no SDK 3.0.2 equivalent and are removed: closeButtonConfig, hidePreview, the previewClose stream, and the preview options pipRadius, enableSwipeOut and pipMaxSize. setResizeMode now supports only fill and fit.
  • sendDownloadCouponResult / sendCustomActionResult are replaced by respond on the request objects. getSdkVersion() moved to Shoplive.getSdkVersion().
  • Sharing: use configuration.navigation.shareScheme. SDK 3.x has no share handler.

Steps:

  1. Update your code with the migration table in the shoplive_player README.
  2. Run flutter clean once after you upgrade. If you do not, old 1.x iOS build products cause the error "'ShoplivePlayerPlugin' has different definitions in different modules".

Known limitations

  • You cannot reset nullable settings (navigation.shareScheme, android.isVolumeKeyEnabled) to null from Dart.
  • After the Flutter engine is detached and attached again, you cannot control a session that the previous engine left open.
  • The streamer does not expose appearance options or the headless streamer API.

For the full list, refer to the CHANGELOG of each package: shoplive_core · shoplive_player · shoplive_streamer.

Links


Full Changelog: 1.8.14...3.0.2