Home / how to / [Updated Posting] In-App Purchase in Kwik 1.7 – Walk-through

[Updated Posting] In-App Purchase in Kwik 1.7 – Walk-through

In the past months, several requests about In-App Purchase (IAP) with Kwik came up and, according our police to provide your requests first, I would like to announce that IAP will be one of the top features of the upcoming 1.7 version. I have to say that I am curious why this is one of the top requisitions. IAP is complex to setup (more below) and most of the current apps made with Kwik at this moment don’t seem to require this new feature.

Saying that, I would like to anticipate how to use IAP with Kwik 1.7.

First thing to understand is that IAP can be implemented in two different ways when users buy a product from your app:

  1. an internal asset (a page, or an addition of points, for example), previously locked, becomes available after the purchase;
  2. An external asset (more levels or a new magazine issue, for example) is downloaded and integrated into the current application;

Kwik will work with the first scenario only. It means the pages that will be unlocked need to reside into your app (more details below).

Understanding IAP
IAP is complex mostly because it does not allow you to test your application in the Simulator and, part of the code needs to reside in Apple’s servers. So, how to setup IAP? As several “how-tos” mention (see some below), you are going to spend more time working in Apple’s side (configuring profiles, etc) than with Kwik.

Start reading this great walk-through from Troy Brant’s  (the code part is not important as Kwik will handle it for you):

  • Basically you will need to create a Unique App ID
  • Create a new provisioning profile
  • Add you application to iTunes
  • Upload your app binary (even if it is not finished) – you need a binary to create a product
  • Add your product(s)

IAP in Kwik
As mentioned before, Kwik only works with internal asset purchases. Considering it uses the concept of pages, imagine that some pages will be unlocked only when the user purchase them. You may have a free storybook that allows the reader to read until the middle of the story. To finish it, he/she needs to buy the rest of the pages.

In this example, I created a three page project. Users can read page 1 and 2. Going to page 3 the user will receive a message informing that page is locked. It will re-direct the user to the first page, which contains a button for purchase.

Step 1 – Add products to your project
The project area now has a few new features. The IAP one is represented by a credit card.
Click  it to enter the products you plan to sell (you see the list of all previously entered products:
Click the + button to enter more products:

In this window, inform exactly the same product id created in iTunes Connect, otherwise your app will not work. For the name, DO NOT enter names with spaces. As convention, use the last word of your product id as name. In my example above, as my product id is com.asouza.candice.epilogue, I named the name field as epilogue.

Step 2 – Add a button enabling the purchase process
Select a layer and click Add Button. You will notice two new button actions:
The first button allows you to buy a product, which needs to be selected via the following window:

I added an option to auto hide the button after purchase. Just enable the check box and the code will be added for you.

The other button allows you to Restore previous purchases (in the case the user bought them and uninstalled your app – it is not fair he/she needs to pay again, right?).

Step 3 – Select the page you need to protect
When in the page you need to protect, go to the Page section and click the new button (same credit card icon):
Now select the product you want to enable for purchase and the page you want to re-direct users who haven’t purchase yet:
All you need now is to export your project and Build it for your device (remember IAP projects do not work on the Simulator), using the same certificate you used in iTunes Connect. Using the test account you created, click your BUY button and you will get access to the previously locked page!

Comments? I would love to hear them!
Alex

PS: With version 1.7.2 you are now able to have more than 1 purchase button per page. Only 1 purchase button per page is allowed (you cannot create, for example, two buttons pointing two different products in the same page);
PS2: If you need to do what is the magic behind the code, Kwik simply creates a local file into users Documents folder. When the locked page is reached, it checks if the local file exists. If not, it will alert and send the users to the predefined pageError.

7 comments

  • This will be a great feature. I was able to do this with Cocos2D and I was hoping there would be a way to implement IAP in my next eBook. Another reason Kwik is awesome.

  • Well… That’s not what I expected. Please, check if you can change this behavior before releasing IAP. We need something more useful that not only shows paid pages but even hides some others. This way we can EXCHANGE pages like simple pages by animated pages, for example.

    My suggestion makes even more useful things beyond IAP, IAP is a plus of this method:

    1. Implement a way of setting tags in actions so you can use buttons to set those variables. Ex. Action set/unset TAG: “alternative ending 1”

    2. Implement a way of buying a TAG. A action to a button for example. Buy TAG “special pages unlocked”. If the buying process is ok or already bought, the tag is set.

    2. Implement show/hide layer based in tags set/not set. Ex: Show layer “butterfliesFlying” if tag set “special content bought”.

    3. Implement show/hide page based on TAGs. In page properties, a show/hide page based on a collection of TAGs set or not set. Show page if tag “alternative ending 1”. In another page that will be substituted: hide page if NOT TAG “alternative Ending 1”. In a final page: show page if tag “show credits” (This condition was set by a button on the first page)

    This way whe can have an amazing tool to control the content based on actions, buttons, and bought things. We can show/hide things on pages (by actions or paid content), or we can show/hide pages by actions or paid content.

    Pleeease. This is the way for IAP and MUCH MORE things to make great content for users and developers.

    Best regards. Rick Araujo.

  • Rick, thanks a lot for your comments and suggestions. They will be considered for future releases. As you can see, this is the first implementation of IAP into Kwik. For sure it is not enough for all scenarios but, it is a simple but great start for what Kwik currently proposes to do: enable the quick creation of storybooks.

    Before keep adding features to this IAP implementation I am willing to see how people will react and uses IAP. Honestly, besides the good number of requests for IAP, I haven’t see any real use for that yet (I know it is early as only a few beta testers are using the version 1.7). My point here is: if there is demand for more features, I will comming to extend IAP implementation.

    Lastly about the particular request you mention, they are very related to logic implementation (conditional statements, etc), which is not in the timeframe for version 1.x. I hope to add them for v2. Fortunately you can extend Kwik’s code manually and implement the request, if this is a top priority for your current project.

    Please fell free to keep sending suggestions and comments via our Forums as they enable other users to jump in and share similar needs. The more users requesting a particular feature, faster is the delivery of it.

    Cheers,
    Alex

  • Step 3, I go to the page I want to lock, click the Credit Card Icon, and I just get the same In app Project Properties screen, how do i get to the “in app purchase only” screen?

Leave a Reply

Your email address will not be published. Required fields are marked *

Privacy Preference Center

Strictly Necessary

these coolies are for WP-SpamShield, gdpr-wp, woocommerce, paypal

PHPSESSID, SJECT16, JCS_INENREF, JCS_INENTIM, gdpr, woocommerce_cart_hash, woocommerce_items_in_cart, woocommerce_recently_viewed, wordpress_, wordpress_logged_in_, wordpress_sec_, wordpress_test_cookie, wp_woocommerce_session_, AKDC, akavpau_ppsd

Functionality

WordPress cookie created when auto-saving a post in the editor.

wp-saving-post, wp-settings-, wp-settings-time-

Performance

google analytic

__utma,__utmb,__utmc,__utmz,_ga,_gid,_gat

Advertising