// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only

/*!

  \page qtpurchasing-appstore.html
  \title Registering Products in App Store
  \brief A short guide to registering in-app products in the iOS App Store.

  To take advantage of in-app purchasing functionality on iOS, register your
  application and all the available products in
  \l{https://appstoreconnect.apple.com/login}{App Store Connect}.
  This guide provides a brief introduction on how to register an application
  and it's in-app products on App Store.

  In-App purchasing can only be tested on the actual hardware for the iOS
  platform. For more information refer to the
  \l{http://developer.apple.com/in-app-purchase/}{iOS documentation}.


  \section1 Register a unique app ID

  One of the requirements to support in-app purchases on iOS is to have
  a registered unique App ID. This means that it is not possible to use
  an App ID that contains a wildcard character. You can check the existing App
  IDs and create new ones from the
  \l{https://developer.apple.com/account/ios/identifiers/bundle/bundleList.action}{Apple Developer Certificate, Identifiers, and Profiles manager}.

  In the \uicontrol{Identifiers} tab of the
  \uicontrol{Developer Certificate, Identifiers, and Profiles} manager, click
  the \uicontrol{+} button to create a New App ID. This will open up the page
  to register a new iOS App ID.

  Give your App a relevant ID description and prefix. Your App ID Suffix
  should be an Explicit App ID type. Enter a unique App ID in the Bundle ID
  field. It is recommended to use the com.mycompany.myappname convention for
  App ID. Where, the "com.mycompany" is the Internet domain name of the
  publisher.

  In the \uicontrol{App Services} area make sure that the
  \uicontrol{In-App Purchases} is checked. Click \uicontrol{continue} your to
  complete the App ID registration.

  \section1 Create a provisioning profile

  To be able to use your new App ID, generate a new provision profile that
  includes the new ID to sign and run your app. Provisioning Profiles are also
  managed through the
  \uicontrol{Apple Developer Certificate, Identifiers, and Profiles} manager.

  Navigate to the \uicontrol{Provisioning Profiles} tab of the manager and
  click the \uicontrol{+} button to create a new Provisioning Profile.  Make
  sure that the \uicontrol{iOS App Development} is selected and click the
  \uicontrol{Continue} button.

  You are now given an option to choose the App ID to use for this profile,
  which will be the unique App ID you created in the previous section. Once
  again make sure that the App ID does not contain any wildcard characters
  (“*”) as it is not be possible to use the In-App Purchasing service with
  such an App ID.

  On the next page you will need to select the certificates that will be
  distributed with your Provisioning Profile. You would have needed to uploaded
  a certificate on your local development machine to the Apple Developer
  Certificate, Identifiers, and Profiles manager previously. Generally you will
  want to add any certificates of the members of your team who will need to build
  your App.

  On the next page you will need to select the devices you will be developing and
  testing your app on. You must register your devices to the Apple Developer
  Certificate, Identifiers, and Profiles manager previously. The devices you
  select here are the only ones capable of running apps signed against this
  provisioning profile, so select all the devices you intend use during the
  development and testing phase.

  Give your Provisioning Profile a descriptive display name, and click
  \uicontrol{Generate} to create the actual profile. When this process is
  completed you’ll be given a choice to download the Provisioning Profile.

  Open the downloaded file in XCode to install. Now the next time you plug in
  one of the registered devices, your Provisioning Profile should be installed
  to it automatically.

  \section1 Register your application

  Before you can register new products available to the in-app purchasing service,
  you need to register your application in App Store Connect. App Store Connect is the
  place where you register an app when you want to submit it to the Apple iOS
  App Store.

  Start by going to \l{https://appstoreconnect.apple.com/login}{App Store Connect} and
  logging in. Once logged in open the \uicontrol{My Apps} link that will take you
  to \uicontrol{Apps} page. If you have already registered your app here, you can
  skip the registration step, otherwise click the plus button and select
  \uicontrol{New App} in the top left corner of the page.

  Select iOS App and then proceed to fill out the required information on the
  next page. When you get to the \uicontrol{Bundle ID} section select the
  unique App ID we created in the previous steps.

  It is likely at this point that you do not have all the necessary details to
  complete the information required to register your app. For now, just fill
  out the forms with stub data as everything except the \uicontrol{SKU} and
  \uicontrol{Version} fields are editable later.

  \section1 Archive and uploading application

  When you build application for iOs device Qt Creator creates XCode project
  that will be used for uploading your application to the App Store. Open the
  XCode project and go to \c {signing and Capabilities} from your project
  properties and make sure that the Apple ID is selected what you use on App
  Store Connect. Make Sure that the \c {Bundle Identifier} is the same as that you
  created on the \uicontrol{Developer Certificate, Identifiers, and Profiles} page.

  Next select \c {Set the active scheme} from the top bar of the XCode window and
  select \c {Generic iOS Device}. Afte that select \c Product on the menu bar and
  click \c Archive. On the pop-up window select \c {Distribute App} go through the
  wizard and the build will show up to the App Store Connect.

  \section1 Setting up application testing

  From the App Store Connect select your application and go to \TestFlight page.
  You should see at least one build of your application in the page. there are two
  type of testing groups internal and external. In internal testing group you can
  select developer who has access to your application on the App Store Connect. In
  external group you can share your application with public link or you can invite
  specific people to test your application.

  \section1 Register the products

  Once your app is registered in App Store Connect you will have additional options
  available to manage that App. In the \uicontrol{Apps} page of App Sotre
  Connect, click the icon representing your app to manage its details. Within this
  menu you can select the \uicontrol{Manage In-App Purchases} from list on the right
  to register in-app products you wish to offer.

  To register a new product, click the \uicontrol{Plus icon} button in the right
  of the "In-App Purchase" header. The first choice you will be given is the type of
  in-app purchase you would like to create.

  On the next page, you must fill out the details about your product. The
  \uicontrol{Reference Name} field refers to how the product will be
  displayed in App Store Connect and in sales reports, but not in the
  App Store itself. The \uicontrol{Product ID} field is very important
  as it is the unique ID that will be used to query for the product from your
  app itself. If possible make this the same ID as the corresponding products
  in the other platform’s stores, otherwise you will have to conditional logic
  in your app for each platform when specifying product identifiers.

  Select the pricing and availability details for you product next. For the iOS
  App Store, pricing is set via a tier system. Each tier represents a price
  level in each iOS App Store region. Your end users will be given the actual
  price expected for a product in terms of what region their App Store is in.

  In the next section \uicontrol{In-App Purchase Details} you specify the details
  for at least one language. When the app requests the product details like
  \c title and \c description, they will be provided in the language of their
  locale if they are available. Create language details for the regions you
  expect to distribute app in.

  Finally, you will need to attach a screenshot that will be used for review
  purposes. This again can be a stub for now, but your product will need to
  pass the review before it can go live to be sold in your published app. Click
  \uicontrol{save} to complete the product registration.
*/
