I'm working on iOS app that blocks incoming spam calls. I'm going to use CallKit. When someone is calling, I'd like to send a request to backend API to check whether the phone number is marked as spam in database. I learned that I have to use CXCallDirectoryProvider. But I heard that iOS doesn't allow sending network requests from CXCallDirectoryProvider implementation. Is it true? Should I have a local database with spam phone numbers in my app?
I didn't test it on device yet, just trying to figure out the most appropriate architecture. Services like TrueCNAM do not allow to pull the whole database. They only provide an API that allows to check one phone number per request.
Related
I'm looking through documention but didn't find anything that can help me find registered clients to twilio voice incoming calls.
For example. I have 10 registered clients to javascript sdk, that can handle incoming calls by their identities. But on my backend I need to find out who is registered and who is not busy making another call.
Is there any endpoint or someting that can return list of users(identites, clients, devices) with their status?
Because with TwiML I can redirect incoming call up to 10 clients. But when I don't know who is ready to answer and not busy I can't redirect responsible.
Thanks for any leads.
Twilio developer evangelist here.
I'm afraid that there isn't a way to list your currently registered clients. But you have a couple of options with how to deal with this.
You could keep a list of your registered clients manually. Adding a client to the list as they log in and removing them when they disconnect.
Alternatively, you could consider using TaskRouter to keep track of this and control the passing out of incoming call tasks to available agents. Then the agents would log on and enter an idle status in TaskRouter, when they accept a call they would be busy, once the call is over they go through a wrapping up stage before you return them to idle and ready for another call.
I resolved it with another way. When the user connects a device to twilio, I put him in the presence group with WS. When the device starts calling, I put him in another presence group. On the backend, when recieving calls, I just check who is in the ready group and not in the calling one and connect him with this incoming call.
There are two things that are unclear to me about TwilioVoice for iOS, after having followed the quickstart demo.
First, I want my app to be only able to receive phone calls, and not to make some. So I want to know, do I really need to call TwilioVoice.register(accessToken)? Or something with CallKit would be enough?
My other question is about access tokens. In the quickstart demo, an access token is fetched every time the user enters ViewController, but since I only want to be able to receive phone calls, I was thinking of fetching access token only in the AppDelegate, but I wonder if I would have issues with the token lifetime?
Thank you for your help,
Yes, you still need register your device. When user A makes a call to user B, Twilio needs user B's device to be registered so they know where to send the VoIP push notification to. CallKit manages the local on-device call state, it doesn't provide the network side of the call. Twilio provides the network side of the call.
You're correct with this. In our application, we register any time application(_:didRegisterForRemoteNotificationsWithDeviceToken) is called since that's the method that provides your application with the device token you need to pass to Twilio.
I'd caution against taking Twilio's sample project as a good sample project. I had to rework most of what they did in their example when I built our implementation. There's WAY more state management that needs to be done to nicely integrate with CallKit.
I am building an app using Twilio to send out text messages and phone calls. It works great but I know there are limits to the amount of messages to send out per number in any given day. The app is going to be used to send out messages in the thousands at times, for instance to alert contacts about weather cancellations.
Since I am still developing, I do not want to send out real messages to thousands of real numbers a bunch of times while I test and configure my code.
Is there any phone apis, lists, etc. of dummy numbers that can be used as my example contacts that will at least return some form of TRUE that the number exists and received my call/message? Or return something else if I hit a use limit because of the number of messages I am sending.
I think I could get everything setup with a list of 1000 numbers since I can plan out every 250-500 calls, do this or that.
Twilio developer evangelist here.
There are no lists like that that I know of.
You do have a set of test credentials that you can use to send messages to a few "magic" numbers that will behave as if the message was successful (or failed for some reason). However there's only one success message here.
The thing about the limits of 200-250 messages per number per day is that they aren't hard limits. They are just around the level that carriers will start to consider blocking your messages. At that point you will likely still get a positive response from the Twilio API as a message is queued to be sent, but it may or may not fail at delivery time.
I recommend you look into Twilio's messaging services, they allow you to create a number pool that messages are sent from. If you are sending a number of the same messages at the same time, you can also check out Twilio Notify for sending notifications. I recently wrote up a blog post on how to set up a messaging service, number pool and Notify for bulk SMS.
Let me know if that helps at all.
what I am trying to achieve is to make a VoIP call from an iPhone to an iPhone using Twilio.
To do that I'm using the iOS SDK, the Twilio Voice to be more specific as the iOS SDK is superseded.
I have a server that generates an access token and when I create a call the Twilio API would make a request to my server and I would return a <Dial /> keyword with the client name and the connection would be established.
The problem is, this counts as two calls(iOS app to Twilio is the first one and when I return a TwML <Dial /> response is the second one) so the price is practically doubled.
Is there a way to make it as a single iOS app to an iOS app call? All my server does is to generate the TWiML using the parameters that are sent from the client anyway.
Oh and also in the documentation there are some talks about capability tokens but all the current documentation is using Access Tokens.
Are capability tokens relics of the past for the older API?
Thanks
Twilio developer evangelist here.
Twilio calls are always priced per leg, so in a call between two people you do always pay for the outgoing leg and the incoming leg. They may also have different lengths, if the outgoing call goes through some other TwiML before making the <Dial> for example.
However, if all you want to do is make calls between applications and you don't need to be able to make calls to the phone network then can I recommend you take a look at the Twilio Video project. While it is called "Video" you can use the SDK to make audio calls between apps too. And if you choose to create peer-to-peer rooms, then the audio stream is sent directly between the two devices and not charged as a call leg at all. The only extra thing you need to do is to generate the call notifications yourself.
As for capability tokens, they are indeed a left over bit of documentation. Capability tokens have mostly been renamed as access tokens so you can use them interchangeably. If you investigate the Video SDK, then everything will be Access Tokens too.
I am creating a chat application with Node.JS's Socket.IO and there is a couple things I need clarification on.
I am implementing offline messaging in my app meaning that when a user opens the app he will receive all the messages he missed when they were online.
This is my approach:
1) Client opens the app and is subscribed/joins a room
2) The client sends a message to Socket.IO
3) Socket.IO inserts the message in some kind of database/datastore
4) When client tries to retrieve the messages it is pulled from the database/datastore and saved on the users phone then it is deleted from the database.
Is this a correct approach?
I was looking at online and some people suggested using task/message queues like Google App Engines Task Queue but I am not sure how this works.
Your approach sounds OK, but I wouldn't delete messages from a DB, at least not immediately after the client receives them.
From your question it seems that you're not currently saving the messages to a database.
This approach has some drawbacks; for example, the user can't view their chat history on a device that was not connected when some of the messages were sent.
There are 2 ways I can think of to do it in a more elegant manner:
Save all messages to DB. on websocket connection and reconnections, fetch all messages newer than your latest message (This approach assumes no edit functionality in your chat, as edits will not be fetched this way). The latter can be implemented using either HTTP or WebSockets.
If you don't want to store the messages in your server, then you should implement some sort of persistent cache in the device used to send the messages. This is very similar to your original solution, except that instead of storing the messages in a database, you're storing them on the user's device. this does require some logic to detect when messages are received, and when the recipient reconnects, in order to trigger sending the missing messages.
The first approach is much better for the general use case in my opinion, but it depends on your use case.