Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. GCM push notifications android
Forum Updated to NodeBB v4.3 + New Features

GCM push notifications android

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
23 Posts 6 Posters 8.0k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SGaistS SGaist

    Hi and welcome to devnet,

    Currently Qt doesn't have anything specific that so you would need to write some native code for that. However you might be interested by V-Play and it's GCM plugin.

    ekkescornerE Offline
    ekkescornerE Offline
    ekkescorner
    Qt Champions 2016
    wrote on last edited by
    #3

    @SGaist I can imagine that there are some devs out there already done this work. I'm really missing a central page at Qt where all such native integrations with Android or iOS can be mentioned. would be better to do work only one time and would make it easier for new devs using Qt for mobile. @tero-kojo we already discussed this some time ago. any news ?

    ekke ... Qt Champion 2016 | 2024 ... mobile business apps
    5.15 --> 6.8 https://t1p.de/ekkeChecklist
    QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

    1 Reply Last reply
    1
    • S Offline
      S Offline
      Schluchti
      wrote on last edited by
      #4

      I am currently working on a blog series about typical problems that developers are facing when using Qt for mobile app development. I think that might be a good topic for the next blog post. :)

      Want to read more about Qt?

      https://gympulsr.com/blog/qt/

      Latest Article: https://gympulsr.com/blog/qt/2017/06/14/ios-background-music-qt.html

      1 Reply Last reply
      1
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #5

        @ekkescorner sur there is, but usually specific to their own applications except in the case of V-Play that provides the support through their framework.

        @Schluchti In the categories of stuff that can help:

        • https://inqlude.org for Qt related libraries
        • qt-pods project

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        ekkescornerE S 2 Replies Last reply
        1
        • SGaistS SGaist

          @ekkescorner sur there is, but usually specific to their own applications except in the case of V-Play that provides the support through their framework.

          @Schluchti In the categories of stuff that can help:

          • https://inqlude.org for Qt related libraries
          • qt-pods project
          ekkescornerE Offline
          ekkescornerE Offline
          ekkescorner
          Qt Champions 2016
          wrote on last edited by
          #6

          @SGaist V-Play is not a solution for me - I'm using Qt because it's Open Source and I want to use Open Source for any plugins / extensions / libraries. V-Play is a great SDK, but V-Play PlugIns are not OSS

          Mobile Apps are special. Developing mobile Apps with Qt there are many common things missed: PushServices, Access to Contacts, Phone, Android Intents, iOS App Extensions, Battery state, SignaturePad, ... all those stuff you usually need, but not found from Qt Classes.
          And you need it for Android and iOS and probably W10. All mobile devs together could develop a community market place. Not for Qt in general - for Qt mobile Apps. Current solution is that devs have to learn HowTo create the native Android / iOS stuff and HowTo call this from Qt. I'm sure there are many devs doing the same again and again.

          Would be cool to have a common place where devs can provide solutions and take a look at other devs solutions HowTo handle such kind of stuff for Android and iOS.

          take a look at PhoneGab / Cordova Plugins: http://www.plugreg.com/plugins and http://www.plugreg.com/plugins or per ex. a SignaturePad for ReactNative: https://github.com/RepairShopr/react-native-signature-capture I found from https://react.parts/native. Try to find a Signature Pad for QQC2 apps running on Android and iOS.
          there was one Qt Blog about Intents with Qt for Android, part 1 and nothing else. also no info HowTo solve similar use-case für iOS.
          There are also some great blogs from KDAB.
          Now with QQC2 we have the UI Controls we need for mobile, but I'm really missing a central place from Qt from where you can find all those important extensions/libraries for mobile app developers.

          ... seems I'm running out of scope from this thread ;-)

          ekke ... Qt Champion 2016 | 2024 ... mobile business apps
          5.15 --> 6.8 https://t1p.de/ekkeChecklist
          QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

          1 Reply Last reply
          1
          • SGaistS SGaist

            @ekkescorner sur there is, but usually specific to their own applications except in the case of V-Play that provides the support through their framework.

            @Schluchti In the categories of stuff that can help:

            • https://inqlude.org for Qt related libraries
            • qt-pods project
            S Offline
            S Offline
            Schluchti
            wrote on last edited by
            #7

            @SGaist Many thanks for the links! Didn't know that such great projects exist :)

            I already implemented push notifiction for iOs and android. As it took me some time to implement it, I am thinking about writing it down to save other Qt developers time when implementing that stuff.

            Want to read more about Qt?

            https://gympulsr.com/blog/qt/

            Latest Article: https://gympulsr.com/blog/qt/2017/06/14/ios-background-music-qt.html

            ekkescornerE 1 Reply Last reply
            1
            • S Schluchti

              @SGaist Many thanks for the links! Didn't know that such great projects exist :)

              I already implemented push notifiction for iOs and android. As it took me some time to implement it, I am thinking about writing it down to save other Qt developers time when implementing that stuff.

              ekkescornerE Offline
              ekkescornerE Offline
              ekkescorner
              Qt Champions 2016
              wrote on last edited by ekkescorner
              #8

              @Schluchti said in GCM push notifications android:

              @SGaist Many thanks for the links! Didn't know that such great projects exist :)

              I already implemented push notifiction for iOs and android. As it took me some time to implement it, I am thinking about writing it down to save other Qt developers time when implementing that stuff.

              great idea ;-)
              best would be a small example project at gitHub together with blogpost

              ekke ... Qt Champion 2016 | 2024 ... mobile business apps
              5.15 --> 6.8 https://t1p.de/ekkeChecklist
              QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

              S 1 Reply Last reply
              1
              • LorenzL Offline
                LorenzL Offline
                Lorenz
                wrote on last edited by Lorenz
                #9

                Hi,

                As already mentioned by @SGaist, V-Play provides support for Push Notifications via GCM and OneSignal for Android and iOS. Also, local notifications are possible with V-Play.

                It's really convenient to add, check out this code sample for OneSignal:

                import QtQuick 2.1
                import VPlayPlugins 1.0
                
                 OneSignal {
                   id: onesignal
                
                   appId: "<ONESIGNAL-APP-ID>"
                
                   onNotificationReceived: {
                     console.debug("Received notification with message:", message)
                   }
                 }
                

                That's all the code you'll need!

                As pointed out by @ekkescorner, you will need a V-Play Indie- or Enterprise license starting from $49 / month to use these features.

                By the way, support for Firebase is currently in the pipeline ;)

                Cheers,
                Lorenz

                Developer @ V-Play Engine - http://v-play.net/qt

                V-Play simplifies

                • Game Development with Qt
                • Mobile App Dev with Qt esp. iOS & Android

                What others say
                V-Play scored #1 in Cross-Platform App Development Tools Report - see why: https://goo.gl/rgp3rq

                1 Reply Last reply
                0
                • ekkescornerE ekkescorner

                  @Schluchti said in GCM push notifications android:

                  @SGaist Many thanks for the links! Didn't know that such great projects exist :)

                  I already implemented push notifiction for iOs and android. As it took me some time to implement it, I am thinking about writing it down to save other Qt developers time when implementing that stuff.

                  great idea ;-)
                  best would be a small example project at gitHub together with blogpost

                  S Offline
                  S Offline
                  Schluchti
                  wrote on last edited by
                  #10

                  @ekkescorner Yeah, that's what I was thinking about ;-). Hope to get the first article done by the end of this week. :)

                  Want to read more about Qt?

                  https://gympulsr.com/blog/qt/

                  Latest Article: https://gympulsr.com/blog/qt/2017/06/14/ios-background-music-qt.html

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    m.kuncevicius
                    wrote on last edited by
                    #11

                    Thank you for answers guys! I knew before about V-Play, but I'm not interested in using it since it is not free. @Schluchti it would be great if you don't mind sharing your code!

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      Schluchti
                      wrote on last edited by
                      #12

                      First part is now available. https://gympulsr.com/blog/qt/2017/03/08/push-notification-ios-qt.html
                      I hope it covers everything.

                      Want to read more about Qt?

                      https://gympulsr.com/blog/qt/

                      Latest Article: https://gympulsr.com/blog/qt/2017/06/14/ios-background-music-qt.html

                      ekkescornerE 1 Reply Last reply
                      3
                      • S Schluchti

                        First part is now available. https://gympulsr.com/blog/qt/2017/03/08/push-notification-ios-qt.html
                        I hope it covers everything.

                        ekkescornerE Offline
                        ekkescornerE Offline
                        ekkescorner
                        Qt Champions 2016
                        wrote on last edited by
                        #13

                        @Schluchti great article - thx providing your experiences and sample app.

                        ekke ... Qt Champion 2016 | 2024 ... mobile business apps
                        5.15 --> 6.8 https://t1p.de/ekkeChecklist
                        QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

                        1 Reply Last reply
                        2
                        • S Offline
                          S Offline
                          Schluchti
                          wrote on last edited by
                          #14

                          Second part is now done: https://gympulsr.com/blog/qt/2017/03/26/push-notification-android-qt.html

                          Hope I didn't miss anything (implemented the notifications a while ago and now tried to remember as much as I could ;-)). If something is missing, please let me know.

                          Want to read more about Qt?

                          https://gympulsr.com/blog/qt/

                          Latest Article: https://gympulsr.com/blog/qt/2017/06/14/ios-background-music-qt.html

                          ekkescornerE A 2 Replies Last reply
                          2
                          • S Schluchti

                            Second part is now done: https://gympulsr.com/blog/qt/2017/03/26/push-notification-android-qt.html

                            Hope I didn't miss anything (implemented the notifications a while ago and now tried to remember as much as I could ;-)). If something is missing, please let me know.

                            ekkescornerE Offline
                            ekkescornerE Offline
                            ekkescorner
                            Qt Champions 2016
                            wrote on last edited by
                            #15

                            @Schluchti cool - blog look great :)

                            probably next 2 weeks I'll test it.

                            just still optimizing all my apps for Qt 5.8

                            ekke ... Qt Champion 2016 | 2024 ... mobile business apps
                            5.15 --> 6.8 https://t1p.de/ekkeChecklist
                            QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

                            1 Reply Last reply
                            2
                            • S Schluchti

                              Second part is now done: https://gympulsr.com/blog/qt/2017/03/26/push-notification-android-qt.html

                              Hope I didn't miss anything (implemented the notifications a while ago and now tried to remember as much as I could ;-)). If something is missing, please let me know.

                              A Offline
                              A Offline
                              Atr0n
                              wrote on last edited by Atr0n
                              #16
                              This post is deleted!
                              S 1 Reply Last reply
                              0
                              • A Atr0n

                                This post is deleted!

                                S Offline
                                S Offline
                                Schluchti
                                wrote on last edited by Schluchti
                                #17

                                @Atr0n thanks! :)

                                You are refering to the android blog post, right? Have you enabled Gradle in the project settings? I haven't seen this errorin particular, but some similar packaging errors when using Ant. In my experience it sometimes also helps to delete the whole build folder to enforce a clean rebuild.

                                edit: are you sure that error is the acutal reason why it failed?

                                Want to read more about Qt?

                                https://gympulsr.com/blog/qt/

                                Latest Article: https://gympulsr.com/blog/qt/2017/06/14/ios-background-music-qt.html

                                A 1 Reply Last reply
                                2
                                • S Schluchti

                                  @Atr0n thanks! :)

                                  You are refering to the android blog post, right? Have you enabled Gradle in the project settings? I haven't seen this errorin particular, but some similar packaging errors when using Ant. In my experience it sometimes also helps to delete the whole build folder to enforce a clean rebuild.

                                  edit: are you sure that error is the acutal reason why it failed?

                                  A Offline
                                  A Offline
                                  Atr0n
                                  wrote on last edited by Atr0n
                                  #18

                                  @Schluchti said in GCM push notifications android:

                                  @Atr0n thanks! :)

                                  You are refering to the android blog post, right? Have you enabled Gradle in the project settings? I haven't seen this errorin particular, but some similar packaging errors when using Ant. In my experience it sometimes also helps to delete the whole build folder to enforce a clean rebuild.

                                  edit: are you sure that error is the acutal reason why it failed?

                                  Hi @Schluchti,
                                  I deleted my last post because after some investigations, I realiced Qt creator has a bug which makes impossible to use the last gradle version (or 3.3 in my case). QT-BUG
                                  I will give it a try once qt creator 4.3 is out.
                                  Anyway, thanks again for your blog. I hope you keep doing these amazing series.
                                  Regards,

                                  1 Reply Last reply
                                  0
                                  • A Offline
                                    A Offline
                                    Atr0n
                                    wrote on last edited by
                                    #19

                                    @Schluchti Finally I make it work. The python scripts need to be updated to make it works with python3 since apns2 it's only compatible with it at version 0.52. But everything works like a charm..
                                    Thank you a lot.
                                    PD: I can pull the python script modification to github if you want.

                                    S 1 Reply Last reply
                                    1
                                    • A Atr0n

                                      @Schluchti Finally I make it work. The python scripts need to be updated to make it works with python3 since apns2 it's only compatible with it at version 0.52. But everything works like a charm..
                                      Thank you a lot.
                                      PD: I can pull the python script modification to github if you want.

                                      S Offline
                                      S Offline
                                      Schluchti
                                      wrote on last edited by
                                      #20

                                      @Atr0n I am glad that it worked :) It would be great if you could create a pull request for it, many thanks!

                                      Want to read more about Qt?

                                      https://gympulsr.com/blog/qt/

                                      Latest Article: https://gympulsr.com/blog/qt/2017/06/14/ios-background-music-qt.html

                                      A 1 Reply Last reply
                                      1
                                      • S Schluchti

                                        @Atr0n I am glad that it worked :) It would be great if you could create a pull request for it, many thanks!

                                        A Offline
                                        A Offline
                                        Atr0n
                                        wrote on last edited by
                                        #21

                                        @Schluchti Nice, thanks!
                                        I have a final question for you: How do you stop notifications? For example, if the user log out.
                                        I was thinking on moving MyGcmListenerService to the main Activity and start it from there. Then I can start and stop the service when I want. What do you think?
                                        Regards,

                                        S 1 Reply Last reply
                                        0
                                        • A Atr0n

                                          @Schluchti Nice, thanks!
                                          I have a final question for you: How do you stop notifications? For example, if the user log out.
                                          I was thinking on moving MyGcmListenerService to the main Activity and start it from there. Then I can start and stop the service when I want. What do you think?
                                          Regards,

                                          S Offline
                                          S Offline
                                          Schluchti
                                          wrote on last edited by Schluchti
                                          #22

                                          @Atr0n I haven't done that, but I would probably try a different approach first. It's just a personal preference, but moving such a central component to a different place would be to risky for me. (I would be afraid to break something and miss messages in certain occasions).

                                          Instead I would try to store the state (user logged in) somewhere and only show the notification when the user is logged in. One could do that either server-side (probably not that comfortable if the user logs in from different devices) or client-side. For example: You could store a boolean flag somewhere (e.q in SharedPreferences, so you can easily access it from the Java part) that saves the state (logged in/logged out). If you receive a new notification you first check if you are logged in. If you aren't, you discard the receive message.

                                          But I am not an android expert...so please take that advice with a grain of salt ;-).

                                          P.S: The disadvantage of that approach is, that you always receive messages although they aren't displayed. So if you are sending a lot of messages this could produce unnecessary load. Another thing is, that if you have a app, where users can explicitly disable push notifications, you are kind of screwing them over with that approach. (because messages are received anyhow) In that case I would probably go the way you described and look for ways to disable that feature completely (or even better: don't send notifications from the server in the first place)

                                          Want to read more about Qt?

                                          https://gympulsr.com/blog/qt/

                                          Latest Article: https://gympulsr.com/blog/qt/2017/06/14/ios-background-music-qt.html

                                          A 1 Reply Last reply
                                          1

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved