0.0.1 • Published 1 year ago

capacitor-twilio-voice v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

capacitor-twilio-voice

Capacitor plugin for FCM push notifications and voice calls using Twilio Voice SDK on Android and iOS

Install

npm install capacitor-twilio-voice
npx cap sync

API

registerTwilio(...)

registerTwilio(options: { accessToken: string; registrationToken: string; userId: string; windowToken: string; }) => Promise<void>
ParamType
options{ accessToken: string; registrationToken: string; userId: string; windowToken: string; }

register()

register() => Promise<void>

Register the app to receive push notifications.

This method will trigger the 'registration' event with the push token or 'registrationError' if there was a problem. It does not prompt the user for notification permissions, use requestPermissions() first.

Since: 1.0.0


checkPermissions()

checkPermissions() => Promise<PermissionStatus>

Check permission to receive push notifications.

On Android the status is always granted because you can always receive push notifications. If you need to check if the user allows to display notifications, use local-notifications plugin.

Returns: Promise<PermissionStatus>

Since: 1.0.0


requestPermissions()

requestPermissions() => Promise<PermissionStatus>

Request permission to receive push notifications.

On Android it doesn't prompt for permission because you can always receive push notifications.

On iOS, the first time you use the function, it will prompt the user for push notification permission and return granted or denied based on the user selection. On following calls it will currect status of the permission without prompting again.

Returns: Promise<PermissionStatus>

Since: 1.0.0


addListener('registration', ...)

addListener(eventName: 'registration', listenerFunc: (token: Token) => void) => Promise<PluginListenerHandle> & PluginListenerHandle

Called when the push notification registration finishes without problems.

Provides the push notification token.

ParamType
eventName'registration'
listenerFunc(token: Token) => void

Returns: Promise<PluginListenerHandle> & PluginListenerHandle

Since: 1.0.0


addListener('registrationError', ...)

addListener(eventName: 'registrationError', listenerFunc: (error: RegistrationError) => void) => Promise<PluginListenerHandle> & PluginListenerHandle

Called when the push notification registration finished with problems.

Provides an error with the registration problem.

ParamType
eventName'registrationError'
listenerFunc(error: RegistrationError) => void

Returns: Promise<PluginListenerHandle> & PluginListenerHandle

Since: 1.0.0


addListener('pushNotificationReceived', ...)

addListener(eventName: 'pushNotificationReceived', listenerFunc: (notification: PushNotificationSchema) => void) => Promise<PluginListenerHandle> & PluginListenerHandle

Called when the device receives a push notification.

ParamType
eventName'pushNotificationReceived'
listenerFunc(notification: PushNotificationSchema) => void

Returns: Promise<PluginListenerHandle> & PluginListenerHandle

Since: 1.0.0


addListener('pushNotificationActionPerformed', ...)

addListener(eventName: 'pushNotificationActionPerformed', listenerFunc: (notification: ActionPerformed) => void) => Promise<PluginListenerHandle> & PluginListenerHandle

Called when an action is performed on a push notification.

ParamType
eventName'pushNotificationActionPerformed'
listenerFunc(notification: ActionPerformed) => void

Returns: Promise<PluginListenerHandle> & PluginListenerHandle

Since: 1.0.0


addListener('twilioRegistration', ...)

addListener(eventName: 'twilioRegistration', listenerFunc: (token: Token) => void) => Promise<PluginListenerHandle> & PluginListenerHandle

Called when the twilio registration finishes without problems.

ParamType
eventName'twilioRegistration'
listenerFunc(token: Token) => void

Returns: Promise<PluginListenerHandle> & PluginListenerHandle


addListener('twilioRegistration', ...)

addListener(eventName: 'twilioRegistration', listenerFunc: (error: RegistrationError) => void) => Promise<PluginListenerHandle> & PluginListenerHandle

Called when the twilio registration finishes without problems.

Provides the fcm notification token.

ParamType
eventName'twilioRegistration'
listenerFunc(error: RegistrationError) => void

Returns: Promise<PluginListenerHandle> & PluginListenerHandle


addListener('twilioRegistrationError', ...)

addListener(eventName: 'twilioRegistrationError', listenerFunc: (token: Token) => void) => Promise<PluginListenerHandle> & PluginListenerHandle

Called when the twilio registration finishes with problems.

Provides an error with the registration problem.

ParamType
eventName'twilioRegistrationError'
listenerFunc(token: Token) => void

Returns: Promise<PluginListenerHandle> & PluginListenerHandle


removeAllListeners()

removeAllListeners() => Promise<void>

Remove all native listeners for this plugin.

Since: 1.0.0


Interfaces

PermissionStatus

PropTypeDescriptionSince
receivePermissionStatePermission state of receiving notifications.1.0.0

PluginListenerHandle

PropType
remove() => Promise<void>

Token

PropTypeDescriptionSince
valuestringOn iOS it contains the APNS token. On Android it contains the FCM token.1.0.0

RegistrationError

PropTypeDescriptionSince
errorstringError message describing the registration failure.4.0.0

PushNotificationSchema

PropTypeDescriptionSince
titlestringThe notification title.1.0.0
subtitlestringThe notification subtitle.1.0.0
bodystringThe main text payload for the notification.1.0.0
idstringThe notification identifier.1.0.0
tagstringThe notification tag. Only available on Android (from push notifications).4.0.0
badgenumberThe number to display for the app icon badge.1.0.0
notificationanyIt's not being returned.1.0.0
dataanyAny additional data that was included in the push notification payload.1.0.0
click_actionstringThe action to be performed on the user opening the notification. Only available on Android.1.0.0
linkstringDeep link from the notification. Only available on Android.1.0.0
groupstringSet the group identifier for notification grouping. Only available on Android. Works like threadIdentifier on iOS.1.0.0
groupSummarybooleanDesignate this notification as the summary for an associated group. Only available on Android.1.0.0

ActionPerformed

PropTypeDescriptionSince
actionIdstringThe action performed on the notification.1.0.0
inputValuestringText entered on the notification action. Only available on iOS.1.0.0
notificationPushNotificationSchemaThe notification in which the action was performed.1.0.0

Type Aliases

PermissionState

'prompt' | 'prompt-with-rationale' | 'granted' | 'denied'