init method
Implementation
@override
void init() {
if (ObjectFactory.currentUser == null) {
throw new SpinachMessagingInitException(
"No user available to be associated with the device");
}
messaging.onTokenRefresh.listen((newToken) {
if (ObjectFactory.currentUser == null){
return;
}
RegistrationRepository.getInstance()?.addDeviceDetails(
ObjectFactory.currentUser!.toJson(), ObjectFactory.currentUser!.id);
});
FirebaseMessaging.onMessage.listen((event) {
convertAndProcess(event.data, false);
});
FirebaseMessaging.onMessageOpenedApp.listen((event) {
convertAndProcess(event.data, true);
});
}