Example #1
0
    public void Start()
    {
        PlatformInterface.instance.logger.Log("PlatformAdMobAdsInit.Start()");

        // Initialize the Google Mobile Ads SDK.
        MobileAds.Initialize(status => { });

        var testDeviceList       = new List <string> {
            //"751709a03251817c6a3d7d3f7072ec57" // iPhone 6s
        };
        var requestConfiguration = new RequestConfiguration.Builder().SetTestDeviceIds(testDeviceList).build();

        MobileAds.SetRequestConfiguration(requestConfiguration);

        // 광고 사운드 끄기
        MobileAds.SetApplicationMuted(true);

        var adUnitId = PlatformInterface.instance.config.GetAdMobRewardVideoAdUnitId();

        // Get singleton reward based video ad reference.
        rewardBasedVideo = new RewardedAd(adUnitId);

        rewardBasedVideo.OnAdLoaded              += HandleOnAdLoaded;
        rewardBasedVideo.OnAdFailedToLoad        += HandleAdFailedToLoad;
        rewardBasedVideo.OnAdOpening             += HandleAdOpening;
        rewardBasedVideo.OnAdClosed              += HandleAdClosed;
        rewardBasedVideo.OnAdFailedToShow        += HandleAdFailedToShow;
        rewardBasedVideo.OnAdDidRecordImpression += HandleAdDidRecordImpression;
        rewardBasedVideo.OnUserEarnedReward      += HandleUserEarnedReward;
        rewardBasedVideo.OnPaidEvent             += HandlePaidEvent;

        RequestRewardBasedVideo();

#if UNITY_IOS
        var trackingStatus = ATTrackingStatusBinding.GetAuthorizationTrackingStatus();
        Debug.Log($"ATTrackingStatusBinding.GetAuthorizationTrackingStatus()={trackingStatus}");
        switch (trackingStatus)
        {
        case ATTrackingStatusBinding.AuthorizationTrackingStatus.NOT_DETERMINED:
            ATTrackingStatusBinding.RequestAuthorizationTracking();
            break;

        case ATTrackingStatusBinding.AuthorizationTrackingStatus.AUTHORIZED:
            AudienceNetwork.AdSettings.SetAdvertiserTrackingEnabled(true);
            break;

        case ATTrackingStatusBinding.AuthorizationTrackingStatus.RESTRICTED:
        case ATTrackingStatusBinding.AuthorizationTrackingStatus.DENIED:
            AudienceNetwork.AdSettings.SetAdvertiserTrackingEnabled(false);
            break;
        }
#endif
    }