High-level, what I'm facing is the long tail of development. I can find answers for Firebase C++, for Android Studio, for Flutter, for Unity, for React Native ... but not for Qt.
Mid-level, I have a Qt application. When deployed to iOS works fine. The push notifications work -- both data and notification. On Android, Pixel XL data works, but notification does not. On Samsung Note 9, nothing works.
Low-level, both data and notification for both Android and iOS worked before upgrading Firebase C++ SDK to 5.4.2 from 4.1.0. (I know that 5.4.3 is the latest, but we chose 5.4.2 because our other apps were only upgraded that far, and we thought it best to keep them all on one level.) I also upgraded from C++10 to C++14. If it's relevant.
Increasingly low level, here is a block from my main.cpp:
#if TARGET_OS_IPHONE || __ANDROID__
FirebaseMessaging *listener = new FirebaseMessaging();
auto result = ::firebase::messaging::Initialize(*fbApp, listener);
if (result == ::firebase::kInitResultFailedMissingDependency) {
qDebug() << "Failed initializing firebase";
} else {
if (result == ::firebase::kInitResultSuccess) {
qDebug() << "Firebase initialization returned a success result code.";
} else {
qDebug() << "Firebase initialization returned a failure result code.";
}
qDebug() << "Firebase initialized with " << result;
}
::firebase::messaging::SetTokenRegistrationOnInitEnabled(true);
#endif
The output received is the expected:
main.cpp(197): Firebase initialization returned a success result code.
main.cpp(201): Firebase initialized with 0
My listener (of type FirebaseMessaging) is unabridged (firebase_messaging.cpp):
#include "firebase_messaging.h"
#include "cpp/3rdparty/logger.hpp"
#include "cpp/controllers/tasklistcontroller.h"
#include "cpp/controllers/logincontroller.h"
using namespace mercury::logger;
FirebaseMessaging::FirebaseMessaging()
{
qDebug() << "FirebaseMessaging has been instantiated.";
}
void FirebaseMessaging::OnMessage(const firebase::messaging::Message & message) {
log<INFO>("Received firebase message");
emit TaskListController::instance()->needsReload();
if (!message.from.empty()) log<INFO>("from: %s", message.from.c_str());
if (!message.error.empty()) log<INFO>("error: %s", message.error.c_str());
if (!message.message_id.empty()) {
log<INFO>("message_id: %s", message.message_id.c_str());
}
if (!message.data.empty()) {
log<INFO>("data:");
for (const auto& field : message.data) {
log<INFO>(" %s: %s", field.first.c_str(), field.second.c_str());
}
}
if (message.notification) {
log<INFO>("notification:");
if (!message.notification->title.empty()) {
log<INFO>(" title: %s", message.notification->title.c_str());
}
if (!message.notification->body.empty()) {
log<INFO>(" body: %s", message.notification->body.c_str());
}
if (!message.notification->icon.empty()) {
log<INFO>(" icon: %s", message.notification->icon.c_str());
}
if (!message.notification->tag.empty()) {
log<INFO>(" tag: %s", message.notification->tag.c_str());
}
if (!message.notification->color.empty()) {
log<INFO>(" color: %s", message.notification->color.c_str());
}
if (!message.notification->sound.empty()) {
log<INFO>(" sound: %s", message.notification->sound.c_str());
}
if (!message.notification->click_action.empty()) {
log<INFO>(" click_action: %s",
message.notification->click_action.c_str());
}
}
}
void FirebaseMessaging::OnTokenReceived(const char * token) {
log<INFO>("Firebase token received: %s", token);
LoginController::instance()->setPushToken(QString::fromUtf8(token));
}
But the only thing that comes from the listener at all is the debug message that "FirebaseMessaging has been instantiated," and not "Received firebase message" or "Firebase token received: %s". Which means that neither of those functions are getting called.
So, I don't have any clue where my problem is, or even how to coax the logs for insight. From the logs, when I send out a push notification from our API, I get:
D FA : Logging event (FE): notification_receive(_nr), Bundle[{firebase_event_origin(_o)=fcm, firebase_screen_class(_sc)=QtActivity, firebase_screen_id(_si)=8469772288255777039}]
V FA : Connecting to remote service
D FA : Logging event (FE): notification_foreground(_nf), Bundle[{firebase_event_origin(_o)=fcm, firebase_screen_class(_sc)=QtActivity, firebase_screen_id(_si)=8469772288255777039}]
V FA : Connection attempt already in progress
D FA : Connected to remote service
V FA : Processing queued up service tasks: 2
V FA : Inactivity, disconnecting from the service
D FA : Logging event (FE): notification_receive(_nr), Bundle[{firebase_event_origin(_o)=fcm, firebase_screen_class(_sc)=QtActivity, firebase_screen_id(_si)=8469772288255777039}]
V FA : Connecting to remote service
D FA : Logging event (FE): notification_foreground(_nf), Bundle[{firebase_event_origin(_o)=fcm, firebase_screen_class(_sc)=QtActivity, firebase_screen_id(_si)=8469772288255777039}]
V FA : Connection attempt already in progress
D FA : Connected to remote service
V FA : Processing queued up service tasks: 2
V FA : Inactivity, disconnecting from the service
And so I believe that my problem is entirely in the Qt implementation itself. IE, not in the cloud, not in firebase, but in my Android Qt implementation.
Here is an image album of the android logcat and the iphone output, showing that android isn't calling the listener callback code, but apple is.
Can anyone help?
EDIT: I found this in my bugreport:
12-20 13:28:58.447 1000 877 23636 E NotificationService: Suppressing notification from package by user request.
12-20 13:28:59.312 1000 877 2141 I ActivityManager: Start proc 7778:com.android.documentsui/u0a12 for broadcast com.android.documentsui/.PackageReceiver
12-20 13:28:59.747 1000 877 1972 I ActivityManager: Start proc 7816:android.process.media/u0a13 for broadcast com.android.providers.downloads/.DownloadReceiver
12-20 13:29:04.400 1000 877 1972 W ActivityManager: Invalid packageName: biz.deliverydudes.driverapp
12-20 13:29:14.008 1000 877 894 I ActivityManager: START u0 {flg=0x10000000 cmp=biz.deliverydudes.driverapp/org.qtproject.qt5.android.bindings.QtActivity (has extras)} from uid 2000
12-20 13:29:14.077 1000 877 916 I ActivityManager: Waited long enough for: ServiceRecord{92c0823 u0 org.fdroid.fdroid/.data.InstalledAppProviderService}
User contributions licensed under CC BY-SA 3.0