Skip to content

Retrieve contact after insert, not working #272

@alorma

Description

@alorma

Testing on emulator.

  suspend fun createTemporalContact(temporalContact: NewTemporalContact): Boolean {

    val rawContact: NewRawContact = NewRawContact().apply {
      setName {
        displayName = temporalContact.name
        givenName = temporalContact.name
      }
      addPhone {
        number = temporalContact.phone
      }
    }

    val insertResult = contacts
      .insertWithPermission()
      .rawContact {
        setName {
          displayName = temporalContact.name
        }
        addPhone {
          number = temporalContact.phone
        }
      }
      .commit()

    val contact = insertResult.contact(contacts, rawContact)
    Log.i("AlormaContacts", "Contact: $contact") // <-- contact is NULL here

    if (insertResult.isSuccessful && contact != null) {
      val entity = TemporalContactEntity(
        rawContactId = contact.id,
        name = temporalContact.name,
        phone = temporalContact.phone,
        deleteAt = temporalContact.deleteAt,
      )
      temporalContactDao.insert(entity)
      return true
    }
    return false
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions