pushbots_flutter 1.0.0-beta2
pushbots_flutter: ^1.0.0-beta2 copied to clipboard
PushBots SDK, help you manage push notifications easily and effectivly.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:pushbots_flutter/pushbots_flutter.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String pbInitState = 'PushBots did not initialized yet...';
String pbRegisterInfo = 'PushBots Register Status';
bool switchState = true;
@override
void initState() {
super.initState();
initPushBots();
PushbotsFlutter.setTags(["tag1", "tag2"]);
PushbotsFlutter.removeTags(["tag1"]);
PushbotsFlutter.shareLocation(true);
PushbotsFlutter.listenForNotificationOpen().stream.listen((onData) {
print("Main Dart opened: " + onData.toString());
});
PushbotsFlutter.listenForNotificationReceive().stream.listen((onData) {
print("Main Dart recieved: " + onData.toString());
});
}
Future<void> initPushBots() async {
String initStatue;
try {
initStatue = await PushbotsFlutter.initialize("5e145ec41f0f854fca1e2b54");
} on Exception {
initStatue = 'Failed to get initialize push-bots.';
}
setState(() {
pbInitState = initStatue;
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin PushBots app'),
),
body: Center(
child: new Column(
children: <Widget>[
Text('$pbInitState\n'),
Switch(
value: switchState,
onChanged: (val) => setState(() {
switchState = val;
PushbotsFlutter.toggleNotifications(switchState);
}),
),
Text('$pbRegisterInfo\n'),
],
),
),
),
);
}
}