Skip to content

FanapSoft/pod_sso

Repository files navigation

ssoFanapium

CI Status Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

  • iOS 9.0+ / macOS 10.0+ / tvOS 9.0+ / watchOS 2.0+
  • Xcode 8.0+
  • Swift 3.0+

Installation

ssoFanapium is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'ssoFanapium'

Then, run the following command:

$ pod install

Usage

Step 1 : Register a custom URL scheme

  • In the File Navigator on the left look for the Info.plist file, by default it's in the Supporting Files Group.

  • Click on the file to open it and at the bottom of the list add a new item.

  • From the list of items to add, choose URL Types

  • Click on the disclosure arrow to drop down the list of contained information, you’ll see an entry for URL Identifier.

  • Click the plus button in the line to add a sibling entry and choose URL Schemes. Once added click the disclosure triangle next to it. In both the URL identifier and URL Schemes > Item 0 entries insert the custom URL scheme of your app.

Step 2 : Making a Request

import ssoFanapium

let sso = SSOClass()

func someFunc() {
    sso.login(	sso_address: "SSO Address",
                client_id: "Your Client Id", 
                redirect_uri: "Your custome URL scheme://", 
                state: "Some things you need after login", 
                sender: self)
    }

Step 3 : Add Observer

import ssoFanapium

let sso = SSOClass()

func someFunc() {
    sso.login(	sso_address: "SSO Address",
                client_id: "Your Client Id", 
                redirect_uri: "Your custome URL scheme://", 
                state: "Some things you need after login", 
                sender: self)



NotificationCenter.default.addObserver( self, 
                                        selector: #selector(ViewController.methodOfReceivedNotification(notification:)), 
                                        name: Notification.Name("ssoLoginDidFinish"),
                                        object: nil)

}

Step 4 : Add method of received notification

import ssoFanapium

let sso = SSOClass()

func someFunc() {
    sso.login(	sso_address: "SSO Address",
                client_id: "Your Client Id", 
                redirect_uri: "Your custome URL scheme://", 
                state: "Some things you need after login", 
                sender: self)



NotificationCenter.default.addObserver( self, 
                                        selector: #selector(ViewController.methodOfReceivedNotification(notification:)), 
                                        name: Notification.Name("ssoLoginDidFinish"), 
                                        object: nil)
}

func methodOfReceivedNotification(notification: Notification){
    NotificationCenter.default.removeObserver(self, name: Notification.Name("ssoLoginDidFinish"), object:nil)

    if notification.object as! String == "SafariViewControllerDidDismiss" {
        print ("SafariViewControllerDidDismiss")
    }else {

        //This Is Your SSO Code 
        //In next step you can get token from server with this code
        let code = notification.object as! String
        print(code)
    }
}

Author

emadgnia, e.ghorbaninia@fanap.ir

License

ssoFanapium is available under the MIT license. See the LICENSE file for more info.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published