Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
iOSExampleXamarin
.gitignore
README.md
iOSExampleXamarin.sln

README.md

More about cidaas

To know more about cidaas visit cidaas

cidaas Documentation

https://docs.cidaas.de/

Requirements

Visual Studio           :   2017
Operating System        :   iOS 10 or above

Installation

cidaas-sdk-ios-v2 is available through NuGet. There are 3 options to integrate it in your project

  1. Enter the following command in Package Manager Console
Install-Package cidaas-sdk-ios-v2
  1. Download the package from the following url
https://www.nuget.org/packages/cidaas-sdk-ios-v2

Once downloaded, drag and drop the file to your project

  1. Right click on your project and select Add Nuget Packages option. Search for cidaas-sdk-ios-v2 and install it

Getting Started

  1. Create a new plist file and add the following code
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<plist version="1.0">
    <dict>
        <key>  DomainURL  </key>
        <string>  Your domain url  </string>
        
        <key>  RedirectURI  </key>
        <string>  Your redirect uri  </string>
        
        <key>  ClientID  </key>
        <string>  Your client id  </string>

    </dict>
</plist>
  1. Add the file name of the plist in your AppDelegate.cs file
CidaasSDKView.CIDAAS_PLIST_FILE_NAME = "Cidaas";

Login

  1. To perform login operation create a view in your Xib and named as cidaasView copy and paste the below code snippet in your cs file
var cidaas = CidaasSDKView.Create();
cidaas.Frame = View.Frame;
cidaas.Login();
cidaas.OnLoginSuccess += (sender, response) =>
{
    // your succes code here
    // UserInfoEntity userInfoEntity = response.UserInfoEntity;
    // TokenEntity tokenEntity = response.TokenEntity;
};
cidaas.OnProcess += (sender, response) =>
{
    // Use this block to show or hide loader while login process going on
    // Boolean isLoading = response.loading
};
cidaasView.AddSubview(v);

Getting User Information

  1. To get user information, call GetUserInfoByAccessToken() method
CidaasSDKView.GetUserInfoByAccessToken(access_token);

Getting Access token

  1. To validate access token, call GetAccessToken() method
CidaasSDKView.GetAccessToken(user_id);

Logout user

  1. cidaas offers various logout methods

Logout in an Embedded browser

To logout the session and redirect to the logout success page, call LogoutWithWebview() or LogoutWithWebviewByAccessToken() method. Though its a embedded browser you can use this like login. Instead of Login(), you need to use LogoutWithWebview() or LogoutWithWebviewByAccessToken() method.

var cidaas = CidaasSDKView.Create();
cidaas.Frame = View.Frame;
cidaas.LogoutWithWebview("your_user_id");
(or) 
cidaas.LogoutWithWebviewByAccessToken("your_access_token");
cidaasView.AddSubview(v);

Optionaly, you can pass post_logout_redirect_url whill will redirect you to the url you mentioned after successful logged out. For more information about post_logout_redirect_url refer Logout Endpoints

cidaas.LogoutWithWebview("your_user_id", "post_logout_redirect_url");
(or)
cidaas.LogoutWithWebviewByAccessToken("your_access_token", "post_logout_redirect_url");

Here also you can listen the event of OnLoginSuccess() because if you did not add the post_logout_redirect_url it will automatically redirect to the login page of cidaas.

Logout Native

To logout the session using native operation, call Logout() method. This will give you json response either success of failure.

var logoutResponse = CidaasSDKView.Logout(user_id);

Get Login URL

  1. To get login URL, call GetLoginURL() method
var loginURL = CidaasSDKView.GetLoginURL();

Get Register URL

  1. To get register URL, call GetRegisterURL() method
var registerURL = CidaasSDKView.GetRegisterURL();

Token Validation Check

  1. To check whether the token is valid or not, call validateToken() method
bool tokenCheck = CidaasSDKView.validateToken(access_token);

Setting Back Button

  1. To enable and set the Back Button
cidaas.EnableBackButton = true;
cidaas.SetBackButtontitle("your_back_button_title");

Sample Code

ViewController.cs

using System;

using UIKit;
using Foundation;
using CidaasSDKiOS;
using CidaasSDK.Helpers;
using CidaasSDKiOS.Helpers;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Net.Http;
using CidaasSDK.Entity;
using CidaasSDKiOS.Entity;

namespace iOSExampleXamarin
{
    public partial class ViewController : UIViewController
    {
        private string user_id;
        private string access_token;

        protected ViewController(IntPtr handle) : base(handle)
        {
            // Note: this .ctor should not contain any initialization logic.
        }

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            createView();
        }

        private void createView()
        {
        
            var loginURL = CidaasSDKView.GetLoginURL();
            var registerURL = CidaasSDKView.GetRegisterURL();
        
            var v = CidaasSDKView.Create();
            v.Frame = View.Frame;
            v.Login();
            v.OnLoginSuccess += (sender, e) =>
            {
                user_id = e.UserInfoEntity.sub;
                access_token = e.TokenEntity.access_token;
                var tokenCheck = CidaasSDKView.validateToken(access_token);
                
            };
            v.OnProcess += (sender, e) =>
            {
                if (e.Loading == true) {
                    CidaasLoader.ShowLoader();
                }
                else {
                    CidaasLoader.HideLoader();
                }
            };
            cidaasView.AddSubview(v);
        }

        public override void DidReceiveMemoryWarning()
        {
            base.DidReceiveMemoryWarning();
            // Release any cached data, images, etc that aren't in use.
        }
    }
}

Screen Shots

Screen 1 Screen 2

Help and Support

For more support visit here

You can’t perform that action at this time.