Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Qt for iOS introduction wanted
Forum Updated to NodeBB v4.3 + New Features

Qt for iOS introduction wanted

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
10 Posts 3 Posters 760 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.
  • A Offline
    A Offline
    adddeeee
    wrote on 14 Aug 2021, 13:13 last edited by
    #1

    Looking for a guide explaining how Qt can interact with iOS. Similar to what is available for Android. There are notification examples for Android, but cannot seem to find anything like that for iOS.

    I have a project which is fetching data from a server every 10 seconds. This works fine in Android, since I have written an Android Service taking care of the data polling in the background, feeding the data to Qt through JNI.

    However, how is the same procedure done for iOS? How do I interact with Qt from iOS, and from Qt to iOS?

    I need to be able to send data to/from Qt and to/from iOS.

    Any guide available?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 14 Aug 2021, 15:17 last edited by
      #2

      Hi,

      AFAIK, there's no direct equivalent to Androïd service.

      See here for some information about background activities on iOS.

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

      A 1 Reply Last reply 15 Aug 2021, 16:35
      1
      • S SGaist
        14 Aug 2021, 15:17

        Hi,

        AFAIK, there's no direct equivalent to Androïd service.

        See here for some information about background activities on iOS.

        A Offline
        A Offline
        adddeeee
        wrote on 15 Aug 2021, 16:35 last edited by
        #3

        @SGaist Thank you! Will have a closer look at that.

        Is there än equivalent to Java Native Interface för ändring data to/from Qt in iOS?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 15 Aug 2021, 17:47 last edited by
          #4

          The official language is Objective-C/C++.

          However, it might not be mandatory to use 100% native APIs depending on what you do.

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

          A 1 Reply Last reply 16 Aug 2021, 00:02
          1
          • K Offline
            K Offline
            KH-219Design
            wrote on 15 Aug 2021, 23:10 last edited by
            #5

            I have a very small public example of mixing Objective-C++ (an mm file) into a Qt5 iOS mobile app.

            https://github.com/219-design/qt-qml-project-template-with-ci/commit/9b6d39aa5a34a3b4642073f0781d302944c20c67

            This might be helpful just in terms of the basic mechanics of adding *.mm files (Objective C++) to your project.

            However, I never did anything as complex as a background "service" (or whatever such a thing should be properly called on iOS).

            www.219design.com
            Software | Electrical | Mechanical | Product Design

            1 Reply Last reply
            1
            • S SGaist
              15 Aug 2021, 17:47

              The official language is Objective-C/C++.

              However, it might not be mandatory to use 100% native APIs depending on what you do.

              A Offline
              A Offline
              adddeeee
              wrote on 16 Aug 2021, 00:02 last edited by
              #6

              @SGaist Okey...

              I'm looking for a guide explaining how one can pass data from native iOS to the Qt part.

              My app will fetch data in the background every 10 seconds. This data need to be passed to the Qt part whenever data is recevied, for the UI to be updated accordingly when app is opened.

              Also the background "service" in iOS (don't know what the equivalent is in iOS for background service in Android) needs to be able to send a local notification to the user.

              Mainly what I do is to fetch data from a server every 10 seconds. Whenever there's a reason to notify the user regarding the data received, a local notification is sent to alert the user something changed.

              What I'm missing is knowledge regarding how to pass data from native iOS to Qt. Similar to what can be done with JNI for Android.

              Do you guys know how to achieve that?

              Also, I need to declare my iOS app to run in the background, since I need to poll data from the server every 10 seconds. How do I do that? For Android it is declaring the app as a foreground service.

              Thanks!

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 16 Aug 2021, 20:32 last edited by
                #7

                There's an article linked in the thread I suggested above that gives more details about the various modes and how to use them.

                As for transferring data, you might be able to leverage directly Qt to load the data from your sever.

                Otherwise you have to explain what data do you fetch from your server. There are already quite a lot of type conversion helper in Qt between native macOS and Qt types.

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

                A 1 Reply Last reply 16 Aug 2021, 20:58
                0
                • S SGaist
                  16 Aug 2021, 20:32

                  There's an article linked in the thread I suggested above that gives more details about the various modes and how to use them.

                  As for transferring data, you might be able to leverage directly Qt to load the data from your sever.

                  Otherwise you have to explain what data do you fetch from your server. There are already quite a lot of type conversion helper in Qt between native macOS and Qt types.

                  A Offline
                  A Offline
                  adddeeee
                  wrote on 16 Aug 2021, 20:58 last edited by
                  #8

                  @SGaist
                  Hello!

                  Yes, I start to realize there are big differences between Android and iOS.

                  My intention it to pull JSON data from a server every 10 seconds. I have found ways of forcing the app to operate in the background using the Background Modes available in Xcode.

                  My next issue is regarding mixing .mm files with my .cpp files.

                  I need to send local notifications to the user from the app, when the app is in background mode. That's why I'm looking for info regarding passing data between iOS and Qt.

                  That is, the app will send local notifications to the user (not pushed from a server) to notify him/her that something changed in the data received.

                  For that, I would need to trigger a local notification to be shown, meaning my Qt code needs to trigger some iOS specific notification handler to show a notification. That trigger I do not understand how to perform.

                  Does that explain my problem?

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 17 Aug 2021, 20:33 last edited by
                    #9

                    You can check the sources of the QtMacExtras module to see how you can use Objective-C++.

                    iOS has local notifications for your needs.

                    One thing you don't explain is how you are retrieving data. As said before you might be able to leverage QNetworkAccessManager and thus do no need any type conversion. Or just pass the json as string and do the processing in the full Qt part of your application.

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

                    A 1 Reply Last reply 18 Aug 2021, 10:46
                    0
                    • S SGaist
                      17 Aug 2021, 20:33

                      You can check the sources of the QtMacExtras module to see how you can use Objective-C++.

                      iOS has local notifications for your needs.

                      One thing you don't explain is how you are retrieving data. As said before you might be able to leverage QNetworkAccessManager and thus do no need any type conversion. Or just pass the json as string and do the processing in the full Qt part of your application.

                      A Offline
                      A Offline
                      adddeeee
                      wrote on 18 Aug 2021, 10:46 last edited by
                      #10

                      @SGaist
                      Thank you! I think I solved it thinking a bit about it. I can use QNetworkAccessManager, since iOS will define the process using Background Modes.

                      Now I'm facing a bit more hidden issue.

                      I've declared my app using the correct Background Mode. It works smoothly and correctly in simulation. The app fetches data every 10 seconds, and displays a test notification, in active mode, in background, and when phone is locked. It all works.

                      However, when downloading the app to a target phone, background running is disabled as soon as the app is no longer in active state.

                      I've looked at Info.plist and copied and replaced the one being built with a copied version + the added background modes. It still does not work.

                      I've not been able to find any info if the Info.plist is my issue or not, but since it's working fine in simulation, my guess is that Info.plist is the problem.

                      NOTE: I've enabled all background modes in Xcode just to be sure. In simulation it works, but not on target.

                      1 Reply Last reply
                      0

                      1/10

                      14 Aug 2021, 13:13

                      • Login

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