Upload address book
Address book upload process:
App gets mobile phone contacts
Make contact.json file
Call file transfer interface
JSON field description:
| Property | Type | Description |
|---|---|---|
| year | Int | year |
| month | Int | month |
| day | Int | day |
| hour | Int | hour |
| minute | Int | minute |
| second | Int | second |
| contact_item_num | Int | Number of contacts (corresponding to items.count) |
| items | collection |
| Property | Type | Description |
|---|---|---|
| name | String | name (maximum 64 bytes) |
| phone | String | phone (maximum 32 bytes) |
Example:
Swift:
var items = [IDOTransBaseModel]()
// Contacts
items.append(IDOTransNormalModel(fileType: .ml, filePath: "/xx/xx/x.json", fileName: "contacts"))
// Call transfer
let canceler = sdk.transfer.transferFiles(fileItems: items, cancelPrevTranTask: true) { currentIndex, totalCount, _, totalProgress in
print("Transfer in progress (\(currentIndex + 1)/\(totalCount)...")
} transStatus: { _, status, errorCode, _ in
if status != .finished || errorCode != 0 {
print("Transfer failed:\(errorCode)")
}
} completion: { rs in
print("Transfer ended: \(rs)")
if rs.last! {
// Transfer successful
} else {
// Transfer failed
} }
Kotlin:
var items = mutableListOf<IDOTransBaseModel>()
// Contact
items.add(IDOTransNormalModel(fileType: IDOTransType.ML, filePath: "/xx/xx/x.json", fileName: "contacts"))
// Call transfer
val cancelable = sdk.transfer.transferFiles(
items, cancelPre,
{ currentIndex, totalCount, currentProgress, totalProgress ->
print("Transmitting ${currentIndex + 1}/$totalCount...")
},
{ currentIndex: Int, status: IDOTransStatus, errorCode: Int?, finishingTime: Int? ->
if (status != IDOTransStatus .FINISHED || errorCode != 0) {
print("Transmission failed: $errorCode")
}
},
{resultList-> resultList.forEach {
if (it){
//Transmission successful
}else{
//Transfer failed
}
}})