Roku (Brighscript)
Link to repository
GitHub
AppsFlyer Roku SDK integration
AppsFlyer empowers gaming marketers to make better decisions by providing powerful tools that solve real pain points, including cross-platform attribution, mobile and web analytics, deep linking, fraud detection, privacy management and preservation, and more.
Game attribution requires the game to communicate with AppsFlyer APIs over HTTPS and report user activities like first opens, consecutive sessions, and in-app events. For example, purchase events.
We recommend you use this sample app as a reference for integrating AppsFlyer into your Roku channel
AppsFlyerRokuSDK - Interface
AppsFlyerRokuSDK.brs
, included in the source/appsflyer-integration-files
folder, contains the required code and logic to connect to AppsFlyer servers and report events.
Start
This method receives your API key and app ID and initializes the AppsFlyer Module that sends first open and session requests to AppsFlyer.
Signature de la méthode
AppsFlyer().start(<< DEV_KEY >>, << APP_ID >>)
Usage:
' Initialize the AppsFlyer integration (send first-open/session event)
AppsFlyer().start(<< DEV_KEY >>, << APP_ID >>)
Arguments:
APP_ID
: Found via ifAppInfo.DEV_KEY
: Get from the marketer or AppsFlyer HQ.
LogEvent
This method receives an event name and JSON object and sends in-app events to AppsFlyer.
Signature de la méthode
AppsFlyer().logEvent(eventName, trackEventValues)
Usage:
trackEventValues = CreateObject("roAssociativeArray")
trackEventValues = {"af_revenue": 24.22, "af_currency":"ILS", "freeHandParam": "freeHandValue"}
AppsFlyer().logEvent("af_purchase", trackEventValues)
Running the sample app
- Open the
appsflyer-sample-app
folder in VSCode. - In
source/main.brs
, replace the following parameters with your own:
devkey = << DEV_KEY >>
appid = << APP_ID >>
-
Deploy the channel. (Using this plugin makes it easier)
-
After the app loads:
Implementing AppsFlyer in your Roku channel
Setup
- Copy the files from the
appsflyer-integration-files
folder into your project. - Add the following code to your
main.brs
file and Initialize the AppsFlyer integration:
Function Main(args as Dynamic) as Void
...
showAppsflyerChannelSGScreen(args)
...
End Function
sub showAppsflyerChannelSGScreen(args as Dynamic)
screen = CreateObject("roSGScreen")
m.port = CreateObject("roMessagePort")
screen.setMessagePort(m.port)
scene = screen.CreateScene("AppsFlyerScene")
screen.show()
' Initialize the AppsFlyer integration (send first-open/session event)
AppsFlyer().start(DEV_KEY, APP_ID)
' Enable debugging if necessary
AppsFlyer().enableDebugLogs(true) ' same as AppsFlyer().setLogLevel("debug")
if args.Lookup("contentId") <> invalid then
AppsFlyer().trackDeeplink(args)
else
AppsFlyer().trackAppLaunch()
endif
' ConversionData response arrives here
while true
msg = Wait(0, m.port)
?"MESSAGE RECEIVED: "msg.GetData()
msgType = Type(msg)
if msgType = "roSGScreenEvent"
if msg.isScreenClosed() then
return
end if
end if
end while
end sub
- Report in-app events.
Mis(e) à jour il y a 2 mois