기타/오류모음

[Admob Error in IOS] Rewarded ad failed to load an ad with error

OfficialCaox 2023. 6. 3. 13:20

Rewarded ad failed to load an ad with error : Error Domain=com.google.admob Code=1 "Request Error: No ad to show." UserInfo={NSLocalizedDescription=Request Error: No ad to show., gad_response_info= ** Response Info **

Response ID: (null)

Network: (null)

 

** Loaded Adapter Response **

(null)

 

** Extras Dictionary **

{

}

 

** Mediation line items **

}

 

 

결론부터 말하면 나의 경우는 xcode에서 plist에서  Tracking Usage Description에 sstring을 추가해줬더니 정상적으로 작동했다.

 기기상에서 앱 추적이 꺼져있던 켜져있던, 저 옵션을 활성화해야 정상적으로 광고 시청이 가능해지는듯.

 

 

 

using UnityEditor;
using UnityEditor.Callbacks;
#if UNITY_IOS
using UnityEditor.iOS.Xcode;
#endif
using System.IO;

public class PostBuildStep
{
#if UNITY_IOS
    // IDFA 요청 설명을 설정합니다.
    const string k_TrackingDescription = "보다 뛰어난 맞춤형 광고 경험을 제공하기 위해 귀하의 데이터를 사용합니다.";

    [PostProcessBuild(0)]
    public static void OnPostProcessBuild(BuildTarget buildTarget, string pathToXcode)
    {
        if (buildTarget == BuildTarget.iOS)
        {
            AddPListValues(pathToXcode);
        }
    }

    // 값을 읽고 plist 파일에 쓰는 함수를 구현합니다.
    static void AddPListValues(string pathToXcode)
    {
        // Xcode 프로젝트 디렉토리에서 plist 파일을 가져옵니다.
        string plistPath = pathToXcode + "/Info.plist";
        PlistDocument plistObj = new PlistDocument();


        // plist 파일에서 값을 읽습니다.
        plistObj.ReadFromString(File.ReadAllText(plistPath));

        // 루트 오브젝트의 값을 설정합니다.
        PlistElementDict plistRoot = plistObj.root;

        // plist의 설명 키-값을 설정합니다.
        plistRoot.SetString("NSUserTrackingUsageDescription", k_TrackingDescription);

        // 변경 사항을 plist에 저장합니다.
        File.WriteAllText(plistPath, plistObj.WriteToString());
    }
#endif
}

+유니티에 위의 스크립트를 그대로 복사붙여넣기하면 자동으로 넣어준다.