How to mimc incoming call? backgroung to foreground / push notification


#1

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?


#2

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?


#3

@Muffasa @scabrera Did you found any solution for this ? I am also trying to built a similar video calling application


#4

@gaurav @Muffasa @scabrera

While I haven’t built something like this, here is what I would do:

You will need to use this plugin:

  1. https://github.com/phonegap/phonegap-plugin-push

I’d probably implement something like this:

Setup

  1. 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

  1. User A wants to call User B, so he pulls up contacts inside your app, selects User B and clicks “Call”

  2. This sends a request to the server stating User A wants to call User B.

  3. The server retrieves the device token for User B, which it then uses to send a push notification to User B’s phone.

  4. (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.

  5. A notification is displayed on User B’s phone, alerting them that User A is calling them.

  6. You can customize the notification however you like, such as including “Answer” and “Deny” buttons.

  7. Inside your app, you will need to include functions for what happens if a user clicks either “Answer” or “Deny”.

  8. If they answer, you now have to establish an open connection for the phone call (beyond the scope of this example).

  9. 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.

  10. 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