上传通讯录

通讯录上传流程:

​ 1、app获取手机联系人

​ 2、制作 contact.json文件

​ 3、调用文件传输接口

json字段说明:

属性 类型 说明
year Int
month Int
day Int
hour Int
minute Int
second Int
contact_item_num Int 联系人数量(对应items.count)
items 集合
属性 类型 说明
name String 名称(最大64字节)
phone String 电话(最大32字节)

示例:

Swift:

var items = [IDOTransBaseModel]()

// 联系人
items.append(IDOTransNormalModel(fileType: .ml, filePath: "/xx/xx/x.json", fileName: "contacts"))

// 调用传输
let canceler = sdk.transfer.transferFiles(fileItems: items, cancelPrevTranTask: true) { currentIndex, totalCount, _, totalProgress in
      print("传输中(\(currentIndex + 1)/\(totalCount)...")
} transStatus: { _, status, errorCode, _ in
    if status != .finished || errorCode != 0 {
        print("传输失败:\(errorCode)")
    }
} completion: { rs in
    print("传输结束: \(rs)")
    if rs.last! {
        // 传输成功
    } else {
        // 传输失败
    }
}

Kotlin:

var items = mutableListOf<IDOTransBaseModel>()

// 联系人
items.add(IDOTransNormalModel(fileType: IDOTransType.ML, filePath: "/xx/xx/x.json", fileName: "contacts"))

// 调用传输
val cancellable = sdk.transfer.transferFiles(
    items, cancelPre,
    { currentIndex, totalCount, currentProgress, totalProgress -> 
      print("传输中${currentIndex + 1}/$totalCount...")
    },
    { currentIndex: Int, status: IDOTransStatus, errorCode: Int?, finishingTime: Int? ->
        if (status != IDOTransStatus.FINISHED || errorCode != 0) {
            print("传输失败:$errorCode")
        }
    },
    {resultList-> resultList.forEach {
        if (it){
            //传输成功
        }else{
            //传输失败
        }
    }})
Copyright © 2023-2024 IDO. All rights reserved. all right reserved,powered by Gitbook修改日期: 2024-08-21 11:55:28

results matching ""

    No results matching ""