- Android: MainActivity, AppLifecycleTracker, Firebase Messaging Service - Android: Notification handlers (dismiss, reply, receipt delivery) - Android: Custom push notification helper and database support - Android: Drawable resources for notification actions - Android: Mipmap resources with foreground/background/round icons - iOS: Push notification service support - Flutter: Push notification background and foreground services - Web/Windows: Generated plugin registrant updates - Config: Added google-services.json for Firebase
81 lines
2.4 KiB
Dart
81 lines
2.4 KiB
Dart
import 'package:firebase_core/firebase_core.dart';
|
|
import 'package:firebase_messaging/firebase_messaging.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'services/push_notification_background.dart';
|
|
import 'services/push_notification_service.dart';
|
|
|
|
final _navigatorKey = GlobalKey<NavigatorState>();
|
|
|
|
void main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
await Firebase.initializeApp();
|
|
|
|
FirebaseMessaging.onBackgroundMessage(firebaseMessagingBackgroundHandler);
|
|
|
|
final pushService = PushNotificationService();
|
|
pushService.init();
|
|
|
|
runApp(MyApp(pushService: pushService));
|
|
}
|
|
|
|
class MyApp extends StatelessWidget {
|
|
final PushNotificationService pushService;
|
|
|
|
const MyApp({super.key, required this.pushService});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MaterialApp(
|
|
title: 'Mattermost',
|
|
navigatorKey: _navigatorKey,
|
|
theme: ThemeData(
|
|
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
|
|
),
|
|
home: const MyHomePage(title: 'Mattermost'),
|
|
builder: (context, child) {
|
|
// 알림 탭 시 네비게이션 콜백 등록
|
|
pushService.onNavigateToChannel = (serverUrl, channelId) {
|
|
// TODO: 채널 화면으로 이동
|
|
// _navigatorKey.currentState?.pushNamed(
|
|
// '/channel',
|
|
// arguments: {'serverUrl': serverUrl, 'channelId': channelId},
|
|
// );
|
|
print('[Nav] Navigate to channel: $channelId on $serverUrl');
|
|
};
|
|
pushService.onNavigateToThread = (serverUrl, rootId) {
|
|
// TODO: 스레드 화면으로 이동
|
|
// _navigatorKey.currentState?.pushNamed(
|
|
// '/thread',
|
|
// arguments: {'serverUrl': serverUrl, 'rootId': rootId},
|
|
// );
|
|
print('[Nav] Navigate to thread: $rootId on $serverUrl');
|
|
};
|
|
return child!;
|
|
},
|
|
);
|
|
}
|
|
}
|
|
|
|
class MyHomePage extends StatefulWidget {
|
|
const MyHomePage({super.key, required this.title});
|
|
final String title;
|
|
|
|
@override
|
|
State<MyHomePage> createState() => _MyHomePageState();
|
|
}
|
|
|
|
class _MyHomePageState extends State<MyHomePage> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
|
title: Text(widget.title),
|
|
),
|
|
body: const Center(
|
|
child: Text('Mattermost Flutter'),
|
|
),
|
|
);
|
|
}
|
|
}
|