appnext.setPreferredOrientation()

Type Function
Return value none
Revision Release 2024.3703
Keywords ads, advertising, Appnext, setPreferredOrientation
See also appnext.getPreferredOrientation()
appnext.*

Overview

Sets the preferred orientation, assuming both landscape and portrait are supported by the application.

Syntax

appnext.setPreferredOrientation( adKey, preferredOrientation )
adKey (required)

String. The ad key returned for a previously created ad.

preferredOrientation (required)

String. The preferred orientation to be set for the ad. Possible values are "automatic", "landscape", and "portrait" (default is "automatic").

Example

local appnext = require( "plugin.appnext" )

local function adListener( event )
    print( "Received " .. event.event .. " for " .. event.adKey .. " with message: " .. event.message )
end

-- Initialize the Appnext plugin
appnext.init( adListener )

-- Create your ads
local fullscreenPlacementID

local platform = system.getInfo( "platformName" )
if ( platform == "iPhone OS" ) then
    fullscreenPlacementID = "YOUR_IOS_FULLSCREEN_PLACEMENT_ID"
elseif ( platform == "Android" ) then
    fullscreenPlacementID = "YOUR_ANDROID_FULLSCREEN_PLACEMENT_ID"
end

local fullscreenAdKey = appnext.createAd( "fullscreen", fullscreenPlacementID )

appnext.setPreferredOrientation( fullscreenAdKey, "landscape" )