Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript support #189

Open
danstepanov opened this issue Feb 5, 2021 · 3 comments
Open

Typescript support #189

danstepanov opened this issue Feb 5, 2021 · 3 comments

Comments

@danstepanov
Copy link

Does this project have type definitions?

Please include the following information for better support

The more context you provide around this issue the faster the community can help you

Did you follow all the instructions as specified in the Twilio Quickstart repositories? yes
What version of React Native are you running? ~0.63.4
What version of react-native-twilio-programmable-voice are you running? ^4.3.0
What device are you using? (e.g iOS10 simulator, Android 7 device)? n/a
Is your app running in foreground, background or not running? n/a
Is there any relevant message in the log? Could not find a declaration file for module 'react-native-twilio-programmable-voice'.
If using iOS, which pod version are you using? ~> 5.2.0

Step to reproduce
(1) import TwilioVoice from 'react-native-twilio-programmable-voice' in a typescript project

Advanced:
Have you tried adding break point using AndroidStudio or XCode and analyse the logs? n/a
can share a project with issue?
Did you try to reinstall the pods completely? yes

@jdegger
Copy link
Collaborator

jdegger commented Feb 8, 2021

Not at the moment. I will add it to the backlog but our backlog is long already. I don't expect it to be implemented anytime soon.

@fabriziomoscon
Copy link
Collaborator

@danstepanov feel free to send a PR for this.

@fiddur
Copy link

fiddur commented May 28, 2021

I hacked together what I see in the README, plus the undocumented removeEventListener that seems to be used in our code at least. Don't have time to make a proper PR right now, but here's the types:

declare module "react-native-twilio-programmable-voice" {
    function accept(): void
    function connect({ To }: { To: string }): void
    function configureCallKit({
        appName,
        imageName,
        ringtoneSound,
    }: {
        appName: string
        imageName?: string
        ringtoneSound?: string
    }): void
    function disconnect(): void
    function getActiveCall(): Promise<boolean> // Not sure what the promise "activeCall" contains.
    function getCallInvite(): Promise<boolean> // Not sure what the promise "callInvite" contains.
    function hold(holdValue: boolean): void
    function ignore(): void
    function initWithToken(accessToken: string): Promise<boolean>
    function reject(): void
    function sendDigits(digits: string): void
    function setMuted(mutedValue: boolean): void
    function setSpeakerPhone(speakerEnabled: boolean): void
    function unregister(): void

    function addEventListener(type: "deviceReady", cb: () => void): void
    function addEventListener(type: "deviceNotReady", cb: ({ err: string }) => void): void
    function addEventListener(type: "callRejected", cb: (value: "callRejected") => void): void
    function addEventListener(
        type: "connectionDidConnect" | "callStateRinging",
        cb: (data: {
            call_sid: string
            call_state: "CONNECTED" | "ACCEPTED" | "CONNECTING" | "RINGING" | "DISCONNECTED" | "CANCELLED"
            call_from: string
            call_to: string
        }) => void,
    ): void
    function addEventListener(
        type:
            | "connectionIsReconnecting"
            | "connectionDidReconnect"
            | "callInviteCancelled"
            | "deviceDidReceiveIncoming",
        cb: (data: { call_sid: string; call_from: string; call_to: string }) => void,
    ): void
    function addEventListener(
        type: "connectionDidDisconnect",
        cb: (
            data:
                | null
                | { err: string }
                | {
                      call_sid: string
                      call_state: "CONNECTED" | "ACCEPTED" | "CONNECTING" | "RINGING" | "DISCONNECTED" | "CANCELLED"
                      call_from: string
                      call_to: string
                      err?: string
                  },
        ) => void,
    ): void
    function addEventListener(type: "proximity", cb: (data: { isNear: boolean }) => void): void
    function addEventListener(
        type: "wiredHeadset",
        cb: (data: { isPlugged: boolean; hasMic: boolean; deviceName: string }) => void,
    ): void

    function removeEventListener(type: string, cb: function): void
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants