/// <summary> /// Returns an id value for a certain type. If the id is not known, an empty /// string is returned. /// </summary> /// <returns>id value or "" if no value was stored for that type.</returns> /// <param name="aType">Id type to get value for.</param> internal String Get(IQUIdType aType) { // handle types that have a fixed value and not stored in the array switch (aType) { #if UNITY_ANDROID && !UNITY_EDITOR case IQUIdType.AndroidId: return IQUSDK.Instance.Device.AndroidId; case IQUIdType.AndroidSerial: return IQUSDK.Instance.Device.AndroidSerial; #elif UNITY_IOS && !UNITY_EDITOR case IQUIdType.IOSVendor: return IQUSDK.Instance.Device.VendorId; #endif default: return this.m_ids[(int)aType]; } }
/// <summary> /// Return id for a certain type. If the id is not known (yet), the method /// will return an empty string. /// </summary> /// <returns>stored id value or empty string if it not (yet) known.</returns> /// <param name="aType">Type to get id for.</param> public string GetId(IQUIdType aType) { return this.m_ids.Get(aType); }
/// <summary> /// Store a new id or update existing id with new value. /// </summary> /// <param name="aType">Type to store id for.</param> /// <param name="aValue">Value to store.</param> private void SetId(IQUIdType aType, string aValue) { this.m_ids.Set(aType, aValue); if (this.Initialized) { this.m_pendingMessages.UpdateId(aType, aValue); } }
/// <summary> /// Returns property name for use with JSON formatted definitions. /// </summary> /// <returns>name for use with JSON formatted definitions.</returns> /// <param name="aType">Type to get JSON name for</param> private String GetJSONName(IQUIdType aType) { switch (aType) { case IQUIdType.Custom: return "custom_user_id"; case IQUIdType.Facebook: return "facebook_user_id"; case IQUIdType.GooglePlus: return "google_plus_user_id"; case IQUIdType.SDK: return "iqu_sdk_id"; case IQUIdType.Twitter: return "twitter_user_id"; #if UNITY_ANDROID && !UNITY_EDITOR case IQUIdType.AndroidAdTracking: return "android_ad_tracking"; case IQUIdType.AndroidAdvertising: return "android_advertising_id"; case IQUIdType.AndroidId: return "android_id"; case IQUIdType.AndroidSerial: return "android_serial"; #endif #if UNITY_IOS && !UNITY_EDITOR case IQUIdType.IOSAdvertising: return "ios_advertising_identifier"; case IQUIdType.IOSVendor: return "ios_vendor_id"; case IQUIdType.IOSAdTracking: return "ios_ad_tracking"; #endif default: return aType.ToString(); } }
/// <summary> /// Store a value for a certain type. Any previous value is overwritten. /// </summary> /// <param name="aType">Type to store value for.</param> /// <param name="aValue">Value to store for the type.</param> internal void Set(IQUIdType aType, String aValue) { // don't store value for types that have a fixed value switch (aType) { #if UNITY_ANDROID && !UNITY_EDITOR case IQUIdType.AndroidId: case IQUIdType.AndroidSerial: return; #elif UNITY_IOS && !UNITY_EDITOR case IQUIdType.IOSVendor: return; #endif default: this.m_ids[(int)aType] = aValue == null ? "" : aValue; break; } }
/// <summary> /// Updates an id within all the stored messages. /// </summary> /// <param name="aType">Id type to update value for.</param> /// <param name="aNewValue">New value to use.</param> internal void UpdateId(IQUIdType aType, String aNewValue) { for (IQUMessage message = this.m_first; message != null; message = message.Next) { message.UpdateId(aType, aNewValue); } }
/// <summary> /// Update an id with a new value. For certain types the id only gets updated /// if it is currently empty. /// </summary> /// <param name="aType">Type to update</param> /// <param name="aNewValue">New value to use</param> internal void UpdateId(IQUIdType aType, String aNewValue) { // get current value and exit for certain types if the current value is // not empty. String currentValue = this.m_ids.Get(aType); switch (aType) { case IQUIdType.Custom: case IQUIdType.Facebook: case IQUIdType.Twitter: case IQUIdType.GooglePlus: case IQUIdType.SDK: if (currentValue.Length > 0) { return; } break; } if (currentValue != aNewValue) { this.m_ids.Set(aType, aNewValue); // message changed if (this.m_queue != null) { this.m_queue.HandleMessageChanged(this); } } }