I have created a game for both iOS and Android.
I have successfully uploaded the game for Android and it works perfectly fine, game runs smoothly, ads and IAP working as it supposed to.
However, when I upload my game onto App Store, upon clicking the button that was supposed to show ads, the game crashed instantly. I have made certain adjustments but none have helped in solving the issue.
Things to note:
I am using Unity 2018.3.8f1 Personal
I am using XCode 11.2.1
I have imported Unity Monetization 3.3.0
I have turned off Ads in the services panel
These are my my configurations for UnityConnectSettings:
UnityAdsSettings:
m_Enabled: 0
m_InitializeOnStartup: 1
m_TestMode: 0
m_IosGameId: 3221231
m_AndroidGameId: 3221232
m_GameIds:
AndroidPlayer:
iPhonePlayer:
tvOSPlayer:
m_GameId:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Monetization;
public class AdsManager : MonoBehaviour
{
public bool finishads = false;
private string gameId = "3221231";
string video_ad = "video";
string rewarded_video_ad = "rewardedVideo";
private bool testMode = false;
// Start is called before the first frame update
void Start()
{
if (Application.platform == RuntimePlatform.IPhonePlayer)
gameId = "3221231";
else if (Application.platform == RuntimePlatform.Android)
gameId = "3221232";
Monetization.Initialize(gameId, false);
}
public void ShowAd()
{
StartCoroutine(WaitForAd());
}
public void ShowRewardedAd()
{
StartCoroutine(WaitForAd(true));
}
IEnumerator WaitForAd(bool reward = false)
{
string placementId = reward? rewarded_video_ad : video_ad;
while (!Monetization.IsReady(video_ad))
{
yield return null;
}
ShowAdPlacementContent ad = null;
ad = Monetization.GetPlacementContent(video_ad) as ShowAdPlacementContent;
if (ad != null)
{
if (reward)
ad.Show(AdFinished);
else
ad.Show();
}
}
void AdFinished(ShowResult result)
{
if (result == ShowResult.Finished)
{
finishads = true;
}
}
}
I believe there is nothing wrong with the codes as it works as it should on Android devices but these are the codes that I am using in the project.
One more thing to note, I am using Windows to build the iOS APK then transfer it over to a Macbook to build using XCode. When I build with XCode, I never change any of the settings and built normally.
Hope someone is able to help me solve this issue.
Thanks!