CoronaSDK 2013.1143 | Released: 18 Jun 2013, 2:19am | What's New | Download Now
You will be redirected to the new docs in a few seconds.
If you are certain you want to see the old docs, click cancel.
Cancel | Continue to new docs
credits.init()
Description:
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.
Syntax:
credits.init( appId, [, uid], listener )
Example:
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()
Parameters:
appId
Application Identifier (string provided by Super Rewards).
uid
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.
listener
Callback function (listener) to handle Super Rewards events.
Returns:
Nothing.
Remarks:
Supported on operating systems and platforms for build numbers shown:
- Mac OS X:--
- Windows:--
- iOS:Build 2011.507
- Android:Build 2011.559
superrewards has been removed.
in response to bug 17343
"We have actually stopped sup porting SuperRewards as of a few months ago (and have taken it out of the Corona engine).
Corona Labs - Bugs"