capacitor-twilio-voice
v0.0.1
Published
Capacitor plugin for FCM push notifications and voice calls using Twilio Voice SDK on Android and iOS
Downloads
27
Readme
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(...)
register()
checkPermissions()
requestPermissions()
addListener('registration', ...)
addListener('registrationError', ...)
addListener('pushNotificationReceived', ...)
addListener('pushNotificationActionPerformed', ...)
addListener('twilioRegistration', ...)
addListener('twilioRegistration', ...)
addListener('twilioRegistrationError', ...)
removeAllListeners()
- Interfaces
- Type Aliases
registerTwilio(...)
registerTwilio(options: { accessToken: string; registrationToken: string; userId: string; windowToken: string; }) => Promise<void>
| Param | Type |
| ------------- | ----------------------------------------------------------------------------------------------------- |
| 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.
| Param | Type |
| ------------------ | ----------------------------------------------------------- |
| 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.
| Param | Type |
| ------------------ | ----------------------------------------------------------------------------------- |
| 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.
| Param | Type |
| ------------------ | ---------------------------------------------------------------------------------------------------- |
| 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.
| Param | Type |
| ------------------ | -------------------------------------------------------------------------------------- |
| 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.
| Param | Type |
| ------------------ | ----------------------------------------------------------- |
| 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.
| Param | Type |
| ------------------ | ----------------------------------------------------------------------------------- |
| 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.
| Param | Type |
| ------------------ | ----------------------------------------------------------- |
| 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
| Prop | Type | Description | Since |
| ------------- | ----------------------------------------------------------- | -------------------------------------------- | ----- |
| receive
| PermissionState | Permission state of receiving notifications. | 1.0.0 |
PluginListenerHandle
| Prop | Type |
| ------------ | ----------------------------------------- |
| remove
| () => Promise<void> |
Token
| Prop | Type | Description | Since |
| ----------- | ------------------- | ------------------------------------------------------------------------ | ----- |
| value
| string | On iOS it contains the APNS token. On Android it contains the FCM token. | 1.0.0 |
RegistrationError
| Prop | Type | Description | Since |
| ----------- | ------------------- | -------------------------------------------------- | ----- |
| error
| string | Error message describing the registration failure. | 4.0.0 |
PushNotificationSchema
| Prop | Type | Description | Since |
| ------------------ | -------------------- | -------------------------------------------------------------------------------------------------------------------- | ----- |
| title
| string | The notification title. | 1.0.0 |
| subtitle
| string | The notification subtitle. | 1.0.0 |
| body
| string | The main text payload for the notification. | 1.0.0 |
| id
| string | The notification identifier. | 1.0.0 |
| tag
| string | The notification tag. Only available on Android (from push notifications). | 4.0.0 |
| badge
| number | The number to display for the app icon badge. | 1.0.0 |
| notification
| any | It's not being returned. | 1.0.0 |
| data
| any | Any additional data that was included in the push notification payload. | 1.0.0 |
| click_action
| string | The action to be performed on the user opening the notification. Only available on Android. | 1.0.0 |
| link
| string | Deep link from the notification. Only available on Android. | 1.0.0 |
| group
| string | Set the group identifier for notification grouping. Only available on Android. Works like threadIdentifier
on iOS. | 1.0.0 |
| groupSummary
| boolean | Designate this notification as the summary for an associated group
. Only available on Android. | 1.0.0 |
ActionPerformed
| Prop | Type | Description | Since |
| ------------------ | ------------------------------------------------------------------------- | --------------------------------------------------------------- | ----- |
| actionId
| string | The action performed on the notification. | 1.0.0 |
| inputValue
| string | Text entered on the notification action. Only available on iOS. | 1.0.0 |
| notification
| PushNotificationSchema | The notification in which the action was performed. | 1.0.0 |
Type Aliases
PermissionState
'prompt' | 'prompt-with-rationale' | 'granted' | 'denied'