Skip to main content

Initialization

✅ DO:
  • Initialize in Application.onCreate()
  • Use Application context
  • Enable debug mode when needed for troubleshooting (publisher’s choice)
  • Handle initialization callbacks
❌ DON’T:
  • Initialize in Activity
  • Use Activity context
  • Initialize multiple times unnecessarily

Ad Loading

✅ DO:
  • Provide meaningful context (user query, AI response, conversation history, additional context)
  • Handle errors gracefully (e.g. hide ad view or show fallback)
  • Track ad events for analytics
  • Use appropriate ad dimensions
❌ DON’T:
  • Use empty or placeholder context
  • Block the UI thread
  • Ignore error callbacks
  • Use incorrect dimensions

Memory Management

✅ DO:
  • Call destroyAd() for every VelocityNativeAd in onDestroy()
  • Clear ad views when not needed
  • Use weak references where appropriate
❌ DON’T:
  • Keep ad views after Activity is destroyed

Error Handling

✅ DO:
override fun onAdFailedToLoad(nativeAd: VelocityNativeAd, error: VelocityAdsError) {
    Log.e("Ad", "Error: $error")
    // Show fallback content or hide ad space
    hideAdView()
}
❌ DON’T:
override fun onAdFailedToLoad(nativeAd: VelocityNativeAd, error: VelocityAdsError) {
    // Don't ignore errors
    // Don't crash the app
}