Important: Please read the Qt Code of Conduct -

get call notification on Android and iOS ?

  • Hi,
    Is it possible to get phone call notification in Qt ? I need this on Android and iOS.
    On Android I assume that thanks to Android Extras I can dabble with java and get this notification, but how about iOS ? Any one knows?

    Best Regards

  • @Marek I am not aware of any Qt APIs for android/iOs so I think you have to go the native way and implement that yourself. As you have already mentioned, you can implement the Android specific stuff with QAndroidExtras. The iOs specific implementation is often (at least in my opinion) easier than the Android one, as you can directly use Objective C.

    I haven't done this, but according to this thread I would roughly do it like this:

    • add Core Telephony framework to the ios specific section of your *.pro file
    • create a header file (*.h) and a sourcecode file (*.mm) and add those files to the ios specific section of your *.pro file. Those files are the place where the implementation takes place. i.e: you get the Core Telephony notification center and register the callback (as described in the stackoverflow thread above).

    One important thing when mixing C++ wth Objective C is: Don't pollute your header file with Objective C specific stuff, or it won't compile. Instead "hide" the implementation by using a nested, private class.

  • @Schluchti Thanks for your answer.
    On macOS I used to call qmake to generate .xcodeproj and then continue in Xcode to compile, archive and upload.

    I know that I need to create .h and .mm file and add the last one to OBJECTIVE_SOURCES in .pro file
    but how to: "add Core Telephony framework to the ios specific section of your *.pro file" ?
    any examples of doing that, or maybe is there a way to do it just in Xcode ?

    Best Regards

  • @Marek

    I am not sure how the Core Telephony Framework is actually called (you have to look that up), but in general you can add framworks like this:

        LIBS += -framework Foundation
        LIBS += -framework CoreMotion
        LIBS += -framework CoreData
        LIBS += -framework AVFoundation
        LIBS += -framework MediaPlayer

    The above code snippet is just copied from the *.pro file of one of my projects, which uses a few different frameworks.

  • Lifetime Qt Champion

    @Schluchti if I may

    ios {
        LIBS += \
            -framework Foundation \
            -framework CoreMotion \
            -framework CoreData \
            -framework AVFoundation \
            -framework MediaPlayer

    would make your .pro file lighter to read.

  • @SGaist @Schluchti Thanks to both of you

    Is this described somewhere ? does not provide this info.
    I will also need In App Purchase and I have seen this also needs some Apple Framework

  • Lifetime Qt Champion

    Yes it is, see qmake platform notes.

    Qt proposes the QtPurchasing module for that task.

  • @SGaist I didn't know about QtPurchasing module, thanks

Log in to reply