支持观测数据回放,为复盘提供依据。
iOS
```objective-c
// 从 URL 中获取参数
NSURL url = [NSURL URLWithString:@"myApp://?param1=value1¶m2=value2"];
NSDictionary params = [self parseQueryString:url.query];
// 调用 Objective-C 方法,将参数传递给应用程序
[self myMethodWithParam1:params[@"param1"] param2:params[@"param2"]];
```
Android
```java
// 从 Intent 中获取参数
Intent intent = getIntent();
String param1 = intent.getStringExtra("param1");
String param2 = intent.getStringExtra("param2");
// 调用 Java 方法,将参数传递给应用程序
myMethod(param1, param2);
```
通用
要将参数传递到应用程序,您可以使用通用 URI 方案,如下所示:
```
myApp://?param1=value1¶m2=value2
```
其中:
`myApp` 是您应用程序的 URI 方案。
`param1` 和 `param2` 是要传递的参数。
`value1` 和 `value2` 是参数的值。
解析查询字符串
以下是一个解析查询字符串的辅助函数(Objective-C):
```objective-c
- (NSDictionary )parseQueryString:(NSString )queryString {
NSMutableDictionary params = [NSMutableDictionary dictionary];
NSArray components = [queryString componentsSeparatedByString:@"&"];
for (NSString component in components) {

NSArray pair = [component componentsSeparatedByString:@"="];
if (pair.count == 2) {
params[pair[0]] = pair[1];
}
}
return params;
}
```