Implemented structure for push Notifications
This commit is contained in:
22
lib/notification/notifyUpdater.dart
Normal file
22
lib/notification/notifyUpdater.dart
Normal file
@ -0,0 +1,22 @@
|
||||
|
||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
|
||||
import '../api/mhsl/notify/register/notifyRegister.dart';
|
||||
import '../api/mhsl/notify/register/notifyRegisterParams.dart';
|
||||
import '../model/accountData.dart';
|
||||
|
||||
class NotifyUpdater {
|
||||
static void registerToServer() async {
|
||||
String? fcmToken = await FirebaseMessaging.instance.getToken();
|
||||
|
||||
if(fcmToken == null) throw Exception("Failed to register push notification because there is no FBC token!");
|
||||
|
||||
NotifyRegister(
|
||||
NotifyRegisterParams(
|
||||
username: AccountData().getUsername(),
|
||||
password: AccountData().getPassword(),
|
||||
fcmToken: fcmToken,
|
||||
),
|
||||
).run();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user