如何在Qt android应用程序中实现推送通知

时间:2017-09-07 13:09:46

标签: qt push-notification notifications qtandroidextras android-push-notification

我使用Qt开发一个Android应用程序,现在我想发送推送通知。 我找不到任何有Qt SDK的推送通知服务。我应该提一下,由于制裁,我无法使用Firebase。是否可以在Qt中使用QAndroidJniObject使用其他SDK?在这种情况下还有其他解决方案吗?

1 个答案:

答案 0 :(得分:3)

关于通知有很好的Qt示例,它使用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>());
}

此示例演示如何将自定义Java类添加到Android应用程序,以及如何使用Qt Android Extras模块中的JNI便捷API调用此类。

Qt android通知示例:http://doc.qt.io/qt-5/qtandroidextras-notification-example.html

自Qt 5.7及更高版本以来,它在QtCreator示例中。