|
21 | 21 | %{#include "app/src/export_fix.h"%} |
22 | 22 | #endif |
23 | 23 |
|
| 24 | +%include "std_map.i" |
| 25 | + |
24 | 26 | %pragma(csharp) moduleclassmodifiers="public sealed class" |
25 | 27 | %pragma(csharp) modulecode=%{ |
26 | 28 | // Hold a reference to the default app when methods from this module are |
|
45 | 47 | #include "analytics/src/include/firebase/analytics/user_property_names.h" |
46 | 48 | %} |
47 | 49 |
|
| 50 | +%rename(kConsentTypeAdStorage) firebase::analytics::kConsentTypeAdStorage; |
| 51 | +%rename(kConsentTypeAnalyticsStorage) firebase::analytics::kConsentTypeAnalyticsStorage; |
| 52 | +%rename(kConsentStatusGranted) firebase::analytics::kConsentStatusGranted; |
| 53 | +%rename(kConsentStatusDenied) firebase::analytics::kConsentStatusDenied; |
| 54 | + |
48 | 55 | // Constant renaming must happen before SWIG_CONSTANT_HEADERS is included. |
49 | 56 | %rename(kParameterAchievementId) firebase::analytics::kParameterAchievementID; |
50 | 57 | %rename(kParameterGroupId) firebase::analytics::kParameterGroupID; |
@@ -231,6 +238,9 @@ class ParameterCopy : private firebase::analytics::Parameter { |
231 | 238 | // Initialize / Terminate implicitly called when App is created / destroyed. |
232 | 239 | %ignore Initialize; |
233 | 240 | %ignore Terminate; |
| 241 | +// SetConsent handled via SetConsentInternal below. |
| 242 | +%ignore SetConsent; |
| 243 | + |
234 | 244 | } // namespace analytics |
235 | 245 | } // namespace firebase |
236 | 246 |
|
@@ -278,5 +288,49 @@ class ParameterCopy : private firebase::analytics::Parameter { |
278 | 288 | } |
279 | 289 | %} |
280 | 290 |
|
281 | | - |
282 | 291 | %include "analytics/src/include/firebase/analytics.h" |
| 292 | + |
| 293 | +%rename(ConsentType) firebase::analytics::ConsentType; |
| 294 | +%rename(ConsentStatus) firebase::analytics::ConsentStatus; |
| 295 | +// Add a swig C++ function to call into the Analytics C++ implementation. |
| 296 | +%{ |
| 297 | +namespace firebase { |
| 298 | +namespace analytics { |
| 299 | + |
| 300 | + void SetConsentInternal(std::map<firebase::analytics::ConsentType, firebase::analytics::ConsentStatus> *ptr) { |
| 301 | + firebase::analytics::SetConsent(*ptr); |
| 302 | + } |
| 303 | + |
| 304 | +} // namespace analytics |
| 305 | +} // namespace firebase |
| 306 | +%} |
| 307 | +// The definition on the C++ side, so that swig is aware of the function's existence. |
| 308 | +void SetConsentInternal(std::map<firebase::analytics::ConsentType, firebase::analytics::ConsentStatus> *ptr); |
| 309 | + |
| 310 | +%typemap(csclassmodifiers) firebase::analytics::ConsentType "enum"; |
| 311 | +%typemap(csclassmodifiers) firebase::analytics::ConsentStatus "enum"; |
| 312 | + |
| 313 | +%typemap(csclassmodifiers) std::map<firebase::analytics::ConsentType, firebase::analytics::ConsentStatus> "internal class" |
| 314 | +%template(ConsentMap) std::map<firebase::analytics::ConsentType, firebase::analytics::ConsentStatus>; |
| 315 | + |
| 316 | +namespace firebase { |
| 317 | +namespace analytics { |
| 318 | + |
| 319 | +%pragma(csharp) modulecode=%{ |
| 320 | + /// @brief Sets the applicable end user consent state (e.g., for device |
| 321 | + /// identifiers) for this app on this device. |
| 322 | + /// |
| 323 | + /// Use the consent map to specify individual consent type values. Settings are |
| 324 | + /// persisted across app sessions. By default consent types are set to |
| 325 | + /// "granted". |
| 326 | + public static void SetConsent(System.Collections.Generic.IDictionary<ConsentType, ConsentStatus> consentSettings) { |
| 327 | + ConsentMap consentSettingsMap = new ConsentMap(); |
| 328 | + foreach(var kv in consentSettings) { |
| 329 | + consentSettingsMap[kv.Key] = kv.Value; |
| 330 | + } |
| 331 | + SetConsentInternal(consentSettingsMap); |
| 332 | + } |
| 333 | +%} |
| 334 | + |
| 335 | +} // namespace analytics |
| 336 | +} // namespace firebase |
0 commit comments