supernotification_flutterbeta 0.1.6
supernotification_flutterbeta: ^0.1.6 copied to clipboard
A Flutter SDK for integrating with the SuperNotification Backend. This package provides the necessary tools to interact with the SuperNotification service, enabling Flutter applications to manage noti [...]
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:workmanager/workmanager.dart';
import 'package:http/http.dart' as http;
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:supernotification_flutterbeta/supernotification_flutterbeta.dart';
import 'package:supernotification_flutterbeta/src/WorkManagerFactory.dart'; // WorkManager Factory sınıfını import ettik
//final _supernotificationFlutterbetaPlugin = SupernotificationFlutterbeta();
void main() async {
WidgetsFlutterBinding.ensureInitialized();
/* final tasks = await Workmanager().cancelAll();
print("Tüm WorkManager işleri iptal edildi. Yeniden başlatmayı deneyin.");*/
/* Workmanager().registerOneOffTask(
"uniqueTaskId",
"sendHttpRequest",
initialDelay: Duration(seconds: 10),
);*/
// await _supernotificationFlutterbetaPlugin.initializeNotification();
// await _supernotificationFlutterbetaPlugin.initializeWorkManager();
const reales_url = "https://supernotification.betgosoftware.xyz";
const dev_url = "http://192.168.0.214:8090";
await SuperNotificationFlutterBeta.initialize(dev_url, "676358932d43df3e6c333364", "test2");
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _platformVersion = 'Unknown';
@override
void initState() {
super.initState();
//_supernotificationFlutterbetaPlugin.initialize("http://192.168.0.214:8090","676358932d43df3e6c333364", "test");
initPlatformState();
}
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState() async {
String platformVersion;
// Platform messages may fail, so we use a try/catch PlatformException.
// We also handle the message potentially returning null.
try {
final response =
platformVersion =
await SuperNotificationFlutterBeta.getPlatformVersion() ?? 'Unknown platform version';
} on PlatformException {
platformVersion = 'Failed to get platform version.';
}
// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance.
if (!mounted) return;
setState(() {
_platformVersion = platformVersion;
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Text('Running on: $_platformVersion\n'),
),
),
);
}
}