void OnApplicationFocus(bool hasFocus)
        {
            Debug.Log("===> OnApplicationFocus() hasFocus:" + hasFocus);
            isAppFocus = hasFocus;

                        #if UNITY_ANDROID && !UNITY_EDITOR
            canObserverAppFocusCall = true;
            PolyADSDK.OnApplicationFocus(hasFocus);
            Debug.Log("===> Game OnApplicationFocus Call, android hasFocus: " + hasFocus);
                        #endif
        }
예제 #2
0
        // Use this for initialization
        public string initSDK(int azone)
        {
                        #if UNITY_IOS && !UNITY_EDITOR
            string result = initIosSDKByZone(PolyADSDKGameObject.GameObject_Callback_Name, PolyADSDKGameObject.Java_Callback_Function, azone);
            if (UPSDK.UPSDKInitFinishedCallback != null)
            {
                UPSDK.UPSDKInitFinishedCallback(true, "UPSDK Init Ios Sdk Finish");
            }
            else if (PolyADSDK.AvidlySDKInitFinishedCallback != null)
            {
                PolyADSDK.AvidlySDKInitFinishedCallback(true, "UPSDK Init Ios Sdk Finish");
            }
            return(result);
                        #elif UNITY_ANDROID && !UNITY_EDITOR
            if (jc == null)
            {
                //Debug.Log (JavaClassName);
                jc = new AndroidJavaClass(JavaClassName);
            }
            string resule = jc.CallStatic <string> (JavaClassStaticMethod_IniSDKByZone,
                                                    PolyADSDKGameObject.GameObject_Callback_Name,
                                                    PolyADSDKGameObject.Java_Callback_Function,
                                                    azone);
            if (UPSDK.UPSDKInitFinishedCallback != null)
            {
                UPSDK.UPSDKInitFinishedCallback(true, "UPSDK Init Android Sdk Finish");
            }
            else if (PolyADSDK.AvidlySDKInitFinishedCallback != null)
            {
                PolyADSDK.AvidlySDKInitFinishedCallback(true, "UPSDK Init Android Sdk Finish");
            }
            return(resule);
                        #else
            // "do nothing";
            if (PolyADSDK.AvidlySDKInitFinishedCallback != null)
            {
                PolyADSDK.AvidlySDKInitFinishedCallback(false, "UPSDK can't ini unkown platform");
            }
            return("initSDK ()");
                        #endif



            //return "initSDK ()";
        }
        public void doCallback(string message)
        {
            Debug.Log(message);
            Hashtable jsonObj = (Hashtable)PolyXXJSON.MiniJSON.jsonDecode(message);

            if (jsonObj.ContainsKey("function"))
            {
                string function = (string)jsonObj["function"];
                string msg      = "";
                string placeId  = "";
                if (jsonObj.ContainsKey("function"))
                {
                    msg     = (string)jsonObj["message"];
                    placeId = (string)jsonObj["cpadsid"];
                }
                Debug.Log("===> function: " + function + ",cpadsid: " + placeId);
                bool isReportOnlineDebug = false;
                if (adCall != null)
                {
                    isReportOnlineDebug = adCall.IsReportOnlineEnable();
                    if (isReportOnlineDebug)
                    {
                        adCall.reportPluginInvokeMethodCall("UnityPlugin doCallback, function: " + function + ",cpadsid: " + placeId);
                    }
                }
                //reward callback
                if (function.Equals(Function_Reward_DidOpen))
                {
                    string fmsg = "";
                    if (UPSDK.UPRewardDidOpenCallback != null)
                    {
                        Debug.Log("===> function UPRewardDidOpenCallback(): ");
                        UPSDK.UPRewardDidOpenCallback(placeId, msg);
                        fmsg = "UnityPlugin Run UPSDK.RewardDidOpenCallback()";
                    }
                    else if (PolyADSDK.AvidlyRewardDidOpenCallback != null)
                    {
                        Debug.Log("===> function AvidlyRewardDidOpenCallback(): ");
                        PolyADSDK.AvidlyRewardDidOpenCallback(placeId, msg);
                        fmsg = "UnityPlugin Run PolyADSDK.RewardDidOpenCallback()";
                    }
                    else
                    {
                        Debug.Log("===> function call fail, no delegate object. ");
                        fmsg = "can't run RewardDidOpenCallback(), no delegate object.";
                    }
                    if (isReportOnlineDebug)
                    {
                        adCall.reportAdVideoShowDid(fmsg);
                    }
                }
                else if (function.Equals(Function_Reward_DidClick))
                {
                    string fmsg = "can't run RewardDidClickCallback(), no delegate object.";
                    if (UPSDK.UPRewardDidClickCallback != null)
                    {
                        UPSDK.UPRewardDidClickCallback(placeId, msg);
                        fmsg = "UnityPlugin Run UPSDK.RewardDidClickCallback()";
                    }
                    else if (PolyADSDK.AvidlyRewardDidClickCallback != null)
                    {
                        PolyADSDK.AvidlyRewardDidClickCallback(placeId, msg);
                        fmsg = "UnityPlugin Run PolyADSDK.RewardDidClickCallback()";
                    }
                    if (isReportOnlineDebug)
                    {
                        adCall.reportAdVideoClick(fmsg);
                    }
                }
                else if (function.Equals(Function_Reward_DidClose))
                {
                    string fmsg = "can't run RewardDidCloseCallback(), no delegate object.";
                    if (UPSDK.UPRewardDidCloseCallback != null)
                    {
                        UPSDK.UPRewardDidCloseCallback(placeId, msg);
                        fmsg = "UnityPlugin Run UPSDK.RewardDidCloseCallback()";
                    }
                    else if (PolyADSDK.AvidlyRewardDidCloseCallback != null)
                    {
                        PolyADSDK.AvidlyRewardDidCloseCallback(placeId, msg);
                        fmsg = "UnityPlugin Run PolyADSDK.RewardDidCloseCallback()";
                    }
                    if (isReportOnlineDebug)
                    {
                        adCall.reportAdVideoClose(fmsg);
                    }
                }
                else if (function.Equals(Function_Reward_DidGivien))
                {
                    string fmsg = "can't run RewardDidGivenCallback(), no delegate object.";
                    if (UPSDK.UPRewardDidGivenCallback != null)
                    {
                        UPSDK.UPRewardDidGivenCallback(placeId, msg);
                        fmsg = "UnityPlugin Run UPSDK.RewardDidGivenCallback()";
                    }
                    else if (PolyADSDK.AvidlyRewardDidGivenCallback != null)
                    {
                        PolyADSDK.AvidlyRewardDidGivenCallback(placeId, msg);
                        fmsg = "UnityPlugin Run PolyADSDK.RewardDidGivenCallback()";
                    }
                    if (isReportOnlineDebug)
                    {
                        adCall.reportAdVideoRewardGiven(fmsg);
                    }
                }
                else if (function.Equals(Function_Reward_DidAbandon))
                {
                    string fmsg = "can't run RewardDidAbandonCallback(), no delegate object.";
                    if (UPSDK.UPRewardDidAbandonCallback != null)
                    {
                        UPSDK.UPRewardDidAbandonCallback(placeId, msg);
                        fmsg = "UnityPlugin Run UPSDK.RewardDidAbandonCallback()";
                    }
                    else if (PolyADSDK.AvidlyRewardDidAbandonCallback != null)
                    {
                        PolyADSDK.AvidlyRewardDidAbandonCallback(placeId, msg);
                        fmsg = "UnityPlugin Run PolyADSDK.RewardDidAbandonCallback()";
                    }
                    if (isReportOnlineDebug)
                    {
                        adCall.reportAdVideoRewardCancel(fmsg);
                    }
                }
                //Interstitial callback
                else if (function.Equals(Function_Interstitial_Didshow))
                {
                    string fmsg = "can't run InterstitialDidShowCallback(), no delegate object.";
                    if (UPSDK.UPInterstitialDidShowCallback != null)
                    {
                        UPSDK.UPInterstitialDidShowCallback(placeId, msg);
                        fmsg = "UnityPlugin Run UPSDK.InterstitialDidShowCallback()";
                    }
                    else if (PolyADSDK.AvidlyInterstitialDidShowCallback != null)
                    {
                        PolyADSDK.AvidlyInterstitialDidShowCallback(placeId, msg);
                        fmsg = "UnityPlugin Run PolyADSDK.InterstitialDidShowCallback()";
                    }
                    if (isReportOnlineDebug)
                    {
                        adCall.reportILDidShow(placeId, fmsg);
                    }
                }
                else if (function.Equals(Function_Interstitial_Didclose))
                {
                    string fmsg = "can't run InterstitialDidCloseCallback(), no delegate object.";
                    if (UPSDK.UPInterstitialDidCloseCallback != null)
                    {
                        UPSDK.UPInterstitialDidCloseCallback(placeId, msg);
                        fmsg = "UnityPlugin Run UPSDK.InterstitialDidCloseCallback()";
                    }
                    else if (PolyADSDK.AvidlyInterstitialDidCloseCallback != null)
                    {
                        PolyADSDK.AvidlyInterstitialDidCloseCallback(placeId, msg);
                        fmsg = "UnityPlugin Run PolyADSDK.InterstitialDidCloseCallback()";
                    }
                    if (isReportOnlineDebug)
                    {
                        adCall.reportILClose(placeId, fmsg);
                    }
                }
                else if (function.Equals(Function_Interstitial_Didclick))
                {
                    string fmsg = "can't run InterstitialDidClickCallback(), no delegate object.";
                    if (UPSDK.UPInterstitialDidClickCallback != null)
                    {
                        UPSDK.UPInterstitialDidClickCallback(placeId, msg);
                        fmsg = "UnityPlugin Run UPSDK.InterstitialDidClickCallback()";
                    }
                    else if (PolyADSDK.AvidlyInterstitialDidClickCallback != null)
                    {
                        PolyADSDK.AvidlyInterstitialDidClickCallback(placeId, msg);
                        fmsg = "UnityPlugin Run PolyADSDK.InterstitialDidClickCallback()";
                    }
                    if (isReportOnlineDebug)
                    {
                        adCall.reportILClick(placeId, fmsg);
                    }
                }
                //banner callback
                else if (function.Equals(Function_Banner_DidClick))
                {
                    if (UPSDK.UPBannerDidClickCallback != null)
                    {
                        UPSDK.UPBannerDidClickCallback(placeId, msg);
                    }
                    else if (PolyADSDK.AvidlyBannerDidClickCallback != null)
                    {
                        PolyADSDK.AvidlyBannerDidClickCallback(placeId, msg);
                    }
                }
                else if (function.Equals(Function_Banner_DidShow))
                {
                    if (UPSDK.UPBannerDidShowCallback != null)
                    {
                        UPSDK.UPBannerDidShowCallback(placeId, msg);
                    }
                    else if (PolyADSDK.AvidlyBannerDidShowCallback != null)
                    {
                        PolyADSDK.AvidlyBannerDidShowCallback(placeId, msg);
                    }
                }
                else if (function.Equals(Function_Banner_DidRemove))
                {
                    if (UPSDK.UPBannerDidRemoveCallback != null)
                    {
                        UPSDK.UPBannerDidRemoveCallback(placeId, msg);
                    }
                    else if (PolyADSDK.AvidlyBannerDidRemoveCallback != null)
                    {
                        PolyADSDK.AvidlyBannerDidRemoveCallback(placeId, msg);
                    }
                }
                //icon callback
                else if (function.Equals(Function_Icon_DidLoad))
                {
                    if (UPSDK.UPIconDidLoadCallback != null)
                    {
                        UPSDK.UPIconDidLoadCallback(placeId, msg);
                    }
                }
                else if (function.Equals(Function_Icon_DidLoadFail))
                {
                    if (UPSDK.UPIconDidLoadFailCallback != null)
                    {
                        UPSDK.UPIconDidLoadFailCallback(placeId, msg);
                    }
                }
                else if (function.Equals(Function_Icon_DidShow))
                {
                    if (UPSDK.UPIconDidShowCallback != null)
                    {
                        UPSDK.UPIconDidShowCallback(placeId, msg);
                    }
                }
                else if (function.Equals(Function_Icon_DidClick))
                {
                    if (UPSDK.UPIconDidClickCallback != null)
                    {
                        UPSDK.UPIconDidClickCallback(placeId, msg);
                    }
                }
                // exitad callback
                                #if UNITY_ANDROID && !UNITY_EDITOR
                else if (function.Equals(Function_ExitAd_DidShow))
                {
                    if (UPSDK.UPExitAdDidShowCallback != null)
                    {
                        UPSDK.UPExitAdDidShowCallback(msg);
                    }
                    else if (PolyADSDK.AvidlyExitAdDidShowCallback != null)
                    {
                        PolyADSDK.AvidlyExitAdDidShowCallback(msg);
                    }
                }
                else if (function.Equals(Function_ExitAd_DidCancel))
                {
                    if (UPSDK.UPExitAdOnCancelCallback != null)
                    {
                        UPSDK.UPExitAdOnCancelCallback(msg);
                    }
                    else if (PolyADSDK.AvidlyExitAdOnCancelCallback != null)
                    {
                        PolyADSDK.AvidlyExitAdOnCancelCallback(msg);
                    }
                }
                else if (function.Equals(Function_ExitAd_DidExit))
                {
                    if (UPSDK.UPExitAdOnExitCallback != null)
                    {
                        UPSDK.UPExitAdOnExitCallback(msg);
                    }
                    else if (PolyADSDK.AvidlyExitAdOnExitCallback != null)
                    {
                        PolyADSDK.AvidlyExitAdOnExitCallback(msg);
                    }
                }
                else if (function.Equals(Function_ExitAd_DidClick))
                {
                    if (UPSDK.UPExitAdDidClickCallback != null)
                    {
                        UPSDK.UPExitAdDidClickCallback(msg);
                    }
                    else if (PolyADSDK.AvidlyExitAdDidClickCallback != null)
                    {
                        PolyADSDK.AvidlyExitAdDidClickCallback(msg);
                    }
                }
                else if (function.Equals(Function_ExitAd_DidClickMore))
                {
                    if (UPSDK.UPExitAdDidClickMoreCallback != null)
                    {
                        UPSDK.UPExitAdDidClickMoreCallback(msg);
                    }
                    else if (PolyADSDK.AvidlyExitAdDidClickMoreCallback != null)
                    {
                        PolyADSDK.AvidlyExitAdDidClickMoreCallback(msg);
                    }
                }
                                #endif
                // check European User Callback
                else if (function.Equals(Function_User_Is_European_User))
                {
                    if (checkEuropeanUserCallback != null)
                    {
                        checkEuropeanUserCallback(true, msg);
                    }
                    checkEuropeanUserCallback = null;
                }
                else if (function.Equals(Function_User_IsNot_European_User))
                {
                    if (checkEuropeanUserCallback != null)
                    {
                        checkEuropeanUserCallback(false, msg);
                    }
                    checkEuropeanUserCallback = null;
                }
                // access privacy information callback
                else if (function.Equals(Function_Access_Privacy_Info_Accepted))
                {
                    if (accessPrivacyInformationCallback != null)
                    {
                        accessPrivacyInformationCallback(UPConstant.UPAccessPrivacyInfoStatusEnum.UPAccessPrivacyInfoStatusAccepted, msg);
                    }
                    accessPrivacyInformationCallback = null;
                }
                else if (function.Equals(Function_Access_Privacy_Info_Defined))
                {
                    if (accessPrivacyInformationCallback != null)
                    {
                        accessPrivacyInformationCallback(UPConstant.UPAccessPrivacyInfoStatusEnum.UPAccessPrivacyInfoStatusDefined, msg);
                    }
                    accessPrivacyInformationCallback = null;
                }
                else if (function.Equals(Function_Access_Privacy_Info_Failed))
                {
                    if (accessPrivacyInformationCallback != null)
                    {
                        accessPrivacyInformationCallback(UPConstant.UPAccessPrivacyInfoStatusEnum.UPAccessPrivacyInfoStatusFailed, msg);
                    }
                    accessPrivacyInformationCallback = null;
                }
                // load callback
                else if (function.Equals(Function_Reward_DidLoadFail))
                {
                    if (rewardVideoFailAction != null)
                    {
                        rewardVideoFailAction(placeId, msg);
                    }
                }
                else if (function.Equals(Function_Reward_DidLoadSuccess))
                {
                    if (rewardVideoSuccessAction != null)
                    {
                        rewardVideoSuccessAction(placeId, msg);
                    }
                }
                else if (function.Equals(Function_Interstitial_DidLoadFail))
                {
                    if (actionIntsFailMaps != null && placeId != null && actionIntsFailMaps.ContainsKey(placeId))
                    {
                        Action <string, String> action = (Action <string, String>)actionIntsFailMaps [placeId];
                        if (action != null)
                        {
                            action(placeId, msg);
                        }
                    }
                }
                else if (function.Equals(Function_Interstitial_DidLoadSuccess))
                {
                    if (actionIntsSuccessMaps != null && placeId != null && actionIntsSuccessMaps.ContainsKey(placeId))
                    {
                        Action <string, String> action = (Action <string, String>)actionIntsSuccessMaps [placeId];
                        if (action != null)
                        {
                            action(placeId, msg);
                        }
                    }
                }
                //unkown call
                else
                {
                    Debug.Log("unkown function:" + function);
                }
            }
        }