64 lines
1.7 KiB
Dart
64 lines
1.7 KiB
Dart
// import 'package:flutter/material.dart';
|
|
// import 'package:pusher/pusher.dart';
|
|
// import 'package:pusher_channels_flutter/pusher-js/core/channels/channel.dart';
|
|
// import 'package:pusher_channels_flutter/pusher-js/core/connection/protocol/message-types.dart';
|
|
// import 'package:pusher_channels_flutter/pusher-js/core/pusher.dart';
|
|
|
|
// void main() {
|
|
// runApp(Notif());
|
|
// }
|
|
|
|
// class Notif extends StatefulWidget {
|
|
// @override
|
|
// _NotifState createState() => _NotifState();
|
|
// }
|
|
|
|
// class _NotifState extends State<Notif> {
|
|
// final Pusher pusher = Pusher(
|
|
// 'APP_ID',
|
|
// PusherOptions(
|
|
// host: 'api.pusher.com',
|
|
// cluster: 'CLUSTER', // Ganti dengan cluster yang sesuai
|
|
// encrypted: true,
|
|
// auth: PusherAuth('APP_KEY', 'APP_SECRET'),
|
|
// ),
|
|
// enableLogging: true, // Aktifkan ini untuk melihat log Pusher
|
|
// );
|
|
|
|
// @override
|
|
// void initState() {
|
|
// super.initState();
|
|
// pusher.connect();
|
|
// subscribeToChannel();
|
|
// }
|
|
|
|
// void subscribeToChannel() {
|
|
// Channel channel = pusher.subscribe('channel-name'); // Ganti dengan nama channel yang sesuai
|
|
|
|
// channel.bind('event-name', (PusherEvent event) {
|
|
// print('Received event: ${event.data}');
|
|
// // Tambahkan kode untuk menangani notifikasi di sini
|
|
// });
|
|
// }
|
|
|
|
// @override
|
|
// void dispose() {
|
|
// pusher.disconnect();
|
|
// super.dispose();
|
|
// }
|
|
|
|
// @override
|
|
// Widget build(BuildContext context) {
|
|
// return MaterialApp(
|
|
// home: Scaffold(
|
|
// appBar: AppBar(
|
|
// title: Text('Pusher Notifications Example'),
|
|
// ),
|
|
// body: Center(
|
|
// child: Text('Aplikasi Anda di sini'),
|
|
// ),
|
|
// ),
|
|
// );
|
|
// }
|
|
// }
|