How to implement push notification in Qt android application

2.1k views Asked by At

I develop a android application using Qt, now i wanna send push notifications. i couldn't find any push notification service that has a Qt SDK. i should mention that because of sanctions i couldn't use Firebase. is it possible to use other SDK using QAndroidJniObject in Qt? is there any other solutions in this situation?

1

There are 1 answers

4
Farhad On

There is very good Qt example about notification and it using QAndroidJniObject.

void NotificationClient::updateAndroidNotification()
{
    QAndroidJniObject javaNotification = QAndroidJniObject::fromString(m_notification);
    QAndroidJniObject::callStaticMethod<void>("org/qtproject/example/notification/NotificationClient",
                                       "notify",
                                       "(Ljava/lang/String;)V",
                                       javaNotification.object<jstring>());
}

This example demonstrates how to add a custom Java class to an Android application, and how to call into this using the JNI convenience APIs in the Qt Android Extras module.

Qt android notification example: http://doc.qt.io/qt-5/qtandroidextras-notification-example.html

It's in QtCreator examples since Qt 5.7 and later.