Version 2021

Pass Custom Login Parameters in iOS

A third-party application can validate login credentials with the MicroStrategy Mobile server and log the user into MicroStrategy Mobile. To perform the validation, the third-party application can use custom parameters such as the device ID. There are a number of different ways to obtain custom parameters that can be passed to the third-party application.

The code snippets below illustrate how to pass the device ID and other custom parameters to the server or to a task. To use these code snippets, you need to import the header file for the MSIGeneric class: #import <MicroStrategyMobileSDK/MSIGeneric.h>.

  • ConnectionInfo.plist

    You can add custom parameter values for existing keys in the ConnectionInfo.plist file.

    Copy
    //load configuration information from plist
        NSString *plistFile= @"ConnectionInfo.plist";
        [MSIGeneric setupConnectInfoFromPlist: plistFile];

    If you add custom parameter keys in this file, they will be ignored. To add custom key:value pairs, use the global environment variables described below.

  • Device settings:

    The device settings can be retrieved from the global environment settings to determine the device ID. The third-party application can determine what kind of device is hitting the Mobile Server as part of the validation process.:

    Copy
    //check or not check UUID
    SDKEnvSettings *sdkEnvSettings =  [MSIGeneric getSDKEnvSettings];
    sdkEnvSettings.isUserDeviceUUID = YES;
  • Custom text entered by the user::

    The third-party application can include a screen that allows a user to enter a custom parameter in a text field. The parameter value is saved in the global environment settings.:

    Copy
    //use custom text entered by user
     [sdkEnvSettings setServerParam: [ self.customTextField text ] forKey: @"customText" ];
  • Key:value pairs provided in the code:

    Multiple key:value pairs can be provided in the code and saved in the global environment settings. For example, in the code snippet below, you would replace "key1" with the name of a custom parameter and "value1" with the value for that parameter. Similarly, you would replace "key2" with the name of a second custom parameter and "value2" with the value for that parameter, and you would replace "key3" with the name of a third custom parameter and "value3" with the value for that parameter. You can provide as few or as many parameters as are needed for validation. Every server call will have these parameters associated with it.:

    Copy
     [sdkEnvSettings setServerParam: @"value1" forKey: @"key1" ];
     [sdkEnvSettings setServerParam: @"value2" forKey: @"key2" ];
     [sdkEnvSettings setServerParam: @"value3" forKey: @"key3" ];

    When loginWithSessionState is invoked to log the user in, the MicroStrategy framework knows how to get the parameters from the plist file and the global environment variables.

    Copy
    //log in
     [self loginWithSessionState: plistFile ];

    See Logging On: Creating and Using Sessions for an explanation of how to create and use MicroStrategy sessions from a mobile application. See Customizing Authentication for an explanation of how to customize the mobile login task. See Adding customized headers to network requests for an explanation on how to customize header values sent in requests to the Mobile server.