When the Qt 5.3 beta was announced, we mentioned the upcoming release of our Qt Purchasing API for Qt Enterprise and Qt Mobile users. We now have a technology preview ready for you to try, and we’re really excited to hear your feedback.
The technology preview is available as a source package from the Qt Account, and the documentation is available online. For the final release (which will be out around the same time as Qt 5.3.0), we will also make binary packages available.
What is it?
The Qt Purchasing API contains cross-platform APIs that can enable in-app purchases in your Qt application. There are C++ and QML APIs available, and it currently supports both consumable and unlockable in-app products. The backends that are currently in place is for Android and iOS, but we’d like to add more later, such as the Windows Store and the Mac OS X Store.
Note that there are no source or binary compatibility guarantees for this technology preview, as one of the objectives of releasing it is to get feedback on the APIs. We want to ensure that the APIs we release match the requirements of our users as much as possible, so it’s possible that they change based on the feedback we get.
How do I build it?
As mentioned, the technology preview is only released as a source package, so you will need to build it manually. Since this is a Qt module which needs to be installed into your Qt directory, it has a couple of requirements which are not requirements for building applications. For you convenience, I’ll go through each of the steps required for building the package in Qt Creator here.
- First you have to download and install a copy of the Qt 5.3.0 beta for your target platform, as the Qt Purchasing APIs depend on Qt 5.3.0. If you want to create an application that works on both iOS and Android, get the combined package for your Mac.
- Set this up, as instructed in the documentation: For iOS and for Android.
- Get the Qt Purchasing API source package, and unpack this in a location of your preference.
- Open Qt Creator.
- In Qt Creator, open the project “qtpurchasing.pro” in the directory where you unpacked the Qt Purchasing source package.
- Select the kits for which you want to use Qt Purchasing.
- In the Projects page, under Build Steps, open Details for Make. Add the word install in the line edit for Make arguments.
- On the same page, make sure you deselect the Shadow build option.
- If this is an Android kit, the PATH environment variable needs to contain the javac compiler executable. If it does not already, add it by editing the PATH variable under Build Environment. On Windows, for example, the directory could be something like C:Program FilesJavajdk1.7.0_15bin.
- Build the project by selecting Build project “qtpurchasing” in the Build menu.
If you get an error that says Error 1 (ignored) you can safely ignore it, as it says.
Once you have completed these steps, the Qt Purchasing API should be ready to use in the Qt version where you chose to install it. Note that you have to execute steps 7 through 10 for each of the kits in which you want to enable Qt Purchasing.
Qt Hangman Rebeefed
To demonstrate the new APIs, we’ve taken the Qt Hangman example and beefed it up a bit.
The example source code is provided in the Qt Purchasing package, so you can build it yourself and run it as you please. The game will work out of the box, but you will have to provide your own store listings for it if you want to enable the in-app purchases in your custom build. If you just want to check out how it looks, an updated version is also available in Google Play for Android and the iOS App Store.
The game’s UI has been revamped with vowel awards and a score, and a more sensible monetization model has been implemented where you can pay for either bundles of 100 vowels or to unlock infinite vowels.
If you are using the Enterprise or Mobile edition of Qt, and are interested in including in-app products in your applications, please download the package and let us know what you think. We’re accepting feedback on Qt.Purchasing@digia.com. Don’t hesitate to contact us, either with suggestions on changes to the APIs or with bug reports!
update: Qt.Purchasing@digia.com should now be working properly. I apologize for the inconvenience.
Link to article: