Public API Reference
Public Flutter API Reference (PitelVoipClient)
Import package:flutter_pitel_voip_v2/flutter_pitel_voip_v2.dart and use PitelVoipClient.instance.
Client state and core methods
| Member | Type / parameters | Meaning |
|---|---|---|
PitelVoipClient.instance | PitelVoipClient | Singleton client. |
isLoggedIn | bool | Current client registration flag; observe onRegistrationStateChanged for updates. |
registrationState | PitelRegistrationState | Latest local state: notRegistered, connecting, or registered. |
events | Stream<PitelCallEvent> | Broadcast stream of call/control events. |
onRegistrationStateChanged | Stream<PitelRegistrationState> | Registration state updates. Only registered means SIP is ready. |
login(settings) | PitelSettings → Future<void> | Starts native registration and saves settings for a later autoLogin(). Completion does not prove SIP registration succeeded. |
autoLogin() | Future<bool> | Attempts restore from SDK-saved settings. false means no saved registration intent or the attempt could not start; true means the command was accepted or the client was already registered; observe the registration stream. |
logout() | Future<void> | Unregisters and clears settings saved by the SDK. |
refreshRegistrationState() | Future<PitelRegistrationState> | Reads native registration state and updates the client state. |
waitForRegistration([timeout]) | optional Duration, default 3.5 seconds → Future<bool> | Waits for a registered event until timeout. |
makeCall(to:, callerName:) | required String to; optional String? callerName → Future<void> | Starts an outgoing call. Accepts an extension or SIP URI; the SDK formats a bare destination using saved domain and port. |
hangup() | Future<void> | Ends the active or connecting call. |
mute() / unmute() | Future<void> | Mutes or restores the local microphone. |
hold() / unhold() | Future<void> | Holds or resumes the active call. |
sendDTMF(dtmf) | String dtmf → Future<void> | Sends DTMF digits during a call. |
transferCall(to) | String to → Future<void> | Transfers the active call to a destination. |
setFCMToken(token) | String token → Future<void> | Android currently saves the token locally and does not re-register SIP on token change. iOS updates the stored token and may trigger re-registration. Future completion is not backend acknowledgement. |
handlePushNotification(data) | Map<String, String> → Future<bool> | Passes a delivered data payload to native handling where appropriate. It does not replace Android's native FCM service or iOS PushKit. |
hasRequiredPermissions() / requestPermissions() | Future<bool> | Checks or requests call permissions exposed by the SDK. Check again before placing each call. |
setUIConfig(uiConfig) | PitelUIConfig → Future<void> | Dynamically updates the native call UI configuration (colors, texts, visibility) at runtime without re-registering SIP. Also caches the configuration for autoLogin(). |
getFullScreenIntentStatus() | Future<FullScreenIntentStatus> | Android FSI status; FullScreenIntentStatus is exported by the public entry point. Names are granted, notGranted, notDeclared, notRequired, unsupported. See the FSI guide. |
openFullScreenIntentSettings() | Future<bool> | Opens Android special app access settings. Call from a user-initiated action; do not open settings automatically at startup. |
Event streams
| Stream / event | Useful fields | Purpose |
|---|---|---|
onRegistrationStateChanged | PitelRegistrationState | Emits notRegistered, connecting, or registered. Only registered means SIP is ready. |
events | PitelCallEvent | Broadcast stream of call and control events. |
PitelIncomingCallEvent | callerName, callerId, uuid | Reports an incoming call. Android may provide an empty uuid; do not assume it is always a platform call identifier. |
PitelCallStateChangedEvent | state, duration, statusCode (default 0), reason, cause | Reports call state changes. Some values may be absent or platform-dependent. |
PitelCallDisconnectedEvent | statusCode, reason, cause | Reports why a call ended. |
PitelMuteChangedEvent / PitelHoldChangedEvent | isMuted / isHeld | Reports mute and hold changes. |
PitelAudioRouteChangedEvent | route | Reports audio route changes. |
PitelCallState values are idle, incoming, calling, connecting, active, held, disconnected, and unknown. PitelAudioRoute values are earpiece, speaker, bluetooth, wiredHeadset, and unknown. Native event values can map to unknown when the platform sends an unrecognized value.
PitelVoipException exposes code, message, and optional details; catch it around login/call/control operations and show a safe message to the user. Native/backend behavior can also vary by platform, so retain sanitized error details for support. The deprecated PitelVoip facade remains for compatibility; new integrations should use PitelVoipClient.
Cancel StreamSubscriptions when their owning screen or controller is disposed. See call disconnect codes for SIP causes and user-facing descriptions.