LinkedinSwift 1.8.1

LinkedinSwift 1.8.1

测试已测试
Lang语言 Obj-CObjective C
许可证 MIT
发布最后发布2020年8月

李剑堂维护。



 
依赖于
AFNetworking>= 3.5.0
IOSLinkedInAPIFix1>= 2.0.7
 

LinkedinSwift

CocoaPods Build Status codebeat badge Gitter

LinkedinSwift是一个使用CocoaPods管理本地LinkedIn SDK的项目

Linkedin Oauth Helper,依赖于是否已安装Linkedin Native App,使用Linkedin IOS SDK或UIWebView进行登录

最新版本基于LinkedIn SDK 1.0.7IOSLinkedinAPI用于webview认证

⚠️LinkedIn已拒绝支持Mobile SDK 链接,希望他们很快解决这个问题。目前只能使用网页登录。

let linkedinHelper = LinkedinSwiftHelper(configuration: 
    LinkedinSwiftConfiguration(
        clientId: "77tn2ar7gq6lgv", 
        clientSecret: "iqkDGYpWdhf7WKzA", 
        state: "DLKDJF45DIWOERCM", 
        permissions: ["r_liteprofile", "r_emailaddress"]
    ),
    nativeAppChecker: WebLoginOnly()
)

也可以尝试示例应用。

注意他们即将对权限进行的更改,从2019年3月1日开始,他们可能只支持r_liteprofile权限而不是r_basicprofile。 链接

如何使用

pod 'LinkedinSwift', '~> 1.8.0'

查看示例项目。

  • 设置配置和辅助实例。
let linkedinHelper = LinkedinSwiftHelper(configuration: 
    LinkedinSwiftConfiguration(
        clientId: "77tn2ar7gq6lgv", 
        clientSecret: "iqkDGYpWdhf7WKzA", 
        state: "DLKDJF45DIWOERCM", 
        permissions: ["r_liteprofile", "r_emailaddress"]
    )
)

或者如果要在不同的ViewController中展示,使用:

let linkedinHelper = LinkedinSwiftHelper(
    configuration: LinkedinSwiftConfiguration(
        clientId: "77tn2ar7gq6lgv", 
        clientSecret: "iqkDGYpWdhf7WKzA", 
        state: "DLKDJF45DIWOERCM", 
        permissions: ["r_basicprofile", "r_emailaddress"]
    ), webOAuthPresent: yourViewController
)
  • 设置Linkedin SDK设置(请参阅此处说明
  • 在AppDelegate中设置重定向处理程序
func application(application: UIApplication, 
        openURL url: NSURL, 
        sourceApplication: String?, 
        annotation: AnyObject) -> Bool {

    // Linkedin sdk handle redirect
    if LinkedinSwiftHelper.shouldHandleUrl(url) {
        return LinkedinSwiftHelper.application(application, 
                openURL: url, 
                sourceApplication: sourceApplication, 
                annotation: annotation
        )
    }
    
    return false
}

⚠️对于iOS 9及以上版本,请使用以下内容代替:

    func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
        // Linkedin sdk handle redirect
        if LinkedinSwiftHelper.shouldHandle(url) {
            return LinkedinSwiftHelper.application(app, open: url, sourceApplication: nil, annotation: nil)
        }
        
        return false
    }
  • 登录
linkedinHelper.authorizeSuccess({ (lsToken) -> Void in
    //Login success lsToken
}, error: { (error) -> Void in
    //Encounter error: error.localizedDescription
}, cancel: { () -> Void in
    //User Cancelled!
})
  • 获取资料
linkedinHelper.requestURL("https://api.linkedin.com/v2/me", 
    requestType: LinkedinSwiftRequestGet, 
    success: { (response) -> Void in
    
    //Request success response
    
}) { [unowned self] (error) -> Void in
        
    //Encounter error
}
  • 注销
linkedinHelper.logout()

示例项目截图

Demo photo

已知问题

-Linkedin 1.0.7似乎再次弄错了Bitcode支持。。您需要关闭Bitcode才能使它正常工作。- 现在似乎可以开启Bitcode了。