How to immediately stop playing the APNS listening tone in iOS?

We have an iOS app (softphone) that receives APNS remote push notifications. Our server knows how to send APNS push when an incoming call arrives to this user, and our softphone application is not an active application on the device. APNS arrives, displays incoming calls to the user's pop-up windows, banner or warning, starts playing the ringtone. If the user notifies the notification, the notification leaves, the ringtone stops, our application starts and answers the call. So far, so good. However, if the notification of an incoming call is presented in the form of a banner, the user can launch our application directly by clicking the application icon. In this case, we want our application to immediately hide / reject an incoming call notification. We tried to send these commands (as an iOS application: how to clear notifications? ):

[[UIApplication sharedApplication] setApplicationIconBadgeNumber: 0]; [[UIApplication sharedApplication] cancelAllLocalNotifications]; 

The problem is that the notification banner disappears, but the notification sound (25 second wav ringtone) continues to play until the end. Is there any way to stop this notification signal right from our code?

+4
source share

Source: https://habr.com/ru/post/1441890/


All Articles