블로그 이미지
Every unexpected event is a path to learning for you.

카테고리

분류 전체보기 (2737)
Unity3D (817)
Programming (474)
Server (33)
Unreal (4)
Gamebryo (56)
Tip & Tech (228)
협업 (58)
3DS Max (3)
Game (12)
Utility (136)
Etc (96)
Link (32)
Portfolio (19)
Subject (90)
iOS,OSX (53)
Android (14)
Linux (5)
잉여 프로젝트 (2)
게임이야기 (3)
Memories (20)
Interest (38)
Thinking (38)
한글 (30)
PaperCraft (5)
Animation (408)
Wallpaper (2)
재테크 (18)
Exercise (3)
나만의 맛집 (3)
냥이 (10)
육아 (16)
Total
Today
Yesterday
04-19 00:04

​With Apple’s incoming changes to the requirements for use of IDFA and needing to request users permission via App Tracking Transparency popup which is incoming at some point in early 2021. Apps need to start to prepare to the incoming changes.

​So how do you add a IDFA App Tracking Transparency popup from a Unity app?

At the moment there is no build in Unity method that will trigger the notification, There is however a preview package!

​As a note App Tracking Transparency is only required on IOS 14 devices, Altough this won’t causing issues on any lower OS version it won’t trigger the popup. If you don’t have access to a IOS 14 device you can test this with the XCode Emulators.​

1. Download Unity IOS Support Package

​Download the com.unity.ads.ios.support library from Github. This is current in preview and won’t be found directly from the package manager.

Unzip this into a folder outside your Asset Folder.

​Note it is best to make sure these files are checking into source control we will be using a relative path from Unity package manager.​

2. Add to Package Manager

​Now in you’re unity project go Windows->Package Manger.

​​

Then press the plus button and add from disk and navigate to the package.json file within the com.unity.ads.ios.support that we just unzipped.

​​

Unity will then import the package, Because we have imported the file from within the base Unity Project file the file has been direct to a relative path, if you however place this file outside this folder you will need to edit the Packages/manifest.json file to make it relative.

​​

​​

3. Triggering App Tracking Transparency Request

​As most SDK recommend We will need to trigger this before we initialize any SDK’s that we wish to pass the IDFA into. We also can only trigger this one pre install with users being able to edit there preference within the IOS Settings menu.​​Here we are using a really simple system where we trigger the notification when a user press a button.

Breaking down

​We first state we are using the IosSupport Library. We also inclosing this with a UNITY_IOS pre-compile which means we will only compile this code if we are running on IOS

#if UNITY_IOS using Unity.Advertisement.IosSupport; #endif

Next the actual triggering, again inclosing this with the UNITY_IOS pre-compile. We first check call ATTrackingStatusBinding.GetAuthorizationTrackingStatus() which will tell if the user has already set there preference, then ATTrackingStatusBinding.RequestAuthorizationTracking() Which will trigger the popup.

#if UNITY_IOS if(ATTrackingStatusBinding.GetAuthorizationTrackingStatus() == ATTrackingStatusBinding.AuthorizationTrackingStatus.NOT_DETERMINED) { ATTrackingStatusBinding.RequestAuthorizationTracking(); } #endif

4. Post build steps

​Like any other permission request Apple requires a description on why you are requesting these permission. For this we need to add the NSUserTrackingUsageDescription key to our PList. Instead of having to do this each time we create a build we are going to create a post build step that automatically adds it to the XCode Project

​You can see more about Unity post build steps here

using UnityEditor;
using UnityEditor.Callbacks;
#if UNITY_IOS
using UnityEditor.iOS.Xcode;
#endif
using System.IO;
 
public class PostBuildStep
{
/// <summary>
/// Description for IDFA request notification
/// [sets NSUserTrackingUsageDescription]
/// </summary>
const string TrackingDescription =
"This identifier will be used to deliver personalized ads to you. ";
 
[PostProcessBuild(0)]
public static void OnPostprocessBuild(BuildTarget buildTarget, string pathToXcode)
{
if (buildTarget == BuildTarget.iOS)
{
AddPListValues(pathToXcode);
}
}
 
static void AddPListValues(string pathToXcode)
{
// Get Plist from Xcode project
string plistPath = pathToXcode + "/Info.plist";
 
// Read in Plist
PlistDocument plistObj = new PlistDocument();
plistObj.ReadFromString(File.ReadAllText(plistPath));
 
// set values from the root obj
PlistElementDict plistRoot = plistObj.root;
 
// Set value in plist
plistRoot.SetString("NSUserTrackingUsageDescription", TrackingDescription);
 
// save
File.WriteAllText(plistPath, plistObj.WriteToString());
}
 
}

