> For the complete documentation index, see [llms.txt](https://dtsupport.gitbook.io/mta-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dtsupport.gitbook.io/mta-docs/app/app_advance_access/app_advance_access_params.md).

# 在线参数

## 功能介绍

开发者在腾讯移动分析网站上设置Key-Value值之后，可以通过接口调用动态获取线上最新的参数值。可用于以下场景：

* 内容更新，文案、价格、应用欢迎语等
* 开关控制，广告的开启和关闭
* 简单的逻辑控制，比如当满足一定条件之后更改对应的内容展示

快速入口：

* [Android 代码集成](https://dtsupport.gitbook.io/mta-docs/app/app_advance_access/pages/-M7juN6snIiZgnf7VLN_#android代码集成)
* [iOS 代码集成](https://dtsupport.gitbook.io/mta-docs/app/app_advance_access/pages/-M7juN6snIiZgnf7VLN_#ios代码集成)

## Android代码集成

### 更新机制

用户在前台配置在线参数，并不是实时下发的，而是当SDK上报会话统计日志时才会更新。调试时，可在配置参数10分钟后，让app退到后台超过30秒发生超时或把app进程杀死重启，产生一个会话，便会更新。

### 集成代码

```java
    /**
     * 获取在线参数
     *
     * @param ctx context上下文
     * @param key 特定的key
     * @return 特定key的值，若找不到赠返回null
     */
    public static String getCustomProperty(Context ctx, String key);

    /**
     * 获取在线参数
     *
     * @param ctx          context上下文
     * @param key          特定的key
     * @param defaultValue 默认值
     * @return 特定key的值，若找不到赠返回defaultValue
     */
    public static String getCustomProperty(Context ctx, String key, String defaultValue);
```

```java
    protected void someAction() { 
        // 获取在线参数onlineKey
        String onlineValue = StatConfig.getCustomProperty("onlineKey", "off" );
        if(onlineValue.equalsIgnoreCase("on")){
            // do something
        }else{
            // do something else
        }
```

## iOS代码集成

**（1）接口**

```c
/**
 获取在MTA前端控制台配置的参数
 调用这个函数前需要在MTA前端控制台中‘应用配置管理项’下的‘自定义参数’中配置才能生效
 首次配置或者更改参数配置后，需要3-5分钟才能生效

 @param key 参数的key
 @param v 没取到参数时返回的默认值
 @return 参数的值或者默认值
 */
- (NSString *)getCustomProperty:(NSString *)key default:(NSString *)v;
```

**（2）示例**

```c
    [[MTAConfig getInstance] getCustomProperty:@"参数名称" default:nil];
```

**注意："参数名称"要与MTA管理台配置的参数名称一致**
