Skip to content

Commit

Permalink
Merge pull request #969 from tchapgouv/968-activer-le-notifications-f…
Browse files Browse the repository at this point in the history
…iltering

968 activer le notifications filtering
  • Loading branch information
NicolasBuquet authored Feb 26, 2024
2 parents c8b71c3 + 09be578 commit bf68932
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 30 deletions.
2 changes: 1 addition & 1 deletion Config/AppVersion.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
//

// Version
MARKETING_VERSION = 2.7.1
MARKETING_VERSION = 2.7.2
CURRENT_PROJECT_VERSION = 1
2 changes: 1 addition & 1 deletion Riot/Assets/fr.lproj/Vector.strings
Original file line number Diff line number Diff line change
Expand Up @@ -1465,7 +1465,7 @@

"voice_message_release_to_send" = "Maintenir pour enregistrer, relâcher pour envoyer";
"event_formatter_call_missed_video" = "Appel vidéo manqué";
"event_formatter_call_missed_voice" = "Appel audio manqué\n\nActuellement sur iOS, vous ne pouvez que passer des appels et pas en recevoir."; // Tchap: temporary fix for VoIP beta-test
"event_formatter_call_missed_voice" = "Appel audio manqué";
"event_formatter_call_active_video" = "Appel vidéo en cours";
"event_formatter_call_active_voice" = "Appel audio en cours";
"event_formatter_call_incoming_video" = "Appel vidéo entrant";
Expand Down
5 changes: 1 addition & 4 deletions Riot/Modules/MatrixKit/Controllers/MXKCallViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1442,10 +1442,7 @@ - (void)updateProximityAndSleep
// Disable the idle timer during a video call, or during a voice call which is performed with the built-in receiver.
// Note: if the device is locked, VoIP calling get dropped if an incoming GSM call is received.
BOOL disableIdleTimer = inCall && (mxCall.isVideoCall || isBuiltInReceiverUsed);

// Tchap: force disable the idle timer when in call, let it be a video call or a voice call with the built-in receiver, built-in speaker or a bluetooth device.
disableIdleTimer = inCall;


UIApplication *sharedApplication = [UIApplication performSelector:@selector(sharedApplication)];
if (sharedApplication && sharedApplication.isIdleTimerDisabled != disableIdleTimer)
{
Expand Down
65 changes: 42 additions & 23 deletions RiotNSE/NotificationService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import UserNotifications
import MatrixSDK
import CallKit

/// The number of milliseconds in one second.
private let MSEC_PER_SEC: TimeInterval = 1000
Expand Down Expand Up @@ -831,29 +832,47 @@ class NotificationService: UNNotificationServiceExtension {

ongoingVoIPPushRequests[event.eventId] = true

let appId = BuildSettings.pushKitAppId

pushGatewayRestClient.notifyApp(withId: appId,
pushToken: token,
eventId: event.eventId,
roomId: event.roomId,
eventType: nil,
sender: event.sender,
timeout: NSE.Constants.voipPushRequestTimeout,
success: { [weak self] (rejected) in
MXLog.debug("[NotificationService] sendVoipPush succeeded, rejected tokens: \(rejected)")

guard let self = self else { return }
self.ongoingVoIPPushRequests.removeValue(forKey: event.eventId)

self.fallbackToBestAttemptContent(forEventId: event.eventId)
}) { [weak self] (error) in
MXLog.debug("[NotificationService] sendVoipPush failed with error: \(error)")

guard let self = self else { return }
self.ongoingVoIPPushRequests.removeValue(forKey: event.eventId)

self.fallbackToBestAttemptContent(forEventId: event.eventId)
// Tchap: report incoming VoIP notification directly to application
// rather than requesting Sygnal to resend unencrypted VoIP notification

// let appId = BuildSettings.pushKitAppId
//
// pushGatewayRestClient.notifyApp(withId: appId,
// pushToken: token,
// eventId: event.eventId,
// roomId: event.roomId,
// eventType: nil,
// sender: event.sender,
// timeout: NSE.Constants.voipPushRequestTimeout,
// success: { [weak self] (rejected) in
// MXLog.debug("[NotificationService] sendVoipPush succeeded, rejected tokens: \(rejected)")
//
// guard let self = self else { return }
// self.ongoingVoIPPushRequests.removeValue(forKey: event.eventId)
//
// self.fallbackToBestAttemptContent(forEventId: event.eventId)
// }) { [weak self] (error) in
// MXLog.debug("[NotificationService] sendVoipPush failed with error: \(error)")
//
// guard let self = self else { return }
// self.ongoingVoIPPushRequests.removeValue(forKey: event.eventId)
//
// self.fallbackToBestAttemptContent(forEventId: event.eventId)
// }

// Starting from iOS 14.5, SDK can "Reports a new incoming call after your notification service extension decrypts a VoIP call request."
// See: https://developer.apple.com/documentation/callkit/cxprovider/3727263-reportnewincomingvoippushpayload

// Build th payload expected by the application.
var payload = [String: String]()
payload["event_id"] = event.eventId
payload["room_id"] = event.roomId

// Send the unencrypted VoIP payload dirtectly to the application.
CXProvider.reportNewIncomingVoIPPushPayload(payload) { error in
if let error = error {
MXLog.debug("[NotificationService] reportNewIncomingVoIPPushPayload Error: \(error)")
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions RiotNSE/RiotNSE.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
<array>
<string>$(APPLICATION_GROUP_IDENTIFIER)</string>
</array>
<key>com.apple.developer.usernotifications.filtering</key>
<true/>
<key>keychain-access-groups</key>
<array>
<string>$(KEYCHAIN_ACCESS_GROUP)</string>
Expand Down
1 change: 1 addition & 0 deletions changelog.d/968.change
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Réception des appels VoIP même si l'application n'est pas lancée ou pas en premier plan.
2 changes: 1 addition & 1 deletion towncrier.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.towncrier]
name = "Changes in"
version = "2.7.1"
version = "2.7.2"
filename = "TCHAP_CHANGES.md"
directory = "changelog.d"
template = "changelog.d/_template.md.jinja"
Expand Down

0 comments on commit bf68932

Please sign in to comment.