All Products
Search
Document Center

Mobile Platform as a Service:iOS

Last Updated:Oct 30, 2023

Important: Since June 28, 2020, mPaaS has stopped support for the baseline 10.1.32. Please use 10.1.68 or 10.1.60 instead. For how to upgrade the baseline from version 10.1.32 to 10.1.68 or 10.1.60, see mPaaS 10.1.68 upgrade guide or mPaaS 10.1.60 upgrade guide.

Switch configuration refers to the capability of dynamically modifying client-side code processing logic without releasing a new version on the client. The client controls relevant processing according to the extracted switch value that is dynamically configured at backend. By using the switch configuration service, you can configure, modify and push various types of switches. The switch refers to key/value pair.

mPaaS provides the configuration management service ConfigService to realize switch configuration. By default, the syncing logic is syncing a switch value at the cold start of the application, or syncing a switch value if half an hour passed since last sync after the application returns to the foreground. In addition, ConfigService also provides an interface for immediate sync and the logic for monitoring configuration changes, by which configuration can be refreshed as soon as it is changed.

To realize switch configuration management, you need to add the corresponding iOS SDK, configure the project and read the configuration.

Prerequisites

The project is connected to mPaaS. For more information, refer to: Access based on native framework and using Cocoapods.

About this task

This document introduce how to integrate the switch configuration in details based on the switch configuration code sample.

Add an SDK

  1. In the Podfile, define mPaaS_pod "mPaaS_Config" to add the dependencies of the switch configuration component.

    config
  2. Based on requirements, run the pod install or pod update command.

Configure a project

Note: This step is applicable to baseline 10.1.32. The project configuration feature is built in baselines 10.1.60 and 10.1.68. Therefore, you can ignore this step when baseline 10.1.60 or 10.1.68 is used.

mPaaS encapsulates the switch configuration capability to a service. and you need to register this service in service manager before using it, as shown in the following figure.

Register the switch configuration service

Read the configurations

Values of switch keys can be dynamically released in the mPaaS console. On the left navigation pane, choose Mobile Delivery Service > Configuration management. Click Configuration Keys to view the detailed configurations.

What to do next

Obtain switch value

In the mPaaS Console, add necessary switch configuration items in Mobile Delivery Service > Configuration management, and deliver the configuration items by platform, whitelist, percentage, version, device model, iOS version and other information. For detailed operations, see Manage configurations.

When the switch key is released through the console, the client can get the key value corresponding to the switch key by calling relevant interface.

+ (void)testStringForKey
{
     id<APConfigService>configService = [DTContextGet() findServiceByName:@"APConfigService"];
    NSString *configValue = [configService stringValueForKey:@"BillEntrance"];
    assert (configValue && [configValue isKindOfClass:[NSString class]]);
}
Note: Switch key values are obtained by calling the RPC API. The call to the RPC API is not necessarily successful. Therefore, you must consider the local processing logic on the client to deal with failures in obtaining key values. We recommend that you set a default switch value in the local logic on the client. You can enable the client to use a new configuration logic when the console delivers a new switch value and use the local default logic when the client fails to obtain a key value.

Advanced operations

  • Set the time when the client pulls a switch value:

    • During cold start of the application

    • 30 minutes later than last pull after the application returns to the foreground

      Note

      The interval of 30 minutes is the default value. You can modify the interval by adding switch Load_Config_Interval on the Configuration Switch Management page under Mobile Delivery Service in the mPaaS console. For more information about the steps, see Manage configurations.

      config

  • Dynamically monitor switch value changes

    • You can add an observer for a specified key to dynamically monitor switch value changes.屏幕快照 2018-12-28 12

    • When the client pulls switch configurations, you can obtain the latest switch value of the specified key in the callback method.屏幕快照 2018-12-28 12

  • You can forcibly pull a switch value from the console by using an SDK.屏幕快照 2018-12-28 12