Hello, I’m building a viber like application and I was wondering how can I make my application go foreground when there is an incoming call inside the app?
Or in another words, if the app is on the background, how can I mimic an incoming call and notify the user about the call from the background just like facebook messenger whatsapp and viber?
Hi everyone!
I’m interesting on how to show a notification when there is an incoming call using ionic to give some more information, even Is there any possibility to get the incoming phone number?
Please can anyone help us?
@Muffasa @scabrera Did you found any solution for this ? I am also trying to built a similar video calling application
While I haven’t built something like this, here is what I would do:
You will need to use this plugin:
I’d probably implement something like this:
Setup
- Whenever a user logs-in to your app, you need to use the Push Plugin to request a device token for push notifications and store this device token on your DB so you can reference it later. You need to do this everytime someone launches your app since the device token can expire.
App Flow
-
User A wants to call User B, so he pulls up contacts inside your app, selects User B and clicks “Call”
-
This sends a request to the server stating User A wants to call User B.
-
The server retrieves the device token for User B, which it then uses to send a push notification to User B’s phone.
-
(Optional) You can include an expiry field on the notification so if User B does not click the notification after ~20seconds, it is removed. That way they do not try to answer a call from hours ago.
-
A notification is displayed on User B’s phone, alerting them that User A is calling them.
-
You can customize the notification however you like, such as including “Answer” and “Deny” buttons.
-
Inside your app, you will need to include functions for what happens if a user clicks either “Answer” or “Deny”.
-
If they answer, you now have to establish an open connection for the phone call (beyond the scope of this example).
-
If they reject the call, you need to send a “reject call” request to the server, which then sends back the rejection to User A, so they know about the status of the call.
-
If User A cancels the call, you will need to send an additional request to the server to cancel the notification (I’m not actually sure if thats possible, but I leave that to you to discover).
I think that should be more than enough to help you guys get started and is how I would approach the problem. Please let me know if you guys are still stuck or need anything else.
Cheers