/// <summary> /// Get the SDK configuration for this user. /// /// Note: This method should be called only after SDK has been initialized. /// </summary> public static SdkConfiguration GetSdkConfiguration() { var sdkConfigurationStr = MaxUnityPluginClass.CallStatic <string>("getSdkConfiguration"); var sdkConfigurationDict = MaxSdkUtils.PropsStringToDict(sdkConfigurationStr); return(SdkConfiguration.Create(sdkConfigurationDict)); }
public AdInfo(string adInfoString) { string adUnitIdentifier; string networkName; string creativeIdentifier; string placement; string revenue; // NOTE: Unity Editor creates empty string var adInfoObject = MaxSdkUtils.PropsStringToDict(adInfoString); AdUnitIdentifier = adInfoObject.TryGetValue("adUnitId", out adUnitIdentifier) ? adUnitIdentifier : ""; NetworkName = adInfoObject.TryGetValue("networkName", out networkName) ? networkName : ""; CreativeIdentifier = adInfoObject.TryGetValue("creativeId", out creativeIdentifier) ? creativeIdentifier : ""; Placement = adInfoObject.TryGetValue("placement", out placement) ? placement : ""; if (adInfoObject.TryGetValue("revenue", out revenue)) { try { // InvariantCulture guarantees the decimal is used for the separator even in regions that use commas as the separator Revenue = double.Parse(revenue, NumberStyles.Any, CultureInfo.InvariantCulture); } catch (Exception exception) { MaxSdkLogger.E("Failed to parse double (" + revenue + ") with exception: " + exception); Revenue = -1; } } else { Revenue = -1; } }
public static SdkConfiguration GetSdkConfiguration() { var sdkConfigurationStr = _MaxGetSdkConfiguration(); var sdkConfigurationDict = MaxSdkUtils.PropsStringToDict(sdkConfigurationStr); return(SdkConfiguration.Create(sdkConfigurationDict)); }
public static AdInfo GetAdInfo(string adUnitIdentifier) { var adInfoString = MaxUnityPluginClass.CallStatic <string>("getAdInfo", adUnitIdentifier); if (string.IsNullOrEmpty(adInfoString)) { return(null); } var adInfoDictionary = MaxSdkUtils.PropsStringToDict(adInfoString); return(new AdInfo(adInfoDictionary)); }
public static AdInfo GetAdInfo(string adUnitIdentifier) { var adInfoString = _MaxGetAdInfo(adUnitIdentifier); if (string.IsNullOrEmpty(adInfoString)) { return(null); } var adInfoDictionary = MaxSdkUtils.PropsStringToDict(adInfoString); return(new AdInfo(adInfoDictionary)); }
public AdInfo(string adInfoString) { string adUnitIdentifier = ""; string networkName = ""; // NOTE: Unity Editor creates empty string IDictionary <string, string> adInfoObject = MaxSdkUtils.PropsStringToDict(adInfoString); adInfoObject.TryGetValue("adUnitId", out adUnitIdentifier); adInfoObject.TryGetValue("networkName", out networkName); AdUnitIdentifier = adUnitIdentifier; NetworkName = networkName; }
public MediatedNetworkInfo(string networkInfoString) { string name; string adapterClassName; string adapterVersion; string sdkVersion; // NOTE: Unity Editor creates empty string var mediatedNetworkObject = MaxSdkUtils.PropsStringToDict(networkInfoString); Name = mediatedNetworkObject.TryGetValue("name", out name) ? name : ""; AdapterClassName = mediatedNetworkObject.TryGetValue("adapterClassName", out adapterClassName) ? adapterClassName : ""; AdapterVersion = mediatedNetworkObject.TryGetValue("adapterVersion", out adapterVersion) ? adapterVersion : ""; SdkVersion = mediatedNetworkObject.TryGetValue("sdkVersion", out sdkVersion) ? sdkVersion : ""; }
/// <summary> /// Parses the prop string provided to a <see cref="Rect"/>. /// </summary> /// <param name="rectPropString">A prop string representing a Rect</param> /// <returns>A <see cref="Rect"/> the prop string represents.</returns> protected static Rect GetRectFromString(string rectPropString) { var rectDict = MaxSdkUtils.PropsStringToDict(rectPropString); float originX; float originY; float width; float height; string output; rectDict.TryGetValue("origin_x", out output); float.TryParse(output, out originX); rectDict.TryGetValue("origin_y", out output); float.TryParse(output, out originY); rectDict.TryGetValue("width", out output); float.TryParse(output, out width); rectDict.TryGetValue("height", out output); float.TryParse(output, out height); return(new Rect(originX, originY, width, height)); }
public void ForwardEvent(string eventPropsStr) { var eventProps = MaxSdkUtils.PropsStringToDict(eventPropsStr); var eventName = eventProps["name"]; if (eventName == "OnSdkInitializedEvent") { var sdkConfiguration = MaxSdkBase.SdkConfiguration.Create(eventProps); InvokeEvent(_onSdkInitializedEvent, sdkConfiguration); } else if (eventName == "OnVariablesUpdatedEvent") { InvokeEvent(_onVariablesUpdatedEvent); } else if (eventName == "OnSdkConsentDialogDismissedEvent") { InvokeEvent(_onSdkConsentDialogDismissedEvent); } // Ad Events else { var adUnitIdentifier = eventProps["adUnitId"]; if (eventName == "OnBannerAdLoadedEvent") { InvokeEvent(_onBannerAdLoadedEvent, adUnitIdentifier); } else if (eventName == "OnBannerAdLoadFailedEvent") { var errorCode = 0; int.TryParse(eventProps["errorCode"], out errorCode); InvokeEvent(_onBannerAdLoadFailedEvent, adUnitIdentifier, errorCode); } else if (eventName == "OnBannerAdClickedEvent") { InvokeEvent(_onBannerAdClickedEvent, adUnitIdentifier); } else if (eventName == "OnBannerAdExpandedEvent") { InvokeEvent(_onBannerAdExpandedEvent, adUnitIdentifier); } else if (eventName == "OnBannerAdCollapsedEvent") { InvokeEvent(_onBannerAdCollapsedEvent, adUnitIdentifier); } else if (eventName == "OnMRecAdLoadedEvent") { InvokeEvent(_onMRecAdLoadedEvent, adUnitIdentifier); } else if (eventName == "OnMRecAdLoadFailedEvent") { var errorCode = 0; int.TryParse(eventProps["errorCode"], out errorCode); InvokeEvent(_onMRecAdLoadFailedEvent, adUnitIdentifier, errorCode); } else if (eventName == "OnMRecAdClickedEvent") { InvokeEvent(_onMRecAdClickedEvent, adUnitIdentifier); } else if (eventName == "OnMRecAdExpandedEvent") { InvokeEvent(_onMRecAdExpandedEvent, adUnitIdentifier); } else if (eventName == "OnMRecAdCollapsedEvent") { InvokeEvent(_onMRecAdCollapsedEvent, adUnitIdentifier); } else if (eventName == "OnCrossPromoAdLoadedEvent") { InvokeEvent(_onCrossPromoAdLoadedEvent, adUnitIdentifier); } else if (eventName == "OnCrossPromoAdLoadFailedEvent") { var errorCode = 0; int.TryParse(eventProps["errorCode"], out errorCode); InvokeEvent(_onCrossPromoAdLoadFailedEvent, adUnitIdentifier, errorCode); } else if (eventName == "OnCrossPromoAdClickedEvent") { InvokeEvent(_onCrossPromoAdClickedEvent, adUnitIdentifier); } else if (eventName == "OnCrossPromoAdExpandedEvent") { InvokeEvent(_onCrossPromoAdExpandedEvent, adUnitIdentifier); } else if (eventName == "OnCrossPromoAdCollapsedEvent") { InvokeEvent(_onCrossPromoAdCollapsedEvent, adUnitIdentifier); } else if (eventName == "OnInterstitialLoadedEvent") { InvokeEvent(_onInterstitialLoadedEvent, adUnitIdentifier); } else if (eventName == "OnInterstitialLoadFailedEvent") { var errorCode = 0; int.TryParse(eventProps["errorCode"], out errorCode); InvokeEvent(_onInterstitialLoadFailedEvent, adUnitIdentifier, errorCode); } else if (eventName == "OnInterstitialHiddenEvent") { InvokeEvent(_onInterstitialHiddenEvent, adUnitIdentifier); } else if (eventName == "OnInterstitialDisplayedEvent") { InvokeEvent(_onInterstitialDisplayedEvent, adUnitIdentifier); } else if (eventName == "OnInterstitialAdFailedToDisplayEvent") { var errorCode = 0; int.TryParse(eventProps["errorCode"], out errorCode); InvokeEvent(_onInterstitialAdFailedToDisplayEvent, adUnitIdentifier, errorCode); } else if (eventName == "OnInterstitialClickedEvent") { InvokeEvent(_onInterstitialClickedEvent, adUnitIdentifier); } else if (eventName == "OnRewardedAdLoadedEvent") { InvokeEvent(_onRewardedAdLoadedEvent, adUnitIdentifier); } else if (eventName == "OnRewardedAdLoadFailedEvent") { var errorCode = 0; int.TryParse(eventProps["errorCode"], out errorCode); InvokeEvent(_onRewardedAdLoadFailedEvent, adUnitIdentifier, errorCode); } else if (eventName == "OnRewardedAdDisplayedEvent") { InvokeEvent(_onRewardedAdDisplayedEvent, adUnitIdentifier); } else if (eventName == "OnRewardedAdHiddenEvent") { InvokeEvent(_onRewardedAdHiddenEvent, adUnitIdentifier); } else if (eventName == "OnRewardedAdClickedEvent") { InvokeEvent(_onRewardedAdClickedEvent, adUnitIdentifier); } else if (eventName == "OnRewardedAdFailedToDisplayEvent") { var errorCode = 0; int.TryParse(eventProps["errorCode"], out errorCode); InvokeEvent(_onRewardedAdFailedToDisplayEvent, adUnitIdentifier, errorCode); } else if (eventName == "OnRewardedAdReceivedRewardEvent") { var reward = new MaxSdkBase.Reward { Label = eventProps["rewardLabel"] }; int.TryParse(eventProps["rewardAmount"], out reward.Amount); InvokeEvent(_onRewardedAdReceivedRewardEvent, adUnitIdentifier, reward); } else if (eventName == "OnRewardedInterstitialAdLoadedEvent") { InvokeEvent(_onRewardedInterstitialAdLoadedEvent, adUnitIdentifier); } else if (eventName == "OnRewardedInterstitialAdLoadFailedEvent") { var errorCode = 0; int.TryParse(eventProps["errorCode"], out errorCode); InvokeEvent(_onRewardedInterstitialAdLoadFailedEvent, adUnitIdentifier, errorCode); } else if (eventName == "OnRewardedInterstitialAdDisplayedEvent") { InvokeEvent(_onRewardedInterstitialAdDisplayedEvent, adUnitIdentifier); } else if (eventName == "OnRewardedInterstitialAdHiddenEvent") { InvokeEvent(_onRewardedInterstitialAdHiddenEvent, adUnitIdentifier); } else if (eventName == "OnRewardedInterstitialAdClickedEvent") { InvokeEvent(_onRewardedInterstitialAdClickedEvent, adUnitIdentifier); } else if (eventName == "OnRewardedInterstitialAdFailedToDisplayEvent") { var errorCode = 0; int.TryParse(eventProps["errorCode"], out errorCode); InvokeEvent(_onRewardedInterstitialAdFailedToDisplayEvent, adUnitIdentifier, errorCode); } else if (eventName == "OnRewardedInterstitialAdReceivedRewardEvent") { var reward = new MaxSdkBase.Reward { Label = eventProps["rewardLabel"] }; int.TryParse(eventProps["rewardAmount"], out reward.Amount); InvokeEvent(_onRewardedInterstitialAdReceivedRewardEvent, adUnitIdentifier, reward); } else { MaxSdkLogger.UserWarning("Unknown MAX Ads event fired: " + eventName); } } }
public void ForwardEvent(string eventPropsStr) { var eventProps = MaxSdkUtils.PropsStringToDict(eventPropsStr); var eventName = eventProps["name"]; if (eventName == "OnSdkInitializedEvent") { var consentDialogStateStr = eventProps["consentDialogState"]; var sdkConfiguration = new MaxSdkBase.SdkConfiguration(); if ("1".Equals(consentDialogStateStr)) { sdkConfiguration.ConsentDialogState = MaxSdkBase.ConsentDialogState.Applies; } else if ("2".Equals(consentDialogStateStr)) { sdkConfiguration.ConsentDialogState = MaxSdkBase.ConsentDialogState.DoesNotApply; } else { sdkConfiguration.ConsentDialogState = MaxSdkBase.ConsentDialogState.Unknown; } InvokeEvent(OnSdkInitializedEvent, sdkConfiguration); } else if (eventName == "OnVariablesUpdatedEvent") { InvokeEvent(OnVariablesUpdatedEvent); } // Ad Events else { var adUnitIdentifier = eventProps["adUnitId"]; if (eventName == "OnBannerAdLoadedEvent") { InvokeEvent(OnBannerAdLoadedEvent, adUnitIdentifier); } else if (eventName == "OnBannerAdLoadFailedEvent") { var errorCode = 0; int.TryParse(eventProps["errorCode"], out errorCode); InvokeEvent(OnBannerAdLoadFailedEvent, adUnitIdentifier, errorCode); } else if (eventName == "OnBannerAdClickedEvent") { InvokeEvent(OnBannerAdClickedEvent, adUnitIdentifier); } else if (eventName == "OnBannerAdExpandedEvent") { InvokeEvent(OnBannerAdExpandedEvent, adUnitIdentifier); } else if (eventName == "OnBannerAdCollapsedEvent") { InvokeEvent(OnBannerAdCollapsedEvent, adUnitIdentifier); } else if (eventName == "OnMRecAdLoadedEvent") { InvokeEvent(OnMRecAdLoadedEvent, adUnitIdentifier); } else if (eventName == "OnMRecAdLoadFailedEvent") { var errorCode = 0; int.TryParse(eventProps["errorCode"], out errorCode); InvokeEvent(OnMRecAdLoadFailedEvent, adUnitIdentifier, errorCode); } else if (eventName == "OnMRecAdClickedEvent") { InvokeEvent(OnMRecAdClickedEvent, adUnitIdentifier); } else if (eventName == "OnMRecAdExpandedEvent") { InvokeEvent(OnMRecAdExpandedEvent, adUnitIdentifier); } else if (eventName == "OnMRecAdCollapsedEvent") { InvokeEvent(OnMRecAdCollapsedEvent, adUnitIdentifier); } else if (eventName == "OnInterstitialLoadedEvent") { InvokeEvent(OnInterstitialLoadedEvent, adUnitIdentifier); } else if (eventName == "OnInterstitialLoadFailedEvent") { var errorCode = 0; int.TryParse(eventProps["errorCode"], out errorCode); InvokeEvent(OnInterstitialLoadFailedEvent, adUnitIdentifier, errorCode); } else if (eventName == "OnInterstitialHiddenEvent") { InvokeEvent(OnInterstitialHiddenEvent, adUnitIdentifier); } else if (eventName == "OnInterstitialDisplayedEvent") { InvokeEvent(OnInterstitialDisplayedEvent, adUnitIdentifier); } else if (eventName == "OnInterstitialAdFailedToDisplayEvent") { var errorCode = 0; int.TryParse(eventProps["errorCode"], out errorCode); InvokeEvent(OnInterstitialAdFailedToDisplayEvent, adUnitIdentifier, errorCode); } else if (eventName == "OnInterstitialClickedEvent") { InvokeEvent(OnInterstitialClickedEvent, adUnitIdentifier); } else if (eventName == "OnRewardedAdLoadedEvent") { InvokeEvent(OnRewardedAdLoadedEvent, adUnitIdentifier); } else if (eventName == "OnRewardedAdLoadFailedEvent") { var errorCode = 0; int.TryParse(eventProps["errorCode"], out errorCode); InvokeEvent(OnRewardedAdLoadFailedEvent, adUnitIdentifier, errorCode); } else if (eventName == "OnRewardedAdDisplayedEvent") { InvokeEvent(OnRewardedAdDisplayedEvent, adUnitIdentifier); } else if (eventName == "OnRewardedAdHiddenEvent") { InvokeEvent(OnRewardedAdHiddenEvent, adUnitIdentifier); } else if (eventName == "OnRewardedAdClickedEvent") { InvokeEvent(OnRewardedAdClickedEvent, adUnitIdentifier); } else if (eventName == "OnRewardedAdFailedToDisplayEvent") { var errorCode = 0; int.TryParse(eventProps["errorCode"], out errorCode); InvokeEvent(OnRewardedAdFailedToDisplayEvent, adUnitIdentifier, errorCode); } else if (eventName == "OnRewardedAdReceivedRewardEvent") { var reward = new MaxSdkBase.Reward { Label = eventProps["rewardLabel"] }; int.TryParse(eventProps["rewardAmount"], out reward.Amount); InvokeEvent(OnRewardedAdReceivedRewardEvent, adUnitIdentifier, reward); } else { Debug.LogWarning("[AppLovin MAX] Unknown MAX Ads event fired: " + eventName); } } }