view rawPostBuild.cs hosted with ❤ by GitHub

​Here we just read in the PlistFile from the Xcode project we just created, then add in a new string values​plistRoot.SetString(“NSUserTrackingUsageDescription”, TrackingDescription);​Which sets the our popup text.​​

4. Testing it out

​Build the App to Xcode as normal and open it up in Xcode. If you open up the Info.Plist you will see the description we just added in from the post build step

​​​​

Now we can just build and play on our device. Then just press the button and you should see the IDFA Popup!

​​​​​

​​​​

​You will notice that if you press the button again it won’t re-trigger this is by the apple requirements so we will need to uninstall and pre-install to test it again.​

​This is the basic implementation ahead of the requirement of App Tracking Transparency for IOS, for a production version it may be best to pre-warn users about the popup, explaining why you are wanting to use the IDFA. This will likely improve the number of user who opt-in​

If any problems feel free to drop me a line on Twitter @Gamereat.

 

 

[출처] alanyeats.com/post/unityapptrackingtransparencypopup/

 

App Tracking Transparency in Unity (IDFA Popup) | Alan Yeats | Pocket Sized Hands Co-Founder | VR / AR Developer

​ With Apple’s incoming changes to the requirements for use of IDFA and needing to request users permission via App Tracking Transparency popup which is incoming at some point in early 2021. Apps need to start to prepare to the incoming changes. ​ So

alanyeats.com

 

반응형
Posted by blueasa
, |

[iOS14+ 대응 관련 FAN SDK 6.2 적용 시 구현 이슈 2가지]

Audience Network SDK(6.2) 최신 버전은 10월 26일에 릴리스되었습니다. 최신 버전에서 강조할 만한 중요한 요구 사항은 두 가지가 있습니다.

 

1. 미디에이션 사용과 무관하게 ‘setAdvertiserTrackingEnabled’ 플래그를 구현하여 데이터로 개인화된 광고를 게재하는지 알려야 합니다.

2.  추천된 SKAdNetwork ID를 Xcode 프로젝트의 Info.plist에 추가하여 광고주가 광고 캠페인의 성공을 측정하도록 합니다.


iOS14에 대응하기 위해 AN SDK 6.2 이상을 적용해야 되는데, iOS에서 FAN SDK 6.2는 위와 같은 2가지 필수 구현사항을 요구하고 있다.

 

현재 나는 Admob 미디에이션을 사용하고, Admob의 FAN 미디에이션 플러그인을 적용해놨는데,

미디에이션이라 하더라도 위 2가지는 적용해야 된다고 한다.

 

위 2가지를 어떻게 적용했는지 정리해 둔다.

 

(※ iOS 플랫폼 대응이니 Android에서는 작동 안하도록 해두자)

1.   ‘setAdvertiserTrackingEnabled’ (이하 ATE) flag 구현

1.1. 광고 추적 활성화

1.1.1. 미디에이션 미 사용 시(AN SDK 직접 적용)

     [링크] developers.facebook.com/docs/audience-network/guides/advertising-tracking-enabled

1.1.2. 미디에이션 사용 시

1.1.2.1. 미디에이션 사용 시에는 아래와 같이 직접 구현해서 사용하라고 설명이 적혀 있다.

          [참조] 미디에이션을 사용 중인 경우 setAdvertiserTrackingEnabled 플래그를 구현한 다음, 미디에이션 SDK를 초기화해야 Facebook에서 입찰 요청을 통해 이를 수신할 수 있습니다.

          ※ 나는 Unity를 사용하고, Admob 미디에이션(GoogleMobileAds)을 사용하기 때문에 유니티에 적용할 수 있는 방식으로 직접 구현이 필요하다.

1.1.2.2. (직접 구현하는 건 귀찮으니)아래 파일을 다운받고, 패키지를 실행해서 AdSettings.cs 파일만 프로젝트에 추가

          [다운로드] Audience Network SDK for Unity

1.1.2.3. Admob 제어 하는 곳에서 Admob 초기화 전에 아래 소스를 추가해서 셋팅해 주자.

         (1.1.2.2.의 파일을 추가하면 아래 소스 실행이 가능해진다.)

