I have a FirebaseMessagingService class from which I call SharedViewModel and set MutableLiveData as value true .
The function written from SharedViewModel is getting called and mutablelivedata is using postData method to set value , but LiveData is not getting observed or called in Fragment/ Activity .
In FirebaseMessagingService
override fun onMessageReceived(message: RemoteMessage) {objectofSharedViewModel.setSomeMutableLiveDataObject(true) // call to SharedViewModel object function }
Code in SharedViewModel .
Its normal function
fun setSomeMutableLiveDataObject(refresh: Boolean){
_mutableLiveDataObj.postValue(refresh)
}
Is it due to different lifecycle ?