Latest 1.0.3
Homepage https://github.com/Etalio/mdi-ios-sdk
License Apache License, Version 2.0
Platforms ios 7.0, requires ARC
Dependencies BETOAuth2Client
Frameworks CoreTelephony

MDI SDK

Build Status
Version
Platform

MDI SDK for iOS.

Usage

Getting started

This assumes that there is a Mobile Connect application created on the developer portal

See the getting started guide for iOS to get started.

Application key

Make sure you have the following from the key registration:

  • Client id
  • Client secret
  • Redirect uri

The key will look something like this:

Application   : Test Application
KeyName       : My first key
ClientId      : 78581d15b05ea263acccb545f683459f
Client secret : eaf7c1273bab7d0415b6d8e3e8af0242
Platform      : ios

BundleId      : com.ericsson.testapp
URL Scheme:
  etalio78581d15b05ea263acccb545f683459f

Configuration

Add this snippet to your project and replace the values from the key:

#import <MDISDK/MDISDK.h>

[[MDIMobileConnectBase manager] setupWithClientId:ClientId clientSecret:ClientSecret scheme:URLScheme];

// Or if you need to provide a discovery URL:

[[MDIMobileConnectBase manager] setupWithClientId:ClientId clientSecret:ClientSecret scheme:URLScheme discoveryUrl:DiscoveryURL];

You will also need to add this snippet in your delegate so the SDK can handle redirects from the browser:

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
    return [[MDIMobileConnectBase manager] handleCallback:url];
}

Remember to add your URL Scheme to your Info.plist file. You can see an example of how to do it in the Sample project.


Authenticating

A prerequisite of being able to authenticate a user is that the application knows about the serving network of the user. Use the loginWithScopes when you want authenticate the user. This will start the discovery process if the user has not been discovered yet or the login process.

[[MDIMobileConnectBase manager] loginWithScopes:@[@"openid", @"profile", @"offline_access"];
                                       acrValue:@"3"
                                      loginHint:nil
                                         prompt:nil
                                            hni:nil
                              completionHandler:^(NSError *error) {
}];

Mobile Connect login & signup

User will be redirected to the Mobile Connect OAuth2 consent pages. After the user has either approved or rejected your application a redirect will be made back to the redirect URI you defined when creating the key. Call the authorize function after the login completion.

- (void)authorizeWithCompletionHandler:(MDITokenBlock)completionHandler;

This method will look for the authentication headers in the request object and take care of the callbacks to Mobile Connect in order to exchange the OAuth2 code header from the redirect and your client secret to an access token and a refresh token.

API

Use this method if you want to get information about the current user.

- (void)userinfoWithCompletionHandler:(MDIDictionaryBlock)completionHandler;

Use these methods if you want to get information about the current user’s token.

- (MDIToken *)token;
- (NSDictionary *)idToken;

Use this method if you want to revoke the current user’s access to the application.

- (void)revokeTokenWithCompletionHandler:(MDIErrorBlock)completionHandler;

Use this method if you want to check it the user is authenticated.

- (BOOL)isAuthenticated;

Use this method if you want to get information about the serving network of the user.

- (MDIDiscoveryData *)discoveryData;

License

Copyright 2015 Ericsson AB

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Latest podspec

{
    "name": "MDISDK",
    "version": "1.0.3",
    "summary": "MDI SDK for iOS",
    "homepage": "https://github.com/Etalio/mdi-ios-sdk",
    "license": "Apache License, Version 2.0",
    "authors": "Ericsson AB",
    "source": {
        "git": "https://github.com/Etalio/mdi-ios-sdk.git",
        "tag": "1.0.3"
    },
    "platforms": {
        "ios": "7.0"
    },
    "dependencies": {
        "BETOAuth2Client": [
            "1.0.5"
        ]
    },
    "source_files": "MDISDK/**/*.{h,m}",
    "requires_arc": true,
    "frameworks": "CoreTelephony",
    "exclude_files": "MDISDK/Security/*.{h,m}",
    "subspecs": [
        {
            "name": "no-arc",
            "requires_arc": false,
            "source_files": "MDISDK/Security/*.{h,m}"
        }
    ]
}

Pin It on Pinterest

Share This