Closed daljit97 closed 5 years ago
Ok so I tried to implement this in C++ and this works:
void QtFirebaseMessaging::subscribe(const QString &topic)
{
auto result = messaging::Subscribe(topic.toUtf8());
result.OnCompletion([this, topic](const firebase::FutureBase &completed_future){
if(completed_future.error() != messaging::kErrorNone){
emit subscribeSuccess(topic);
}
else{
emit subscribeFailed(topic);
}
});
}
void QtFirebaseMessaging::unsubscribe(const QString &topic)
{
auto result = messaging::Unsubscribe(topic.toUtf8());
result.OnCompletion([this, topic](const firebase::FutureBase &completed_future){
if(completed_future.error() != messaging::kErrorNone){
emit unsubscribeSuccess(topic);
}
else{
emit unsubscribeFailed(topic);
}
});
}
I think 4 signals fo subscribing/unsubscribing might be too much but it does the job.
@daljit97 - awesome! Good thing you found a workaround. I'll see if I can get it merged soon!
Implemented in v1.4.3
Firebase Cloud Messaging allows the user to subscribe to "Topics" as mentioned here. Currently there doesn't seem to be support in QtFirebase to subscribe to Topics. I was wondering if it was possible to implement this. Looking here it seems this is just a matter of calling:
However, I am not familiar with the Firebase C++ APIs so I am not sure if this is the case. Currently as a workaround, I am using the Instance ID APIs but would be nice to able to do this using QtFirebase directly.