bubbl_flutter_sdk 5.0.0-alpha.1 copy "bubbl_flutter_sdk: ^5.0.0-alpha.1" to clipboard
bubbl_flutter_sdk: ^5.0.0-alpha.1 copied to clipboard

Bubbl for Flutter - geofenced and scheduled notifications, surveys and analytics, bridging the native Bubbl SDKs.

example/example.md

Bubbl for Flutter: example #

Start Bubbl at launch, ask for permissions, and hear what it does:

import 'package:bubbl_flutter_sdk/bubbl_flutter_sdk.dart';
import 'package:flutter/material.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Bubbl.start(
    apiKey: 'YOUR_SDK_API_KEY',
    options: const BubblOptions(baseUrl: 'https://…'),
  );
  runApp(const MaterialApp(home: Home()));
}

class Home extends StatefulWidget {
  const Home({super.key});

  @override
  State<Home> createState() => _HomeState();
}

class _HomeState extends State<Home> {
  final List<String> _log = <String>[];

  @override
  void initState() {
    super.initState();
    Bubbl.addEventListener((event) {
      final line = switch (event) {
        BubblNotificationEvent(:final message) => '${event.runtimeType}: ${message.headline}',
        BubblGeofenceEntered(:final locationId) => 'Entered $locationId',
        _ => '${event.runtimeType}', // New kinds of event come in minor versions.
      };
      setState(() => _log.insert(0, line));
    });
  }

  Future<void> _allow() async {
    if (!await Bubbl.isSupported) return; // Older Android or iOS: Bubbl does nothing there.
    await Bubbl.permissions.requestNotifications();
    await Bubbl.permissions.requestLocation(always: true);
  }

  @override
  Widget build(BuildContext context) => Scaffold(
        appBar: AppBar(title: const Text('Bubbl')),
        body: ListView(
          children: [
            FilledButton(onPressed: _allow, child: const Text('Allow notifications and location')),
            for (final line in _log) ListTile(title: Text(line)),
          ],
        ),
      );
}

Draw notifications yourself while the app is open (Bubbl still shows them in the background):

await Bubbl.setNotificationListener((message) async {
  // Show your own card, then report what happens:
  await Bubbl.reportDisplayed(message);
  return true; // false: Bubbl shows it
});

See the README for the install steps, consent, surveys, credential start and diagnostics.

0
likes
160
points
211
downloads

Documentation

API reference

Publisher

verified publisherbubbl.tech

Weekly Downloads

Bubbl for Flutter - geofenced and scheduled notifications, surveys and analytics, bridging the native Bubbl SDKs.

Homepage

Topics

#notifications #geofencing #location #push-notifications #analytics

License

Apache-2.0 (license)

Dependencies

flutter

More

Packages that depend on bubbl_flutter_sdk

Packages that implement bubbl_flutter_sdk