Skip to content
This repository has been archived by the owner on Mar 12, 2020. It is now read-only.

Linkedin IOS SDK for Swift from IOS 7

License

Notifications You must be signed in to change notification settings

gatherdigital/LinkedinSwift

 
 

Repository files navigation

LinkedinSwift

CocoaPods Build Status codebeat badge Gitter

LinkedinSwift is a project for managing native LinkedIn SDK using CocoaPods

Linkedin Oauth Helper, depend on Linkedin Native App installed or not, using Linkdin IOS SDK or UIWebView to login, support Swift with iOS 7

Latest version is based on LinkedIn SDK 1.0.7 and IOSLinkedinAPI for webview auth.

How to use

pod 'LinkedinSwift', '~> 1.7.7'

Check out Example project.

  • Setup configuration and helper instance.
let linkedinHelper = LinkedinSwiftHelper(configuration: 
    LinkedinSwiftConfiguration(
        clientId: "77tn2ar7gq6lgv", 
        clientSecret: "iqkDGYpWdhf7WKzA", 
        state: "DLKDJF45DIWOERCM", 
        permissions: ["r_basicprofile", "r_emailaddress"]
    )
)

Or if you want to present in a different ViewController, using:

let linkedinHelper = LinkedinSwiftHelper(
    configuration: LinkedinSwiftConfiguration(
        clientId: "77tn2ar7gq6lgv", 
        clientSecret: "iqkDGYpWdhf7WKzA", 
        state: "DLKDJF45DIWOERCM", 
        permissions: ["r_basicprofile", "r_emailaddress"]
    ), webOAuthPresent: yourViewController
)
  • Setup Linkedin SDK settings: instruction here
  • Setup redirect handler in 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
}

⚠️ for iOS 9 and above use this instead:

    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
    }
  • Login:
linkedinHelper.authorizeSuccess({ (lsToken) -> Void in
    //Login success lsToken
}, error: { (error) -> Void in
    //Encounter error: error.localizedDescription
}, cancel: { () -> Void in
    //User Cancelled!
})
  • Fetch profile:
linkedinHelper.requestURL("https://api.linkedin.com/v1/people/~?format=json", 
    requestType: LinkedinSwiftRequestGet, 
    success: { (response) -> Void in
    
    //Request success response
    
}) { [unowned self] (error) -> Void in
        
    //Encounter error
}
  • Logout:
linkedinHelper.logout()

Example project screenshots:

Demo photo

Known issues

-It seems Linkedin 1.0.7 messed up with Bitcode support. again. You need to turn off Bitcode to make it work.- seems can turn on Bitcode now.

About

Linkedin IOS SDK for Swift from IOS 7

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Objective-C 87.6%
  • C 7.8%
  • Swift 3.7%
  • Ruby 0.9%