Spam Call Protection
SDK for spam call identification and blocking. Integrates with native call systems on iOS and Android.
Authentication is handled by the SDK
Initialize the SDK with the credentials issued during onboarding. The SDK obtains and refreshes the JWT Bearer token internally, so you do not manage tokens yourself. The Authorization: Bearer token described in Authentication is what the SDK uses under the hood for direct REST calls. The SDK syncs with the /calls/database endpoint on your behalf.
Features
- Updatable spam number database
- Real-time call identification
- Configurable automatic blocking
- Spam number reporting
- Integration with Call Directory (iOS) and Call Screening (Android)
Installation
iOS (Swift Package Manager)
swift
dependencies: [
.package(url: "https://github.com/dguard/dguard-call-ios.git", from: "1.0.0")
]Android (Gradle)
gradle
implementation 'io.dguard:call-filter-sdk:1.0.0'Basic Usage
iOS
swift
import DGuardCallFilter
// Initialize
let callFilter = DGuardCallFilter(apiKey: "your_api_key")
// Check Number
let result = callFilter.checkNumber("+34900123456")
if result.isSpam {
print("Spam detected: \(result.spamType)")
print("Reports: \(result.reportCount)")
}
// Update Database & Call Directory
callFilter.updateDatabase { success in
if success {
callFilter.reloadCallDirectoryExtension()
}
}
// Report Number
callFilter.reportNumber(
phoneNumber: "+34900123456",
spamType: .telemarketing,
comment: "Repeated advertising calls"
)Android
kotlin
import io.dguard.call.DGuardCallFilter
// Initialize
val callFilter = DGuardCallFilter.Builder(context)
.apiKey("your_api_key")
.autoBlock(true) // Automatic blocking
.build()
// Register as Call Screening Service
callFilter.registerAsCallScreeningService()
// Check Number
val result = callFilter.checkNumber("+34900123456")
if (result.isSpam) {
Log.w("Call", "Spam: ${result.spamType}")
}
// Blocking Levels
callFilter.setBlockingLevel(BlockingLevel.AGGRESSIVE) // NONE, MODERATE, AGGRESSIVEiOS - Call Directory Extension
Configure Call Directory Extension in your iOS project:
swift
// CallDirectoryHandler.swift
import CallKit
import DGuardCallFilter
class CallDirectoryHandler: CXCallDirectoryProvider {
let callFilter = DGuardCallFilter(apiKey: "your_api_key")
override func beginRequest(with context: CXCallDirectoryExtensionContext) {
// Add blocked numbers
let blockedNumbers = callFilter.getBlockedNumbers()
for number in blockedNumbers {
context.addBlockingEntry(withNextSequentialPhoneNumber: number)
}
// Add call identification
let identifiedNumbers = callFilter.getIdentifiedNumbers()
for (number, label) in identifiedNumbers {
context.addIdentificationEntry(
withNextSequentialPhoneNumber: number,
label: label
)
}
context.completeRequest()
}
}API Endpoint
The SDK syncs with the DGuard API:
GET
/calls/databaseGet spam call database
Required Permissions
Android
xml
<!-- Call Filter -->
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_CALL_LOG" />
<uses-permission android:name="android.permission.ANSWER_PHONE_CALLS" />iOS Capabilities
- Call Directory Extension
- App Groups (for data sharing)