Lerg/plugins-fyber

Fyber Plugin for Corona

★ 0Forks 0KotlinGitHub ↗Compare

README

Fyber Plugin for Corona

Add to build.settings

	plugins = {
		['plugin.fyber'] = {
			publisherId = 'com.spiralcodestudio',
			supportedPlatforms = {
				iphone = {url = 'https://.../plugin.fyber.stub.tgz'},
				android = {url = 'https://.../plugin.fyber.android.tgz'},
				macos = false,
				win32 = false
			}
		}
	}

Require the plugin in Lua.

 local fyber = require('plugin.fyber')

API reference

fyber.init(params)

Initialize the plugin. Call it before using the plugin. However, you might want to provide a user consent information for better offers before calling fyber.init(). See fyber.setGdprConsentData().

params table

  • app_id, string. App id.
  • security_token, string. Security token.
  • user_id, string, optional. Unique user id. Don't set for automatic user id.
  • should_close_offerwall. boolean, optional. If true automatically close the offerwall on offer selection.
  • listener, function. Listener receives fyber events.

Syntax

local json = require('json')
fyber.init{
	app_id = '123456',
	security_token = 'fankjfsy47tia7jhgg4783t4has984',
	--user_id = '',
	--should_close_offerwall = true,
	listener = function(event)
		print(json.prettify(event))
	end
}

Events

fyberOfferWall

Events regarding the offerwall.

  • name, string, 'fyberOfferWall'.
  • phase, string. 'load' - the offerwall has been loaded or failed to load. 'close' - the offerwall has been closed.
  • isError, boolean, true in case of an error loading the offerwall.
  • errorMessage, string, error description. If the offerwall is not available the message would be 'No ad available.'.

fyberVirtualCurrency

Events regarding the virtual currency.

  • name, string, 'fyberVirtualCurrency'.
  • isError, boolean, true in case of an error.
  • errorMessage, string, error description.
  • currencyId, string, currency id.
  • currencyName, string, currency name.
  • deltaOfCoins, number, the difference in the total amount of coins.
  • latestTransactionId, string, transaction id.
  • isDefault, boolean, true if the default currency.

fyber.loadOfferWall()

Load the offerwall. On load a fyberOfferWall event is dispatched.

Syntax

fyber.loadOfferWall()

fyber.isOfferWallLoaded()

Returns true if offerwall is loaded.

Syntax

local is_loaded = fyber.isOfferWallLoaded()
print(is_loaded)

fyber.showOfferWall()

Shows a loaded offerwall.

Syntax

fyber.showOfferWall()

fyber.requestVirtualCurrency()

Requests an update for virtual currencies. A fyberVirtualCurrency event is dispatched.

Syntax

fyber.requestVirtualCurrency()

fyber.setGdprConsentData(params)

params table

  • is_consent_given, boolean, optional. Set to true if user gave consent, false if user refused to give consent or don't set a value to indicate that user didn't do anything.
  • consent_data, string, optional. Consent data.

Syntax

fyber.setGdprConsentData{
	is_consent_given = true,
	consent_data = 'CONSENT DATA'
}

fyber.clearGdprConsentData()

Clears any previous consent information.

Syntax

fyber.clearGdprConsentData()

Contributors

Lerg

Issues