Steps

  • the sample project in Bookshelf zip

    http://kwiksher.com/tutorials/Kwik4/BookShelf.zip

    • copy the following project to ~/Documents/Kwik folder

      • BookShelfTmplt
      • Book01
      • Book02
      • BookServer
    • edit BookShelfTmplt/tmplt/components/store/model.lua for Host URL of yours.

      local YourHost  = "http://localhost:8080"
      M.URL           = YourHost.."/bookshelf/"
      M.backgroundImg = "bg.png"
      
  • BookShelfTmplt project

    • Project Properties
      • Advanced > Book Shelf Type. Set it as template
      • Monetization to set Book{Num}
    • Shelf page
      • book{Num}Icon
      • downloadBtn
      • saveBtn
      • savingTxt
      • purchaseBtn
      • restoreBtn
    • INFO page
      • infoTxt
      • bookXXIcon
      • purchaseBtn
      • savintTxt
      • savedBtn
      • downloadBtn
      • hideOverlayBtn
    • Template pages
      • Page Properties to be set as Template Page
      • Navigation
        • Goto TOC
        • Goto title
        • Goto previous book
        • Goto next book
  • Book{Num} project

    • project properties
      • Advanced > Book Shelf Type. Set it as template and enable downloadable
    • making each page as same as the layer structure of Book shelf master app
    • put the copyright.txt file to build4/assets/ folder
    • build4/model.json to be edited for each alias to associate the book layers with the layers of the master app.
    • mp3 and txt files with p{Num}_ prefix at the root folder
  • BookServer

    • copyright.txt
    • copy_books.bat(Mac) or copy_books.command(MAC)
  • copy each assets.zip and bg.png to book{Num} folder of the http server

    if bg image is jpg, please modify store/model.lua's backgroundImg as "bg.jpg".

  • corona simulator > show sand box folder, you need to clean the following folders if you want to recover the initial state.

    • Application Support
    • Documents
    • TemporaryFiles
  • Before device build, set the valid product IDs from apple, google or amazon.

Kwik pubishes it to build4/components/store/model.lua

M.debug     = false

M.episodes = {
            book01  ={name = "book01", dir = "book01", numOfPages = 6, info = "test", versions ={  }},
            book02  ={name = "book02", dir = "book02", numOfPages = 2, info = "test", versions ={  }},
    }
--
M.catalogue = {
    products = {
            book01 = {
            productNames = { apple="com.kwiksher.bookshelf.book01", google="com.kwiksher.bookshelf.book01", amazon=""},
            productType  = "non-consumable",
            onPurchase   = function() IAP.setInventoryValue("unlock_book01") end,
            onRefund     = function() IAP.removeFromInventory("unlock_book01") end,
        },
            book02 = {
            productNames = { apple="com.kwiksher.bookshelf.book02", google="book02", amazon=""},
            productType  = "consumable",
            onPurchase   = function() IAP.setInventoryValue("unlock_book02") end,
            onRefund     = function() IAP.removeFromInventory("unlock_book02") end,
        },
    },

Debug mode

When you test it with debug as true for IAP on corona simulator. You need to set the book names as dummies for the productNames. Don't use the official produtnames from apple, google or amazon. With official IDs, debug mode fails to return a book name and IAP not work correctly.

fo instance, book01 and book02 are set

M.debug     = true

M.catalogue = {
    products = {
            book01 = {
            productNames = { apple="book01", google="book01", amazon="book01"},
            productType  = "non-consumable",
            onPurchase   = function() IAP.setInventoryValue("unlock_book01") end,
            onRefund     = function() IAP.removeFromInventory("unlock_book01") end,
        },
            book02 = {
            productNames = { apple="book02", google="book02", amazon="book02"},
            productType  = "non-consumable",
            onPurchase   = function() IAP.setInventoryValue("unlock_book02") end,
            onRefund     = function() IAP.removeFromInventory("unlock_book02") end,
        },

build.settings

iOS

if you use http server instead of https, please set your domain in build.settings

NSExceptionDomains

https://docs.coronalabs.com/guide/hardware/appleATS/index.html

Android

  • config.lua needs google license key
  • build.settings needs the permissions

To do so, please enable expansion file and set the license key from goggle. Then config.lua and build.settings will be configured when publishing with Kwik

project properties > Advanced Settings.

results matching ""

    No results matching ""