iot_notification 0.8.12
iot_notification: ^0.8.12 copied to clipboard
A new Flutter plugin.
example/lib/main.dart
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:iot_notification/iot_notification.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Iot Notification Example'),
),
body: Center(
child: Column(children: <Widget>[
ElevatedButton(
child: Text("Start Service"),
onPressed: () {
IotNotification.startService(
userAccessToken : "",
userRefreshToken : "",
devAccessToken : "",
devRefreshToken : "",
mqttClientIdentifier : "",
brokerAddress : "",
brokerProtocol : "ssl",
brokerPort : 8883,
authServer : "",
apiServer : "",
rootCA : ""
);
}),
ElevatedButton(
child: Text("Add Device"),
onPressed: () async {
IotNotification.addDevice(json.encode({
"id": "1213213",
"sn": "INISN",
"name": "DEVIA ABAL",
"state": "ready",
"desc": "UUN",
"developer_id": "1",
"options": null
}));
}),
ElevatedButton(
child: Text("Scan Barcode"),
onPressed: () async {
String result = await IotNotification.scan();
print("QR CODE $result");
}),
ElevatedButton(
child: Text("Get Keys"),
onPressed: () async {
List<String> keys = await IotNotification.getKeys();
print(keys[0]);
print(keys[1]);
}),
ElevatedButton(
child: Text("Stop service"),
onPressed: () async {
IotNotification.stopService();
}),
ElevatedButton(
child: Text("Cancel alarm"),
onPressed: () async {
IotNotification.cancelAlarm();
}),
ElevatedButton(
child: Text("Request Alarm Permission"),
onPressed: () async {
IotNotification.requestAlarmPermission();
}),
ElevatedButton(
child: Text("IgnoreBatteryOptimization"),
onPressed: () async {
IotNotification.ignoreBatteryOptimization();
}),
ElevatedButton(
child: Text("OpenBatterySettings"),
onPressed: () async {
IotNotification.openBatterySettings();
}),
ElevatedButton(
child: Text("Request Post notification"),
onPressed: () async {
IotNotification.requestPostNotificationsPermission();
}),
ElevatedButton(
child: Text("Test Logger"),
onPressed: () async {
IotNotification.initLogger("dev", "debug", "username",
"password", "server", "sam-iot", "dev");
}),
ElevatedButton(
child: Text("OpenFileManager"),
onPressed: () {
IotNotification.openFileManager();
})
])),
),
);
}
}