iot_notification 0.8.69 copy "iot_notification: ^0.8.69" to clipboard
iot_notification: ^0.8.69 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: SingleChildScrollView(
          child: Center(
              child: Column(children: <Widget>[
            ElevatedButton(
                child: Text("Start Service"),
                onPressed: () {
                  IotNotification.startService(
                      userAccessToken : "",
                      userRefreshToken : "",
                      devAccessToken : "",
                      devRefreshToken : "",
                      mqttClientIdentifier : "skdjskdjskdjskdjskdjskdjs-iniadalahidekuuntuk",
                      brokerAddress : "iot.samelement.com",
                      brokerProtocol : "ssl",
                      brokerPort : 8883,
                      authServer : "https://iot.samelement.com",
					            apiServer : "https://iot.samelement.com",
                      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();
                }),
            ElevatedButton(
                child: Text("Insert Event"),
                onPressed: () {
                  IotNotification.insertEvent(sender: "System", title: "Random Title", description: "This is a description");
                }),
            ElevatedButton(
                child: Text("Get All Events"),
                onPressed: () async {
                  List<Events> events = await IotNotification.getAllEvents();
                  events.forEach((element) {
                    print("Nilainya ${element.id} ${element.createdAt.toString()}");
                  });
                }),
                ElevatedButton(
                  child: Text("Clear Events"),
                  onPressed: () {
                    IotNotification.clearEvents();
                  }
                ),
                ElevatedButton(
                    child: Text("Show full screen intents"),
                    onPressed: () {
                      IotNotification.showFullScreenIntent();
                    }
                ),
              ])),
        ),
      ),
    );
  }
}
0
likes
0
points
35
downloads

Publisher

unverified uploader

Weekly Downloads

A new Flutter plugin.

Homepage

License

unknown (license)

Dependencies

flutter

More

Packages that depend on iot_notification

Packages that implement iot_notification