×
A new build of Corona SDK is now available to subscribers. Not a subscriber? Subscribe now.
CoronaSDK 2014.2381 | Released: 30 Jul 2014, 6:32am | What's New | Download Now

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

Replies

open768
User offline. Last seen 42 weeks 4 days ago. Offline
Joined: 6 Jul 2011

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"