Documentation Index
Fetch the complete documentation index at: https://docs.stringboot.com/llms.txt
Use this file to discover all available pages before exploring further.
The FAQ Provider allows you to manage and deliver multilingual FAQs dynamically. It uses the same offline-first architecture as the string system.
Features
- Offline-First: FAQs are cached locally in the Room database.
- Tagging: Filter FAQs by tags (e.g., “payments”, “account”) and sub-tags.
- Reactive: Listen for updates using Kotlin Flows.
Initialization
Before using the FAQ Provider, ensure the Stringboot SDK is initialized in your Application class:
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
// Initialize the main SDK first
StringProvider.initialize(
context = this,
apiToken = "YOUR_API_TOKEN"
)
// Initialize FAQ Provider separately
FAQProvider.initialize(
context = this,
cacheSize = 200 // Optional: Configure cache size
)
}
}
Usage
Fetching FAQs
Use FAQProvider.getFAQs() to fetch a list of FAQs.
lifecycleScope.launch {
// Fetch all FAQs with tag "payments"
val faqs = FAQProvider.getFAQs(tag = "payments")
faqs.forEach { faq ->
println("Q: ${faq.question}")
println("A: ${faq.answer}")
}
}
Reactive Flow
Use getFAQsFlow() to observe changes:
lifecycleScope.launch {
FAQProvider.getFAQsFlow(tag = "payments")
.collect { faqs ->
// Update RecyclerView or Compose list
adapter.submitList(faqs)
}
}
You can filter by sub-tags to get more specific results:
val refundFAQs = FAQProvider.getFAQs(
tag = "payments",
subTags = listOf("refunds")
)
Syncing
FAQs are synced automatically, but you can force a refresh:
lifecycleScope.launch {
val success = FAQProvider.refreshFromNetwork()
if (success) {
Log.d("Stringboot", "FAQs updated")
}
}