Balwant Chauhan
Balwant Chauhan

Reputation: 29

Notify video chat application when app is terminated

Is there any way to notify my video chat application that there is an incoming video call when the app is in the terminated state? (Like an Android background service.)

I notify of incoming calls via socket when the application is in the running and background states.

Upvotes: 2

Views: 124

Answers (2)

Hasya
Hasya

Reputation: 9898

  • Get pushkit payload
  • Implement pushkit at ios code side
  • Once you receive silent notification
  • Schedule local notification
  • Keep important information in local notification's userinfo
  • Also keep local notification object in NSUserDefault
  • If your device gets restart then you can retrieve localnotification userinfo from NSUserDefault object
  • Once you get silent notification your socket will get active upto your local notification sound plays ( Max 30 seconds )
  • If you want incoming call ringing more than 30 seconds then server has to send silent notification at each 30 seconds
  • Delete previous object and reschedule latest on local notification

Let me know if you need any help in push kit implementation.

Upvotes: 0

Florian Burel
Florian Burel

Reputation: 3456

App that are using VoIP are treated differently by apple and have more privilieges. In the past, that meant keeping a permanent connection to the server to get notified when a call occurs.

This was not very efficient in terms of energy saving.

Since iOS8 it is recommanded to use PushKit (the push notification API) to notify your user when a call occurs. Apps with VoIP privileges will be notified on the spot and that can wake up your app whatever the state it's in.

Here are the world from apple :

Instead of persistent connections, developers should use the PushKit framework—APIs that allows an app to receive pushes (notifications when data is available) from a remote server. Whenever a push is received, the app is called to action. For example, a VoIP app could display an alert when a call is received, and provide an option to accept or reject the call. It could even begin taking precursory steps to initiate the call, in the event the user decides to accept.

https://developer.apple.com/library/ios/documentation/Performance/Conceptual/EnergyGuide-iOS/OptimizeVoIP.html

Upvotes: 2

Related Questions