Unity/GoogleMobileAds/SKAdNetworkのソースを表示
←
Unity/GoogleMobileAds/SKAdNetwork
ナビゲーションに移動
検索に移動
あなたには「このページの編集」を行う権限がありません。理由は以下の通りです:
この操作は、次のグループに属する利用者のみが実行できます:
登録利用者
。
このページのソースの閲覧やコピーができます。
==SKAdNetworkとは== ios14のidfa対応するために、使えば良いじゃんとadmobに推奨されてるライブラリ ==admobからios14対応時に推奨されてるお知らせ== <pre> To help you prepare for these changes and improve iOS monetization rates, Google recommends that you take the following actions as soon as possible: 1. Install the latest Google Mobile Ads SDK for iOS (for AdMob or Ad Manager). Versions 7.64 or later include critical features for iOS 14 compatibility. 2. Configure SKAdNetwork with Google’s network identifier. Advertisers will be using Apple’s SKAdNetwork API to measure the value they get from your app, so doing so is the best way to get credit for your app’s ads performance. Learn more about configuring SKAdNetwork for mobile and video. 3. Review Apple’s ATT consent prompt and determine if implementing is right for your app. Conducting a limited user experiment (via server configuration) can help you understand what implementation works best for your users. Google’s Funding Choices user messaging is an option you may want to evaluate for creating and managing the ATT prompt & explainer messaging. Learn more about configuring Funding Choices IDFA messages. </pre> ==unityのadmobライブラリ== https://github.com/googleads/googleads-mobile-unity/releases Google Mobile Ads Unity Plugin v5.4.0 であれば、 Google Mobile Ads iOS SDK 7.68.0 となっていて、7.64より上なので、Google Mobile Ads Unity Plugin 5.4.0を入れておけば良い。 ==unityのadmobライブラリでSKAdNetwork対応方法== iosをビルドすると Info.plistに以下が出力される <pre> <key>SKAdNetworkItems</key> <array> <dict> <key>SKAdNetworkIdentifier</key> <string>cstr6suwn9.skadnetwork</string> </dict> </array> </pre> SKAdNetworkIdentifierの値は、以下ページにある値と同じか、確認しておく。 https://developers.google.com/admob/ios/ios14?hl=ja ==App Tracking Transparency で許可をリクエストする== Info.plistに以下を追加 <pre> <key>NSUserTrackingUsageDescription</key> <string>This identifier will be used to deliver personalized ads to you.</string> </pre> ===自動反映する場合=== Assets/Editor/PostBuildProcessForIosAtt.cs <pre> #if UNITY_IOS using System.IO; using UnityEditor.iOS.Xcode; using UnityEditor; using UnityEditor.Callbacks; namespace iOS.Editor { public class PostBuildProcessForIosAtt { private const string ATT_FRAMEWORK = "AppTrackingTransparency.framework"; [PostProcessBuild] public static void OnPostProcessBuild(BuildTarget buildTarget, string buildPath) { if (buildTarget != BuildTarget.iOS) { return; } var pbxPath = PBXProject.GetPBXProjectPath(buildPath); var pbx = new PBXProject(); pbx.ReadFromFile(pbxPath); string target = GetUnityMainTargetGuidWithCompatible(pbx); pbx.AddFrameworkToProject(target, ATT_FRAMEWORK, true); pbx.WriteToFile(pbxPath); var path = buildPath + "/Info.plist"; var plist = new PlistDocument(); plist.ReadFromFile(path); var root = plist.root; root.SetString("NSUserTrackingUsageDescription", "本アプリは、広告効果の測定や分析などのためにIDFA(広告識別子)を利用します。"); plist.WriteToFile(path); } private static string GetUnityMainTargetGuidWithCompatible(PBXProject pbx) { #if UNITY_2019_3_OR_NEWER return pbx.GetUnityFrameworkTargetGuid(); #else return pbx.TargetGuidByName(PBXProject.GetUnityTargetName()); #endif } } } #endif </pre> 上記を設置して、iosをビルドすれば良い。 ===unityからのリクエスト方法=== Assets/Plugins/iOS/AttObjC.mm <pre> #import <AppTrackingTransparency/AppTrackingTransparency.h> #import <AdSupport/AdSupport.h> #ifdef __cplusplus extern "C" { #endif int Sge_Att_getTrackingAuthorizationStatus() { if (@available(iOS 14, *)) { return (int)ATTrackingManager.trackingAuthorizationStatus; } else { return -1; } } typedef void (*Callback)(int status); void Sge_Att_requestTrackingAuthorization(Callback callback) { if (@available(iOS 14, *)) { [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) { if (callback != nil) { if (status == ATTrackingManagerAuthorizationStatusNotDetermined) { NSLog(@"ATT status = NotDetermined(未設定) -> 端末設定でOK、アプリで未選択"); } else if (status == ATTrackingManagerAuthorizationStatusRestricted) { NSLog(@"ATT status = Restricted(制限あり)"); } else if (status == ATTrackingManagerAuthorizationStatusDenied) { NSLog(@"ATT status = Denied(不許可) -> 端末設定orアプリで不許可"); } else if (status == ATTrackingManagerAuthorizationStatusAuthorized) { NSLog(@"ATT status = Authorized(許可)"); } else { NSLog(@"ATT status = Other(その他)"); } callback((int)status); } }]; } else { NSLog(@"ATT status = iOS14 未満(非対応)"); callback(-1); } } #ifdef __cplusplus } #endif </pre> Assets/Scripts/AttObjC.cs <pre> using System; // for Action using System.Runtime.InteropServices; // for DllImport using System.Threading; // for SynchronizationContext using UnityEngine; // for Application public class AttObjC { #if UNITY_IOS private const string DLL_NAME = "__Internal"; [DllImport(DLL_NAME)] private static extern int Sge_Att_getTrackingAuthorizationStatus(); public static int GetTrackingAuthorizationStatus() { if (Application.isEditor) { return -1; } return Sge_Att_getTrackingAuthorizationStatus(); } [DllImport(DLL_NAME)] private static extern void Sge_Att_requestTrackingAuthorization(OnCompleteCallback callback); private delegate void OnCompleteCallback(int status); private static SynchronizationContext _context; private static Action _onComplete; public static void RequestTrackingAuthorization() { if (Application.isEditor) { return; } #if UNITY_IOS _context = SynchronizationContext.Current; Sge_Att_requestTrackingAuthorization(OnRequestComplete); #endif } [AOT.MonoPInvokeCallback(typeof(OnCompleteCallback))] private static void OnRequestComplete(int status) { if (_onComplete != null) { _context.Post(_ => { _onComplete = null; }, null); } } #endif } </pre> Assets/Scripts/AttStartup.cs <pre> using System.Collections; using System.Collections.Generic; using UnityEngine; public class AttStartup { public static void Exec() { #if UNITY_IPHONE int status = AttObjC.GetTrackingAuthorizationStatus(); if (status == 0) { AttObjC.RequestTrackingAuthorization(); } #endif } void CallbackFunction(int status) { Debug.Log("ATT状況:" + status); } } </pre> MainScene.cs(起動時のStartなどから実行) <pre> void Start() { #if UNITY_IPHONE AttStartup.Exec(); // att #endif } </pre> 参考:https://creator.game.cyberagent.co.jp/?p=7382 ====Use of undeclared identifier 'ATTrackingManager'エラーが出る==== 以下2箇所のコードで"Use of undeclared identifier 'ATTrackingManager'"がエラーが出る場合 return (int)ATTrackingManager.trackingAuthorizationStatus; [ATTrackingManager mmファイルにimport追加すればよい。 #import <AppTrackingTransparency/AppTrackingTransparency.h> #import <AdSupport/AdSupport.h> ==iOSで説明文を多言語化する方法== アプリ名の変更と同じようなやり方でできる。 xcode側で、InfoPlist.stringsを作成し、localeをenglishで設定し、以下を追加する InfoPlist.strings(English) <pre> NSUserTrackingUsageDescription = "Allowing tracking makes it easier for you to see relevant ads. Access to personal information by this I don't."; </pre> 物理ファイル:en.lproj/InfoPlist.strings InfoPlist.strings(Japanese) <pre> NSUserTrackingUsageDescription = "追跡(トラッキング)を許可すると、関連性が高い広告が表示されやすくなります。これによる個人情報へのアクセスはありません。"; </pre> 物理ファイル:Japanese.lproj/InfoPlist.strings 参考:https://i-app-tec.com/ios/localization.html ==説明ダイアログを挟んでも大丈夫っぽい== https://twitter.com/Kumanbow/status/1364787562951233536 https://twitter.com/masaseat/status/1357387154658271233 ==参考== https://qiita.com/bosteri_bon/items/36233fdbc478d7e74cc9 http://blog.be-style.jpn.com/article/188329627.html
Unity/GoogleMobileAds/SKAdNetwork
に戻る。
ナビゲーション メニュー
個人用ツール
ログイン
名前空間
ページ
議論
日本語
表示
閲覧
ソースを閲覧
履歴表示
その他
検索
案内
プログラムメモ
php
flutter
java
android
kotlin
ios
unity
unrealengine
javascript
mysql
sqlite
postgresql
oracle
mroonga
mongodb
flash
electron
cocos2dx
titanium
cpp
ruby
perl
python
accessメモ
rss
html
monaca
cordova
golang
blender
セキュリティ
テストツール
サーバメモ
linux
dotnet
apacheメモ
htaccessメモ
subversion
git
仮想サーバ
ansible
sendgrid
xampp
cacti
mecab
faces
flashpolicyd
fcs
jenkins
運用
デザインメモ
css
ユーザビリティ
ux
サービスメモ
twitter
facebook
instagram
mixi
セカンドライフ
通信ログ横取り
google
ustream
aws
gcp
plesk
azure
vps
AI
その他サービス
便利系メモ
SEO
モバイル
抽象変数名
DDD
クライアント
firefox
chrome
pgp
windows
mac
jmetar
Thunderbird
excel
libreoffice
vpnclient
doxygen
VisualStudioCode
fastlane
metaquest
cmsメモ
mediawiki
pukiwiki
wordpress
その他
資格
IT用語
pvを稼ぐ方法
将棋プログラム
その他
ログイン
ページ内
メインページ
最近の更新
人気のページ
問い合わせ
ツール
リンク元
関連ページの更新状況
ページ情報