// iOS에서만 실행하도록 한다.
#if UNITY_IPHONE && !UNITY_EDITOR
// Set the flag as true 
AudienceNetwork.AdSettings.SetAdvertiserTrackingEnabled(true);
#endif

 

2.   SKAdNetwork IDs Xcode 프로젝트의 Info.plist 추가

2.1. SKAdNetwork ID를 발급받는다.

     [참조 링크] www.wisetracker.co.kr/wp-content/uploads/2020/09/iOS_14_update_guide.pdf

2.2. ID를 Inpo.plist에 추가한다. (아래 보이는 ID는 예시입니다.)

2.2.1. Inpo.Plist에 직접 추가하는 방법(developer.apple.com/documentation/storekit/skadnetwork/configuring_the_participating_apps)

 

※ 아래 2개 SKAdNetworkID는 페이스북 공용 ID이니, FAN을 붙이는거면 그대로 사용하면 된다.

    [참조링크] developers.facebook.com/docs/audience-network/guides/SKAdNetwork

<key>SKAdNetworkItems</key>
<array>
    <dict>
        <key>SKAdNetworkIdentifier</key>
        <string>v9wttpbfk9.skadnetwork</string>
    </dict>
    <dict>   
         <key>SKAdNetworkIdentifier</key>
         <string>n38lu8286q.skadnetwork</string>
    </dict>
</array>

 

2.2.2. Unity에서 PostProcessor로 추가하는 방법(추천)

namespace blueasa
{
    public class XcodeSettingsPostProcessor
    {

        [PostProcessBuild(444)]
        public static void OnPostprocessBuild(BuildTarget buildTarget, string pathToBuiltProject)
        {

            /// Stop processing if targe is NOT iOS
            if (buildTarget != BuildTarget.iOS)
                return;

            /// Initialize PbxProject
            var projectPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj";
            PBXProject pbxProject = new PBXProject();
            pbxProject.ReadFromFile(projectPath);
            string targetGuid = pbxProject.TargetGuidByName("Unity-iPhone");

            /// Add string setting
            // SKAdNetwork IDs integration(for iOS14+)
            // https://blueasa.tistory.com/2482
            // https://blueasa.tistory.com/2493
            var arraySKAdNetworkItems = plist.root.CreateArray("SKAdNetworkItems");
            // for FAN
            // https://developers.facebook.com/docs/audience-network/guides/SKAdNetwork
            var dictSKAdNetworkIdentifier_FAN_1 = arraySKAdNetworkItems.AddDict();
            dictSKAdNetworkIdentifier_FAN_1.SetString("SKAdNetworkIdentifier", "v9wttpbfk9.skadnetwork"); // FAN 1
            var dictSKAdNetworkIdentifier_FAN_2 = arraySKAdNetworkItems.AddDict();
            dictSKAdNetworkIdentifier_FAN_2.SetString("SKAdNetworkIdentifier", "n38lu8286q.skadnetwork"); // FAN 2
            
            /// Apply editing settings to Info.plist
            plist.WriteToFile(plistPath);

        }
    }
}

 

 

[참조사이트]

developers.facebook.com/blog/post/2020/10/29/preparing-our-partners-ios-14-latest-guidance-on-skadnetwork/?locale=ko_KR

developers.google.com/admob/ios/mediation/facebook?hl=en#swift

 

[SKAdNetwork IDs 참조]

[Admob] developers.google.com/admob/ios/ios14#skadnetwork

[Unity] unityads.unity3d.com/help/ios/skadnetwork-ids?fbclid=IwAR3T6BWG6-SIdWipZaB-PEtUQhg1DAnU_kQ22iiSv4Z5Q6nItq2edtpIIkM

[Unity.xml] skan.mz.unity3d.com/v2/partner/skadnetworks.plist.xml?_ga=2.140049011.1591405619.1607905486-1813266944.1603773122

[Vungle] support.vungle.com/hc/en-us/articles/360002925791-Integrate-Vungle-SDK-for-iOS#3-add-the-%E2%80%9C-objc%E2%80%9D-linker-flag-0-9

[Vungle.xml] vungle.com/skadnetworkids.xml

[AppsFlyer 제공 리스트] docs.google.com/spreadsheets/d/e/2PACX-1vSqwIBW3FzbrXKqluDQ2hEec7zcvVrxQ02ivWsHnGQTvLMeFmHHjGz1R5TVy6_cqAIVh0pAy4Yud7Qx/pubhtml

반응형
Posted by blueasa
, |