Last active
July 19, 2021 06:49
-
-
Save baba-s/3836b7212b733ba5a58ecdbc8ba33486 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if UNITY_IOS | |
using System.Collections; | |
using Unity.Advertisement.IosSupport; | |
using UnityEngine; | |
using UnityEngine.iOS; | |
public sealed class Example : MonoBehaviour | |
{ | |
private IEnumerator Start() | |
{ | |
// まだ許可ダイアログを表示したことがない場合 | |
if ( ATTrackingStatusBinding.GetAuthorizationTrackingStatus() == | |
ATTrackingStatusBinding.AuthorizationTrackingStatus.NOT_DETERMINED ) | |
{ | |
// 許可ダイアログを表示します | |
ATTrackingStatusBinding.RequestAuthorizationTracking(); | |
// 許可ダイアログで「App にトラッキングしないように要求」か | |
// 「トラッキングを許可」のどちらかが選択されるまで待機します | |
while ( ATTrackingStatusBinding.GetAuthorizationTrackingStatus() == | |
ATTrackingStatusBinding.AuthorizationTrackingStatus.NOT_DETERMINED ) | |
{ | |
yield return null; | |
} | |
} | |
// IDFA(広告 ID)をログ出力します | |
// トラッキングが許可されている場合は IDFA が文字列で出力されます | |
// 許可されていない場合は「00000000-0000-0000-0000-000000000000」が出力されます | |
Debug.Log( Device.advertisingIdentifier ); | |
} | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment