mindbox 2.0.0 copy "mindbox: ^2.0.0" to clipboard
mindbox: ^2.0.0 copied to clipboard

outdated

Flutter Mindbox SDK. Plugin wrapper over of Mindbox iOS/Android SDK.

Pub Version

This plugin is a wrapper over the native Mindbox(iOS, Android) libraries that allows to receive and handle push notifications.

Features #

  • Receive and show push notification in both mobile platforms.
  • Receive push notification data(link, payload) in Flutter.
  • Execute sync/async operations.

Getting started #

This plugin depends on the configuration of push notifications on native platforms. It's necessary to follow the steps specified in the guide:

Usage #

Initialization #

import 'package:mindbox/mindbox.dart';

void main() {
   WidgetsFlutterBinding.ensureInitialized();

   final config = Configuration(
     domain: "your domain",
     endpointIos: "iOs endpoint",
     endpointAndroid: "Android endpoint",
     subscribeCustomerIfCreated: true,
   );
 
   Mindbox.instance.init(configuration: config);

   runApp(MyApp());
}

Handling push click #

Mindbox.instance.onPushClickReceived((link, payload) {
  print(payload);
  switch (link) {
    case 'mindbox.cloud':
      Navigator.push(context, MaterialPageRoute(builder: (context) => ContentPage()));
      break;
    case 'mindbox.cloud/user':
      Navigator.push(context, MaterialPageRoute(builder: (context) => ProfilePage()));
      break;
    default:
      Navigator.push(context, MaterialPageRoute(builder: (context) => HomePage()));
  }
});

Getting device UUID #

Mindbox.instance.getDeviceUUID((uuid) => print(uuid));

Getting APNS/FMS/HMS token #

Mindbox.instance.getToken((token) => print(token));

Execute async operation #

Mindbox.instance.executeAsyncOperation(
  operationSystemName: 'operationName',
  operationBody: {'example': 'body'},
);

Execute sync operation #

Mindbox.instance.executeSyncOperation(
  operationSystemName: 'operationName',
  operationBody: {'example': 'body'},
  onSuccess: (String response) {
    jsonDecode(response);
  },
  onError: (MindboxError error){
    if (error is MindboxProtocolError) {
      print(error.code);
    }
    print(error.message);
    jsonDecode(error.data);
  },
);
11
likes
0
pub points
89%
popularity

Publisher

verified publishermindbox.ru

Flutter Mindbox SDK. Plugin wrapper over of Mindbox iOS/Android SDK.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, mindbox_android, mindbox_ios, mindbox_platform_interface

More

Packages that depend on mindbox