Identification CallKit not working for unknown reason

360 Views Asked by At

I am working with CallKit about module Identification

Step 1: I entered the correct phone number with the country code -> identification works fine

Step 2: I add more random numbers + add country code -> Of course the numbers I random are not real -> Identification not working with the numbers random and the numbers I added the first time in step 1

My code:

private func addAllIdentificationPhoneNumbers(to context: CXCallDirectoryExtensionContext) {
// Retrieve phone numbers to identify and their identification labels from data store. For optimal performance and memory usage when there are many phone numbers,
// consider only loading a subset of numbers at a given time and using autorelease pool(s) to release objects allocated during each batch of numbers which are loaded.
//
// Numbers must be provided in numerically ascending order.
if let identifications = try? self.fetchSpamSync() {
  for identification in identifications {
    if let name = identification.name {
      var number = String(identification.number)
      number = "084" + number
      let newNumber = Int64(number as String) ?? Int64("0")!
      if newNumber != 0 {
        context.addIdentificationEntry(withNextSequentialPhoneNumber: newNumber, label: name)
      }
    }
  }
}}

private func addOrRemoveIncrementalIdentificationPhoneNumbers(to context: CXCallDirectoryExtensionContext, since date: Date) {
// Retrieve any changes to the set of phone numbers to identify (and their identification labels) from data store. For optimal performance and memory usage when there are many phone numbers,
// consider only loading a subset of numbers at a given time and using autorelease pool(s) to release objects allocated during each batch of numbers which are loaded.
if let identifications = try? self.fetchSpamSync(includeRemoved: true, since: date) {
  for identification in identifications {
    if identification.isRemoved {
      context.removeIdentificationEntry(withPhoneNumber: identification.number)
    } else {
      if let name = identification.name {
        var number = String(identification.number)
        number = "084" + number
        let newNumber = Int64(number as String) ?? Int64("0")!
        if newNumber != 0 {
          context.addIdentificationEntry(withNextSequentialPhoneNumber: newNumber, label: name)
        }
      }
    }
  }
}}    // Record the most-recently loaded set of identification entries in data store for the next incremental load...

Can you tell me what is causing the error with all the numbers I just added although some have worked fine and correct

Is it possible that if one of them fails, all of them won't work? although it worked fine before

Many thanks !

0

There are 0 best solutions below