4. Call the Inference API
Configure the Airflux SDK to request an inference decision before displaying an interstitial ad. Based on the AI's response, you can decide whether to proceed with showing the ad. This process allows for smarter, more revenue-optimized ad delivery.

1. Set up the API Call and callbacks
Use the Airflux.RequestInference() function with the SHOW_INTERSTITIAL_AD method to request a real-time ad decision. To ensure the AI makes an accurate decision, you must provide detailed contextual parameters and implement the appropriate callbacks.
Code Example
Airflux.RequestInference(
AirfluxInference.SHOW_INTERSTITIAL_AD(
parameters: new Dictionary<string, object>
{
{ AirfluxParameter.AD_TYPE, "interstitial_ad" },
{ AirfluxParameter.AD_PLACEMENT_ID, "placement_3" },
{ AirfluxParameter.AD_PLACEMENT_TYPE, "static" },
{ AirfluxParameter.AD_PLACEMENT_POSITION, "stage_start" },
{ AirfluxParameter.STAGE, 10 },
{ AirfluxParameter.STAGE_TYPE, "primary_stage" },
{ AirfluxParameter.TOTAL_FINISHED_STAGE, 10 },
{ AirfluxParameter.STAGE_RESULT, "success" },
{
AirfluxAttribute.AD_COOLDOWN_SECONDS, new Dictionary<string, object>
{
{ "rewarded_ad", 10 },
{ "interstitial_ad", 20 }
}
},
{
AirfluxAttribute.REWARD_ITEMS, new Dictionary<string, object>
{
{ "coin", 500 },
{ "gem", 10 }
}
}
},
onShowAd: () => {
// AI determined to show the ad. Implement your logic here.
Debug.Log("AI decided to show ad.");
// Your function to display the interstitial ad
},
onSkipAd: () => {
// AI determined to skip the ad. Implement your logic here.
Debug.Log("AI decided to skip ad.");
// Your function to continue gameplay without showing ads
},
onDefaultAdPolicy: () => {
// Implement your internal logic to decide whether to show or skip the ad.
Debug.Log("AI returned default policy. Implementing internal logic.");
// Your function for default ad decision logic
},
onFailure: (error) => {
// Inference request failed. Implement your internal logic to handle the error
// and decide whether to show or skip the ad based on your game's policy.
Debug.Log($"Inference request failed: {error.Message}. Falling back to default policy.");
// Your function for default ad decision logic on error
}
)
);Verification
2. Deploy the app
After completing sufficient QA and crash testing, deploy your gaming app. To ensure proper integration with Airflux, make sure the deployment follows the timeline coordinated with the Growth Manager.
Next steps
Congratulations! If you have completed the steps above, you are all set to optimize your in-game advertising with Airflux. Click here to learn how to receive your optimization results.
Frequently Asked Questions
Last updated

