Skip to content

Commit

Permalink
fixed #107
Browse files Browse the repository at this point in the history
  • Loading branch information
Limon-O-O committed Nov 10, 2017
1 parent 165a1a5 commit e5e845a
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions Sources/MonkeyKing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -177,31 +177,38 @@ extension MonkeyKing {
result = (ret == "0")
return result
}

// Share
if let data = UIPasteboard.general.data(forPasteboardType: "content") {
if let dict = try? PropertyListSerialization.propertyList(from: data, options: PropertyListSerialization.MutabilityOptions(), format: nil) as? [String: Any] {

guard
let account = shared.accountSet[.weChat],
let info = dict?[account.appID] as? [String: Any],
let result = info["result"] as? String,
let resultCode = Int(result) else {
return false
}

// OAuth Failed
if let state = info["state"] as? String, state == "Weixinauth", resultCode != 0 {
let error = NSError(domain: "WeChat OAuth Error", code: -1, userInfo: nil)
shared.oauthCompletionHandler?(nil, nil, error)
return false
}

let success = (resultCode == 0)

if success {
shared.deliverCompletionHandler?(.success(nil))
} else {
shared.deliverCompletionHandler?(.failure(.sdk(reason: .unknown))) // TODO: pass resultCode
shared.deliverCompletionHandler?(.failure(.sdk(reason: .unknown)))
}

return success
}
}
// OAuth Failed
if urlString.contains("platformId=wechat") && !urlString.contains("state=Weixinauth") {
let error = NSError(domain: "WeChat OAuth Error", code: -1, userInfo: nil)
shared.oauthCompletionHandler?(nil, nil, error)
return false
}

return false
}
// QQ Share
Expand Down

0 comments on commit e5e845a

Please sign in to comment.