UBports Robot Logo UBports Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    New ConverseJS (XMPP) app with broken source links?

    Scheduled Pinned Locked Moved App Development
    45 Posts 4 Posters 526 Views 2 Watching
    Loading More Posts
    • 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.
      • poVoqP Offline
        poVoq @wilson101
        last edited by

        @wilson101 Why? I am just saying you should mention that on the store page.

        Fairphone 5 (Not yet installed UT on it though)

        W 1 Reply Last reply Reply Quote 0
        • W Offline
          wilson101 @poVoq
          last edited by

          @poVoq To be honest you have right. They get logs on servers from IP and browser metrics. I will use local files and implement hook notifications now. I will try. At least we can use it with that type of notifications till I found out how to implement the ubports push notifications.

          1 Reply Last reply Reply Quote 1
          • pparentP Offline
            pparent @wilson101
            last edited by pparent

            @wilson101 said in New ConverseJS (XMPP) app with broken source links?:

            @poVoq Yes, github just sucks for me. Do you have any suggestions on how to implement the push notifications https://docs.ubports.com/en/latest/appdev/guides/pushnotifications.html in a web app ? Or I should try to implement web hook to email.

            Maybe you can look at this:

            https://forums.ubports.com/topic/11375/send-notification-locally-from-qt-c-qml-app.

            It may not be push notification as such, because your app would have to keep running unsuspended in background, but it is sill notifications in a webview.

            W 1 Reply Last reply Reply Quote 2
            • W Offline
              wilson101 @pparent
              last edited by

              @pparent Thank you! I will check it now. 😊

              pparentP 1 Reply Last reply Reply Quote 0
              • pparentP Offline
                pparent @wilson101
                last edited by

                @wilson101

                That being said XMMP protocol might support real push notifications, i.e the server calls a endpoint ( here https://push.ubports.com/notify ) when a new message arrives, and this allows to wake up the phone and display notification. This would be more ideal as the app would not need to run in background to get the notifications.

                I don't know how easy this would be though, especially if you're not the developer of the underlying js application.

                W poVoqP 2 Replies Last reply Reply Quote 1
                • W Offline
                  wilson101 @pparent
                  last edited by

                  @pparent I need to find in the conversejs source where messages are received and hook that to the push notifications with js. On theory should work. But I will first try your implementation. I already executed your script.

                  pparentP 1 Reply Last reply Reply Quote 0
                  • pparentP Offline
                    pparent @wilson101
                    last edited by pparent

                    @wilson101

                    Note that I've just update the documention of the module, there was a small mistake. (It's not helper.send("Hello world") but helper.showNotificationMessage("title","Hello world")

                    @wilson101 said in New ConverseJS (XMPP) app with broken source links?:

                    I need to find in the conversejs source where messages are received and hook that to the push notifications with js.

                    Yes but note that it is not the most optimal way to do. In theory the most ideal would be that the app registers a Push notification server directly to the XMPP server, so that the XMPP server itself send the notification to Ubports push server and then to the phone, so that even if the app is not running at all, and no js from conversejs is running, you still can get the notification.

                    W 1 Reply Last reply Reply Quote 0
                    • W Offline
                      wilson101 @pparent
                      last edited by

                      @pparent That would be great yes! I have one question. Where should I put helper.send("Hello world") ? in the main.qml? I see that it use desktop web notification, page title change, and notification audio playback. So does that mean I can just put the code on top of the main.qml and when i receive message in the app it will automatically send notification?

                      pparentP 1 Reply Last reply Reply Quote 0
                      • pparentP Offline
                        pparent @wilson101
                        last edited by pparent

                        @wilson101 said in New ConverseJS (XMPP) app with broken source links?:

                        Where should I put helper.send("Hello world") ? in the main.qml?

                        Sorry the documentation was not up to date
                        It's not helper.send("Hello world") but helper.showNotificationMessage("title","Hello world")

                        If your webapp emits desktop notifications you can add to your webview

                        onPresentNotification: (notification) => {
                                       helper.showNotificationMessage(notification.title, notification.message);
                                }
                        

                        Otherwise you would need to send a message in js through console.log and then get it in QML with:

                        onJavaScriptConsoleMessage: function(level, message, line, sourceId) {
                        

                        Or you can simply make the app emit desktop notifications which is easy in js.

                        1 Reply Last reply Reply Quote 2
                        • poVoqP Offline
                          poVoq @pparent
                          last edited by

                          @pparent said in New ConverseJS (XMPP) app with broken source links?:

                          That being said XMMP protocol might support real push notifications, i.e the server calls a endpoint ( here https://push.ubports.com/notify ) when a new message arrives, and this allows to wake up the phone and display notification. This would be more ideal as the app would not need to run in background to get the notifications.

                          Yes, but it would require modifying a module on the server, so it will not work with most XMPP servers out there.

                          The probably better alternative would be for the app developer to run a push relay that pretends to be a FCM relay but pushes to the UBports server instead. Not sure how difficult it would be to modify existing software for that though.

                          Fairphone 5 (Not yet installed UT on it though)

                          pparentP 1 Reply Last reply Reply Quote 1
                          • pparentP Offline
                            pparent @poVoq
                            last edited by

                            @poVoq

                            Standard XMMP protocol does not allow to register a custom push server? If so it was poorly designed for a federated protocol...

                            poVoqP 1 Reply Last reply Reply Quote 1
                            • W Offline
                              wilson101
                              last edited by

                              I'm wondering why the sound notifications don't work even if I use the tweak tool and prevent app suspension. On my computers browser works. On the app don't work.

                              W 1 Reply Last reply Reply Quote 0
                              • W Offline
                                wilson101 @wilson101
                                last edited by

                                Ok I fixed that now sound notifications are working, but we need to make the app not suspend from the tweak tool if we want to get notifications on locked screen.

                                pparentP 1 Reply Last reply Reply Quote 0
                                • pparentP Offline
                                  pparent @wilson101
                                  last edited by pparent

                                  @wilson101

                                  Congrats , thought it might not be ideal to let your app emit notification sounds in background, because users could want their phone to be in mute mode, and only vibrate (+ if you don't hear the notification you cannot know if there was one later).

                                  Ideally you could make notifications real UT notifications as I did in whatsweb:

                                  https://github.com/alefnode/ubports-apps/pull/44/commits

                                  W 1 Reply Last reply Reply Quote 2
                                  • W Offline
                                    wilson101 @pparent
                                    last edited by

                                    @pparent It's not ideal for sure. But QML is to confusing for me to be able to implement the push notifications properly with the js code of conversejs. If you have any ideas how to do it exactly I will appreciate it.

                                    pparentP 2 Replies Last reply Reply Quote 0
                                    • pparentP Offline
                                      pparent @wilson101
                                      last edited by

                                      @wilson101

                                      It's basically doing the exact same thing I did in this pull request:

                                      https://github.com/alefnode/ubports-apps/pull/44/commits

                                      Although you can do something much simpler because, to make sure I don't miss a notification I've taken into account 3 sources: desktop notifications, title change, and sound. The first one may be enough in your case.

                                      W 1 Reply Last reply Reply Quote 0
                                      • W Offline
                                        wilson101 @pparent
                                        last edited by

                                        @pparent desktop notifications are enabled in covnerejs by default, but I don't know how to enable them in QML to be able to interact with your module.

                                        pparentP 1 Reply Last reply Reply Quote 0
                                        • pparentP Offline
                                          pparent @wilson101
                                          last edited by

                                          @wilson101

                                          Also make sure to allow your webview to receive desktop notifications in the first place:

                                          onFeaturePermissionRequested: {
                                                 grantFeaturePermission(securityOrigin, feature, true);
                                                 }
                                          
                                          1 Reply Last reply Reply Quote 1
                                          • pparentP Offline
                                            pparent @wilson101
                                            last edited by pparent

                                            @wilson101 said in New ConverseJS (XMPP) app with broken source links?:

                                            @pparent desktop notifications are enabled in covnerejs by default, but I don't know how to enable them in QML to be able to interact with your module.

                                            Well first you add to your webview

                                            onFeaturePermissionRequested: {
                                                   grantFeaturePermission(securityOrigin, feature, true);
                                                   }
                                            

                                            Then in the profile of the webview:

                                            profile:  WebEngineProfile {
                                            ......
                                            
                                                     onPresentNotification: (notification) => {
                                                            helper.showNotificationMessage(notification.title, notification.message);
                                                     }
                                                     
                                                .......
                                                   
                                                   }//End WebEngineProfile
                                            

                                            It should be pretty straight forward.

                                            W 1 Reply Last reply Reply Quote 1
                                            • W Offline
                                              wilson101 @pparent
                                              last edited by

                                              @pparent I have a question about onFeaturePermissionRequested: {
                                              grantFeaturePermission(securityOrigin, feature, true);
                                              }
                                              should I replace feature with notification or whatever name it has in qml or leave it like that ?

                                              pparentP 1 Reply Last reply Reply Quote 0
                                              • First post
                                                Last post