Steps

  • the sample project in Bookshelf zip

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

    • copy the project to ~/Documents/Kwik
      • BookShelfEmbedded
      • BookShelfTOC
      • Book01
      • Book02
      • BookServer
    • edit BookShelfTOC/tmplt/components/store/model.lua for Host URL of yours.

      local YourHost  = "http://localhost:4000/daily"
      M.URL           = YourHost.."/LibraryParent/"
      M.backgroundImg = "bg.png"
      
  • BookShelfTOC

    • Project Properties
      • Advanced > Book Shelf Type. Set it as embedded and disable downlodable
      • Monetization to set Book{Num}
    • Shelf page
      • Book{Num}Icon
      • downloadBtn
      • saveBtn
      • savingTxt
      • purchaseBtn
      • restoreBtn
      • infoTxt
      • Buy Product Action
    • Book{Num} INFO page
      • Book{Num}Icon
        • downloadBtn
        • saveBtn
        • savingTxt
        • purchaseBtn
        • infoTxt
        • hideOverlayBtn
  • Book{Num}
    • project properties
      • Advanced > Book Shelf Type. Set it as embedded and enable downlodable
  • 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 sotre/model.lua's backgroundImg as "bg.jpg".

  • BookShelfEmbedded

    • copy.bat or copy.command
    • main.lua - require("plugin.KwikShelf").start("TOC", 1)
  • corona simulator > show sand box folder, you need to clean the followig folders if you want to recover the inital state.

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

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

M.debug     = false

M.epsodes = {
            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 amaon. With offcial 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 ""