CONNECT ID iOS SDK documentation
Please use the GitHub Watch feature to get notified on new releases of the SDK, at the top of the page.
Implements the API's for docs.telenordigital.com/apis/connect/id/authentication.html.
To add the library in your project, you can either use CocoaPods or manual install in your project.
Using CocoaPods
In your Podfile
add:
pod 'TDConnectIosSdk'
and then:
pod install
to install your dependencies
Follow these steps to add the library in your Swift project:
- Add TDConnectIosSdk as a submodule in your project. Open a terminal and navigate to your project directory. Then enter:
git submodule add https://github.com/telenordigital/connect-ios-sdk.git
- Open the
connect-ios-sdk
folder, and drag theTDConnectIosSdk.xcodeproj
into the file navigator in Xcode. - In Xcode select your application target and under the "Targets" heading section, ensure that the 'iOS Deployment Target' matches the application target of TDConnectIosSdk.framework (Currently set to 8.0).
- Select the "Build Phases" heading section, expand the "Target Dependencies" group and add
TDConnectIosSdk.framework
. - Click on the
+
button at the top left of the panel and select "New Copy Files Phase". Rename this new phase to "Copy Frameworks", set the "Destination" to "Frameworks", and addTDConnectIosSdk.framework
.
Using Carthage
Create Cartfile
in your project that contains
github "telenordigital/connect-ios-sdk"
Because the SDK project manages it's depencies with Cocoapods you will have to install the SDK depencies with Cocoapod locally, even though you don't have to use it for your project
carthage update # this will give an error but will generate the files needed
cd Carthage/Checkouts/connect-ios-sdk
pod install
cd ../../..
carthage update
Note: Make sure you have the latest version of Cocoapods (1.4.0 at the time of writing)
To set the SDK to Confidential Client mode set the optional init parameter in the Config
object named isPublicClient
to false
. Otherwise it will default to a public client.
A confidential client will not exchange the authorization code but simply return this to the client through the callback. The app code can then send this to the server-side component of the client.
See http://docs.telenordigital.com/connect/id/native_apps.html for more information.
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
let config = TelenorConnectConfig(clientId: "telenordigital-connectexample-ios",
redirectUrl: "telenordigital-connectexample-ios://oauth2callback",
useStaging: true,
scopes: ["profile", "openid", "email"],
accountId: "telenor-connect-ios-hello-world",
isPublicClient: false) // this variable needs to be present
let oauth2Module = AccountManager.getAccountBy(config: config)
?? AccountManager.addAccountWith(config: self.config, moduleClass: TelenorConnectOAuth2Module.self)
oauth2Module.requestAuthorizationCode { (authorizationCode: AnyObject?, error: NSError?) in
if (error != nil) {
// handle error
return
}
// use authorizationCode
}
}
-
Clone this project
-
Get the dependencies
The project uses CocoaPods for handling its dependencies. As a pre-requisite, install CocoaPods and then install the pod. On the root directory of the project run:
pod install
- open TDConnectIosSdk.xcworkspace
OAuth2 Client based on aerogear-ios-http.
Forked from aerogear/aerogear-ios-oauth2.