Steps
Steps
-
the sample project in Bookshelf zip
https://kwiksher.com/tutorials/Kwik4/BookShelf.zip
- copy the following projects to ~/Documents/Kwik folder
- BookShelfEmbedded
- BookTOC
- Book01
- Book02
- BookServer
- edit BookTOC/tmplt/components/store/model.lua for Host URL of yours if you set up your own server.
local YourHost = "http://localhost:8080" M.URL = YourHost.."/bookshelf/" M.backgroundImg = "bg.png"
- copy the following projects to ~/Documents/Kwik folder
-
BookTOC
- Project Properties
- Advanced > Book Shelf Type. Set it as embedded and disable downloadable
- Monetization. Set a book id for instance, book01, book02
- 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}Icon
- Project Properties
-
Book{Num}
- project properties
- Advanced > Book Shelf Type. Set it as embedded and enable downloadable
- project properties
-
BookServer
- compress_assets/main.lua corona simulator
compress and copy each assets of Books to BookServer and bg.png as well
if bg image is jpg, please modify store/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 following folders if you want to recover the initial state.
- Application Support
- Documents
- TemporaryFiles
-
For device build, you must set the valid product IDs from apple, google or amazon. For IAP Debug Mode, set the same name value to each filed.
Kwik publishes 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 product names 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.
