value_data.push_back(v.get<std::string>().c_str());
}
- auto result = app_control_add_extra_data_array(app_control, key.c_str(), value_data.data(),
- value_data.size());
+ int result = APP_CONTROL_ERROR_NONE;
+ /*
+ * Native applications handle single extra data objects and arrays in a different ways,
+ * hence they have to be packed with different native API functions.
+ */
+ if (1 == value_data.size()) {
+ result = app_control_add_extra_data(app_control, key.c_str(), value_data[0]);
+ } else {
+ result = app_control_add_extra_data_array(app_control, key.c_str(), value_data.data(), value_data.size());
+ }
+
if (APP_CONTROL_ERROR_INVALID_PARAMETER == result) {
if (0 == key.length()) {
LoggerD("app_control_add_extra_data_array failed: zero-length key");