0

I am writing an application to block spam calls on my mobile and since iOS 18.2 I encounter a problem, it is that in my call log instead of the name of my application, I have something else that appears :

(null): Numéro bloqué

enter image description here

it worked very well before. And then now if you have any ideas.

Thanks you

import Foundation

import CallKit import os.log

class CallDirectoryHandler: CXCallDirectoryProvider {

let logger = OSLog(subsystem: "arnaudguitard.SilenceApp.BlockerExtension", category: "CallDirectoryHandler")

override func beginRequest(with context: CXCallDirectoryExtensionContext) {
    os_log("🚀 Début de beginRequest", log: logger, type: .info)
    
    if context.isIncremental {
        os_log("📌 Mise à jour incrémentale", log: logger, type: .info)
        context.removeAllBlockingEntries()
        context.removeAllIdentificationEntries()
    } else {
        os_log("🔄 Mise à jour complète", log: logger, type: .info)
    }

    do {
        guard let containerURL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.arnaudguitard.SilenceApp") else {
            os_log("❌ Impossible d'accéder au conteneur partagé", log: logger, type: .error)
            context.completeRequest()
            return
        }
        
        let fileURL = containerURL.appendingPathComponent("filters.json")
        
        guard let data = try? Data(contentsOf: fileURL) else {
            os_log("❌ Aucun filtre sauvegardé trouvé", log: logger, type: .error)
            context.completeRequest()
            return
        }
        
        let filters = try JSONDecoder().decode([Filter].self, from: data)
        os_log("📊 Décodé %{public}d filtres", log: logger, type: .info, filters.count)
        
        var phoneNumbers = [CXCallDirectoryPhoneNumber]()
        
        for (index, filter) in filters.enumerated() where filter.isEnabled {
            os_log("🔍 Traitement du filtre %{public}d", log: logger, type: .debug, index)
            for numberString in filter.numbers {
                if let phoneNumber = CXCallDirectoryPhoneNumber(numberString) {
                    phoneNumbers.append(phoneNumber)
                    os_log("➕ Numéro ajouté à la liste de blocage : %{public}@", log: logger, type: .debug, numberString)
                } else {
                    os_log("⚠️ Impossible de convertir le numéro : %{public}@", log: logger, type: .error, numberString)
                }
            }
        }
        
        os_log("📱 Nombre total de numéros à bloquer : %{public}d", log: logger, type: .info, phoneNumbers.count)
        
        phoneNumbers.sort()
        
        //let silenceLabel = "Numéro bloqué"
        
        for number in phoneNumbers {
            context.addBlockingEntry(withNextSequentialPhoneNumber: number)
            context.addIdentificationEntry(withNextSequentialPhoneNumber: number, label: "Numéro bloqué")
            os_log("🚫 Numéro ajouté à la liste de blocage et identifié : %{public}lld", log: logger, type: .debug, number)
        }
        
        os_log("✅ Tous les numéros ont été ajoutés à la liste de blocage et identifiés", log: logger, type: .info)
        context.completeRequest()
    } catch {
        os_log("❌ Erreur lors du traitement des filtres : %{public}@", log: logger, type: .error, error.localizedDescription)
        context.cancelRequest(withError: error)
    }
    
    os_log("🏁 Fin de beginRequest", log: logger, type: .info)
}

}

0

Browse other questions tagged or ask your own question.