callbundle_platform_interface 1.0.14
callbundle_platform_interface: ^1.0.14 copied to clipboard
Platform interface for the CallBundle federated Flutter plugin. Defines the abstract API contract, data models, and events for native call UI.
callbundle_platform_interface #
The platform interface for the callbundle plugin.
This package provides the abstract API contract and data models that all platform implementations must conform to.
Overview #
| Component | Description |
|---|---|
CallBundlePlatform |
Abstract class all implementations extend |
MethodChannelCallBundle |
Default MethodChannel-based implementation |
NativeCallConfig |
Plugin configuration (app name, platform options) |
BackgroundRejectConfig |
Native HTTP reject config for killed-state decline |
RefreshTokenConfig |
Token refresh config for automatic 401 retry |
NativeCallParams |
Incoming/outgoing call parameters |
NativeCallEvent |
Events from native to Dart |
NativeCallInfo |
Active call state |
NativeCallPermissions |
Permission status with diagnostics |
NativeCallType |
Voice/video enum |
NativeCallState |
Call state enum (ringing, active, held, ended) |
NativeCallEventType |
Event type enum |
PermissionStatus |
Permission states |
NativeHandleType |
Phone/email/generic handle types |
MethodChannel Contract #
Channel: com.callbundle/main
Dart to Native #
| Method | Arguments | Description |
|---|---|---|
configure |
Map |
Initialize with config |
showIncomingCall |
Map |
Show incoming call UI |
showOutgoingCall |
Map |
Show outgoing call UI |
endCall |
String |
End specific call |
endAllCalls |
— | End all calls |
setCallConnected |
String |
Mark call connected |
getActiveCalls |
— | Get active call list |
checkPermissions |
— | Check status (no prompts) |
requestPermissions |
— | Request (triggers dialogs) |
requestBatteryOptimizationExemption |
— | Request Doze exemption (Android) |
getVoipToken |
— | Get iOS VoIP token |
dispose |
— | Release resources |
Native to Dart #
| Method | Arguments | Description |
|---|---|---|
onCallEvent |
Map |
Call event delivery |
onVoipTokenUpdated |
String |
VoIP token update |
onReady |
— | Native initialization complete |
Creating a Custom Implementation #
To implement a new platform (e.g., Web, Windows):
import 'package:callbundle_platform_interface/callbundle_platform_interface.dart';
class CallBundleWeb extends CallBundlePlatform {
static void registerWith() {
CallBundlePlatform.instance = CallBundleWeb();
}
@override
Future<void> configure(NativeCallConfig config) async {
// Your implementation
}
// ... implement all abstract methods
}
Register in pubspec.yaml:
flutter:
plugin:
implements: callbundle
platforms:
web:
dartPluginClass: CallBundleWeb
Data Models #
NativeCallConfig #
Top-level plugin configuration with platform-specific sub-configs:
appName— Display name for the appandroid—AndroidCallConfigwith TelecomManager, notification, and OEM settingsios—IosCallConfigwith CallKit, video, and recents settingsbackgroundReject—BackgroundRejectConfigfor killed-state native HTTP reject
NativeCallParams #
Parameters for showing incoming/outgoing calls:
callId— Unique identifiercallerName— Display namehandle— Phone number or SIP addresscallType— Voice or videoduration— Auto-dismiss timeout in millisecondsextra— Pass-through metadata (survives cold-start)android/ios— Platform-specific options
NativeCallEvent #
Events delivered from native to Dart:
type— Event type (accepted, declined, ended, incoming, missed, timedOut)callId— Which call this event belongs toisUserInitiated—truefor user taps,falsefor programmatic/systemextra— Pass-through metadata from the original calleventId— Monotonic ID for deduplicationtimestamp— When the event occurred
NativeCallPermissions #
Comprehensive permission status with OEM diagnostics:
notificationPermission— Notification permission statusfullScreenIntentPermission— Full-screen intent (Android 14+)phoneAccountEnabled— TelecomManager account registeredbatteryOptimizationExempt— Doze mode exemption statusmanufacturer,model,osVersion— Device infoisFullyReady— All critical permissions granted
BackgroundRejectConfig #
Native HTTP reject configuration for killed-state decline:
urlPattern— URL with{key}placeholdershttpMethod— HTTP method (default: PUT)authStorageKey— Key influtter_secure_storagefor Bearer tokenheaders,body— Request headers and body with placeholder supportrefreshToken—RefreshTokenConfigfor automatic 401 retry
RefreshTokenConfig #
Automatic token refresh when native reject receives 401:
url— Refresh token endpointrefreshTokenKey— Key influtter_secure_storagefor refresh tokenbodyTemplate— Request body with{refreshToken}placeholderaccessTokenJsonPath— Dot-notation path to new access token in responserefreshTokenJsonPath— Dot-notation path to new refresh token (if rotated)
Note on Breaking Changes #
Strongly prefer non-breaking changes (such as adding a method to the interface) over breaking changes for this package.