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

Download button

Configuring the client side library

Important. The client side libraries will only work together with the server side SDKs. Available server side SDKs: .Net, PHP, Java

  1. Download the Mobile Connect client side library.

    git clone https://github.com/Mobile-Connect/ios_client_side_library.git
  2. Open project in XCode.
  3. Build the project.
  4. Open the configuration file: ClientSideLib/Config.plist.
    Here are few parameters for mode, which needs Discovery request:
    <string name="ip_address">default ip_address</string>
    <string name="mcc_value">default mcc_value</string>
    <string name="mnc_value">default mnc_value</string>
    <string name="server_endpoint">your server side endpoint</string>
    <string name="msisdn">default msisdn</string>

    Parameters for mode without Discovery:

    <string name="server_endpoint_wd">your server side endpoint</string>
    <string name="msisdn_wd">default msisdn</string>
  5. Be sure to provide your server side endpoint (endpoint of your server side application).
  6. Add your custom configuration (e.g. msisdn, ip_address).


Using the client side library

Mode with Discovery request

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. To set the request parameters it uses setValues method:

    func setValues() {
        if let addr = NetworkUtils.getIPAddress() {
            ipAddressField.text = addr
        } else {
            ipAddressField.text = config.getIpAdress()
        }
        msisdnField.text = self.config.getMsisdn()
        mccField.text = NetworkUtils.getCellularInformation().mcc
        if mccField.text!.isEmpty {
            mccField.text = self.config.getMcc()
        }
        mncField.text = NetworkUtils.getCellularInformation().mnc
        if mncField.text!.isEmpty {
            mncField.text = self.config.getMnc()
        }        
    }

 

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).

        func getLogin(_ sender: Any) {
            var parameters : [String: String] = [:]
            if(isMsisdnRequest) {
                parameters = NetworkUtils.requestConstructor(msisdn: msisdnField.text, sourceIp: isWithIP ? ipAddressField.text : EMPTY)
            } else if (isMccMncRequest) {
                    parameters = NetworkUtils.requestConstructor(mcc: mccField.text, mnc: mncField.text, sourceIp: isWithIP ? ipAddressField.text : EMPTY)
            } else {
                    parameters = NetworkUtils.requestConstructor(sourceIp: isWithIP ? ipAddressField.text : EMPTY)
            }
            request = HttpUtils.createRequestWithParams(url:config.getEndpoint(), params:parameters)
        }

    After having prepared a request URI the application sends GET request using the webview:

    • 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 error message.
    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.

Mode without Discovery request

You can add msisdn to the request to server side. To set the request parameters it uses setValues method:

    func setValues() {
        textView.text = self.config.getMsisdnWd()
    }

After you clicking Mobile Connect button the Application makes getLogin method call with your configuration in parameters.
This method generates GET request to the server side endpoint (from your configuration).
    func getLogin(_ sender: Any) {
        var parameters : [String: String] = [:]
        parameters = NetworkUtils.requestConstructor(msisdn:textView.text)
        request = HttpUtils.createRequestWithParams(url:config.getWdEndpoint(), params:parameters)
    }

After having prepared a request URI the application sends GET request using the webview http://server_side_endpoint?msisdn=your_msisdn. In case of failure while sending the request to server side, application shows error message. When the application gets valid response it shows message OK and opens web view dialog to start authentication.
After displaying web view you will see a few redirects until the web view gets the URL with code and state parameters.
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.