Skip to content
This repository has been archived by the owner on Oct 1, 2021. It is now read-only.

gardun0/flutter_pusher_beams

Repository files navigation

MOVING TO OFFICIAL, DEPRECATED SOON

This plugin is now under development, including all features from native modules, you can follow the progress right here.


Flutter Pusher Beams (Client)

Pub.dev

Unofficial Pusher Beams Flutter client library supported for iOS and Android.

Note: the plugin API have been designed with the same parameters and functions names as the native SDKs

iOS Documentation | Android Documentation

Installation Guide

  • You need a Pusher Beams instance to get an instanceId, you can get one from here

Follow the FlutterFore installation guide from the following packages on your Flutter app as Pusher Beams itself requires FCM to work:

Once the above have been set up, you must include this plugin on your pubspec.yaml:

dependencies:
  pusher_beams: "^0.5.3+3"

Get the instanceId from your Pusher Beams panel and call .start() as soon as possible on your app:

import 'package:pusher_beams/pusher_beams.dart'; // Import the plugin

// Stuff
void main () async {
  // Your app setup
    
  // We start PusherBeams before the app
  await PusherBeams.start('YOUR INSTANCE ID');

  runApp(SomeApp());
}

Once PusherBeams were started you can now start to add, remove or get the interests you need as follows:

import 'package:pusher_beams/pusher_beams.dart'; // Import the plugin

await PusherBeams.addDeviceInterest("hello");
await PusherBeams.removeDeviceInterest("hello");
await PusherBeams.getDeviceInterests();

Notes

  • I decided not to write the function documentation as they were implemented the same as their native libraries, you can read it here.
  • Every function on this Plugin is a Dart Future.
  • Remember this library have been implemented as a Singleton (the native libraries follows this pattern).

Todo

  • Send from flutter serializable AuhtorizationOptions for custom UNAuthorizationOptions.
  • setUserId implementation to add the authentication part
  • Flutter Web support

Developed with ❤️