新版本友盟中获取用户信息:
UMSocialManager.default().getUserInfo(with: UMSocialPlatformType.wechatSession, currentViewController: self) { (response, userError) in
if userError != nil {
return
}
if response != nil {
let userinfoBS = response as! UMSocialUserInfoResponse
let iconUrl = userinfoBS.iconurl
let name = userinfoBS.name
//MARK: uid、unionId 二者等同
let uid = userinfoBS.uid
let unionId = userinfoBS.unionId
//MARK: usId、openId 二者相同
let usId = userinfoBS.usid
let openId = userinfoBS.openid
print("iconUrl--->\(String(describing: iconUrl))\n---name->\(String(describing: name))\n---uid---->\(String(describing: uid))\n---openId--->\(String(describing: openId))\n---unionId--->\(String(describing: unionId))\n---usId--->\(String.init(describing: usId))")
}
}
//自定制model
class UMModel: NSObject {
///绑定页面的 验证码
var verifyCode: String = ""
///绑定页面 的电话号码
var tel: String = ""
///绑定页面的 地区id
var areaID: String = ""
//以下为友盟数据:
///第三方登录类型 1微信;2QQ
var type: String = "1"
///第三方的图片链接
var iconUrl: String = ""
///用户在某个小程序或者公众号的唯一标识
var openId: String = ""
///第三方的 唯一id
var unionId: String = ""
///第三方的 昵称
var name: String = ""
override init() {
super.init()
}
init(_ para: Any?, type: String = "") {
if let userInfo = para as? UMSocialUserInfoResponse {
self.type = type
iconUrl = userInfo.iconurl
openId = userInfo.openid
unionId = userInfo.uid
name = userInfo.name
}
}
}