Closed hrueger closed 5 years ago
@hrueger most likely the LocalNotifications.addOnMessageReceivedCallback
changes the meaning of this
as this is a native callback. Try the following:
constructor() {
const that = this;
LocalNotifications.addOnMessageReceivedCallback(
function (notification) {
that.subject.next(notification);
}
).then(
function() {
console.log("Listener added");
}
)
}
@NickIliev Thanks for your answer. Although it didn't fix the problem, I wondered why there is no error if this.subject didn't exist. So I printed both subjects (the one in the sendTest() method and the one in the callback) and noticed, that the subject in the callback doesn't have any subscribers... The problem was that I added the callback, before I subscribed to the subject... I fixed this by adding the callback again after the subscribe. Nevertheless, many thanks for your efforts!
Type: Bug Angular 8 + Nativescript
I have a subject in my push notification service (this service shows the notifications), which is returned as an Observable. But when I do
this.subject.next(xxx)
in the callback of the local notification, the subscribe method of the observable is not run. But when my component calls thetestSubject() Function
, subscribe() is run. Why?test.component.ts
push.service.ts