This example client side application demonstrates how to integrate client side library with server side library.

Configuring the client side library

Important. Your client side library will work only with server side library.

  1. Download the Mobile Connect client side library

    git clone https://github.com/clientside
  2. Open project in XCode.
  3. Build the project.

Open the configuration file: ClientSideSDK/config.plist .
Here are two parameters:

<string name="server_endpoint">your server side endpoint</string>
<string name="msisdn">default msisdn</string>

Be sure to provide your server side endpoint (endpoint of your server side library).
You can also configure your msisdn, if it's necessary.
Add your custom configuration (e.g. ip_address).

Using the client side library

With your configuration specified in the configuration file or using user interface, you have everything you need to make a successful call to the server side library.
You can use client side application in three modes:

  • Using msisdn
  • Using MCC_MNC
  • None mode

Also you can add IP address to the request to server side.
After you clicking "Mobile Connect" button the Application does the following:

  1. Checks which mode you have selected.
  2. Checks that configuration of your selected mode is valid.
  3. Makes getLogin method call with your configuration in parameters

    This method generates GET request to the server side endpoint (from your configuration). To generate the request parameters it uses discoveryParametersTapped method:

    @IBAction func discoveryParametersTapped(_ sender: Any) {
            if discoveryRequestParameters.selectedSegmentIndex == 1 {
                UIView.transition(with: self.msisdnField, duration: 0.5, options: UIViewAnimationOptions.transitionCrossDissolve, animations: {
                    self.mccField.isHidden = true
                    self.mncField.isHidden = true
                    self.msisdnField.isHidden = false
                }, completion: nil)
                isMsisdnRequest = true
                isMccMncRequest = false
            } else if discoveryRequestParameters.selectedSegmentIndex ==  {
                UIView.transition(with: self.mccField, duration: 0.5, options: UIViewAnimationOptions.transitionCrossDissolve, animations: {
                    self.mccField.text = self.mcc
                    self.mncField.text = self.mnc
                    self.mccField.isHidden = false
                    self.mncField.isHidden = false
                    self.msisdnField.isHidden = true
                }, completion: nil)
                isMccMncRequest = true
                isMsisdnRequest = false
            } else {
                isMsisdnRequest = false
                isMccMncRequest = false
            }
        } 
        }

    After having prepared a request URI the application sends GET request using the volley library:
    • If you are using only msisdn the request to your server side part will be: http://server_side_endpoint?msisdn=your_msisdn.
    • When you are using mcc and mnc it will be: http://server_side_endpoint?mcc=your_mcc&mnc=your_mnc.
    • If you choose 'None' mode: http://server_side_endpoint?.
    • Also you can check 'IP address' e.g. in msisdn mode: http://server_side_endpoint?msisdn=your+msisdn&ip_address=your_ip_address.
  4. In case of failure while sending the request to server side, application shows message: 'Error occurred sending request to the server'.
    When the application gets valid response it shows message 'OK' and opens web view dialog to start authentication.

  5. After displaying web view:
    • In msisdn mode you will see a few redirects until the web view gets the URL with 'code' and 'state' parameters.
    • Using MCC_MNC or none mode you will be redirected to the operator selection page. Here you can type your msisdn and process page.

    In any case after getting URL with 'code' and 'state' parameters application sends GET request (to server side) and gets the response with JSON, that contains the results information.