Initializes the Super Rewards API in an app with a specific Application Identifier (string provided by Super Rewards) and a callback function (listener) to handle Super Rewards events.
To learn more, go to the Credits (Virtual Currency) Guide.
Note: Adding "require credits" to your code will enable Corona Launchpad regardless of the setting in config.lua.
credits.init( appId, [, uid], listener )
local credits = require "credits" local creditsListener = function( event ) print( event.name ) -- outputs "creditsRequest" if ( event.isError ) then print( "An error occurred. Request failed" ) else print( event.newCredits ) -- number of new credits earned print( event.totalCredits ) -- total available credits end end credits.init( "yourAppIdHere", creditsListener ) credits.showOffers() credits.requestUpdate()
Application Identifier (string provided by Super Rewards).
The optional uid argument in the function is used to set a "test user id" for your build, so you can test offer completion without having to actually complete a real offer. In the Admin section when you manage your app (in the Super Rewards back-end), you must specify this same test user id in the field provided (recommended uids: 1001, 1002, 1003, and so on).
It's important to note that once you test and unlock a test offer with a uid, you must create a new build with a different uid. There's no way to reset a uid and unlock an offer again.
For your final app build, you should not set the uid argument in the function above.
Callback function (listener) to handle Super Rewards events.
Supported on operating systems and platforms for build numbers shown:
- Mac OS X:--
- iOS:Build 2011.507
- Android:Build 2011.559