4

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?

Farhad
  • 4,119
  • 8
  • 43
  • 66
Amarilla
  • 63
  • 6

1 Answers1

3

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.

Farhad
  • 4,119
  • 8
  • 43
  • 66
  • 1
    @Elsiete.moon If my answer was helpful could you accept it, thanks. – Farhad Sep 08 '17 at 07:58
  • the Qt example was very helpful and i really appreciate it, but the example is about creating local notification and that's actually the reason i didn't accept your answer. – Amarilla Sep 08 '17 at 18:31
  • 1
    What do you mean by `local notification ` ? – Farhad Sep 08 '17 at 18:33
  • Ok, let me explain in another way, i want to send notifications to users even if my app is closed, i can do this with services like [onesignal](https://onesignal.com/) and [pushy](https://pushy.me/) but they didn't support Qt. – Amarilla Sep 08 '17 at 18:39