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

outdated

Flutter Mindbox SDK.

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

Flutter Mindbox plugin is in beta.

Features #

  • Receive and show push notification in both mobile platforms.
  • Receive push notification data(links) in Flutter.

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 `mindbox.dart`
import 'package:mindbox/mindbox.dart';

void main() {
   WidgetsFlutterBinding.ensureInitialized();
   // Initialization configuration
   final config = Configuration(
           domain: "your domain",
           endpointIos: "iOs endpoint",
           endpointAndroid: "Android endpoint",
           subscribeCustomerIfCreated: true);
   // Initialization
   Mindbox.instance.init(configuration: config);

   runApp(MyApp());
}

Handling push click #

Mindbox.instance.onPushClickReceived((link) {
  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) {
  setState(() {
    _deviceUUID = uuid;
  });
});

Getting APNS/FMS token #

Mindbox.instance.getDeviceUUID((uuid) {
  setState(() {
    _deviceUUID = uuid;
  });
});