Getting Started with Teak on Corona SDK

For backwards compatibility reasons our SDKs still reflect our previous name of 'Carrot'.

The Teak plugin for Corona SDK is hosted by Corona Labs and can be used in your application with a simple modification to your settings.

A simple example can be found on our GitHub page.

You can also find the full source code on GitHub: github.com/GoCarrot/carrot-corona

build.settings

Using Teak requires some additions to your build.settings file for your Corona SDK app.

settings =
{
  -- For Android, the internet permission is required
  android = {
    usesPermissions = {
      "android.permission.INTERNET",
    }
  },
  plugins =
  {
    -- key is the name passed to Lua's 'require()'
    ["plugin.carrot"] =
    {
      -- required
      publisherId = "com.gocarrot",
    },
  },
}

Teak Initialization

You should initialize Teak when your application starts. Simply call carrot.init() providing your Teak Application ID, and Teak API Key.

carrot.init("YOUR TEAK APPLICATION ID", "YOUR TEAK API KEY")

Teak User Authentication

If your app already does Facebook authentication, simply pass Teak the access token you get from sign-in. Please note that Teak requires the 'publish_actions' permission.

  -- Facebook SSO performed by your app...
  carrot.validateUser("FACEBOOK USER ACCESS TOKEN")

If your app does not do Facebook authentication, it can be done using Corona SDK's built-in Facebook plugin.

    -- Perform Facebook Login, and request the 'publish_actions' permission.
    facebook.login("YOUR FACEBOOK APP ID", function(event)
      -- If the callback is triggered with a login event, call carrot.validateUser()
      -- with the access token provided by the login event.
      if event.type == "session" and event.phase == "login" then
        carrot.validateUser(event.token)
      end
    end, {"publish_actions"})

Definining Social Triggers

Next you need to define the social triggers which will be sent to the Teak service to post stories.

-- Earning an achievement in your app called "level_up"
carrot.postAchievement("level_up")

-- User earns a new high score
carrot.postHighScore(score_value)

-- If there is a viral story type set up in the Teak web tool in which a user can
-- 'complete' a 'level', this will post a viral story about the user completing
--  level 2, assuming that "level_2" is defined in the web tool
carrot.postAction("complete", "level_2")

SDK Documentation

Documentation for the Teak plugin for Corona SDK can be found here: Teak plugin for Corona SDK