larpon / QtFirebase

An effort to bring Google's Firebase C++ API to Qt + QML
MIT License
283 stars 83 forks source link

Subscribing to topic nets no result #169

Closed NaLogo closed 2 years ago

NaLogo commented 2 years ago

Hi, after setting this up with the app I'm working on and being able to successfully test messages via my firebase console, I'm running into an issue with topics.

After messaging is ready and having received a token, I attempt to subscribe to a topic "qtfirebasetopic" but nothing happens. There is no success or error message at any point even though I am listening for various signals, including onSubscribed and onError.

I've littered subscribe() in qtfirebasemessaging.cpp with qDebug() statements and can confirm that the onCompletion() block is never executed. Any ideas?

I'm running Qt 5.15.2 and targeting Android 30. NDK: 21.3.6528147

larpon commented 2 years ago

Due to the general low interest in the project and a lot of restrictions and changes to Googles policies regarding firebase - and Qt, since project start - I've choosen to discontinue trying to maintain any working examples. It's too time consuming.

My only advice is that you try to setup things with your own project tokens / info / settings and don't rely on anything provided in the example app or by default. Everything you need should be visible in the firebase console (which I haven't looked at in years at this point in time)

NaLogo commented 2 years ago

I did and I am using my own settings for my own app package. 😅

But I understand. Thanks for taking the time to reply.

larpon commented 2 years ago

I did and I am using my own settings for my own app package. sweat_smile

Ah, sorry for assuming you played with defaults :) Many often experience that messaging appears to be dysfunctional because notifications doesn't appear - have you tried sending your app to the background on (I assume Android?) your phone - and then send a test message from firebase console.

But I understand. Thanks for taking the time to reply.

No problem - it's just how things are when it's one man vs. big corp. :sweat_smile:

NaLogo commented 2 years ago

Ah, sorry for assuming you played with defaults :)

No worries. :)

Many often experience that messaging appears to be dysfunctional because notifications doesn't appear - have you tried sending your app to the background on (I assume Android?) your phone - and then send a test message from firebase console.

I did, but nothing arrives for the topic I subscribed to. The thing is that the onSubscribed event is never fired when triggering a subscription so I assume it just doesn't go through?

The block in onCompletion is just never executed. I added these qDebug() statements to verify.

qDebug() << "Trying to subscribe to topic:" << topic.toUtf8();

    // TODO queue these futures so repeated calls don't get lost
    auto result = firebase::messaging::Subscribe(topic.toUtf8());

    result.OnCompletion([this, topic](const firebase::FutureBase &completed_future){
        qDebug() << "Subscription completed.";
        if(completed_future.error() == firebase::messaging::kErrorNone) {
            qDebug() << "Subscribed to topic:" << topic;
            emit subscribed(topic);
        } else {
            qDebug() << "Error while subscribing to topic:" << topic;
            emit error(completed_future.error(), QString(QString::fromUtf8(completed_future.error_message())));
        }
    });

    qDebug() << "Subscribe method ended.";

Is there a good way to debug these requests? Or am I SOL since Firebase itself is pretty closed?

NaLogo commented 2 years ago

As it turns out, it was a big oversight on my part.

I overlooked that the QtFirebase wrapper was only tested up to Firebase SDK version 6.7.0 - and I was using the latest 8.7.0. 😬 So apparently, along the way, something was changed that QtFirebase is incompatible with.

Now the Future object resolves and the device gets subscribed to the selected topic. Messages also arrive more reliably.

Closing this. Again, thanks for taking the time to take a look at this. 😊

larpon commented 2 years ago

As it turns out, it was a big oversight on my part.

I overlooked that the QtFirebase wrapper was only tested up to Firebase SDK version 6.7.0 - and I was using the latest 8.7.0. 😬 So apparently, along the way, something was changed that QtFirebase is incompatible with.

Now the Future object resolves and the device gets subscribed to the selected topic. Messages also arrive more reliably.

Closing this. Again, thanks for taking the time to take a look at this. 😊

Happy to help - I'm glad you figured it out in the end.

Yes it becomes increasingly hard for small developers to stay on top of things with the speed and constant evolving of products like Firebase from big corporations 🤷‍♂️