adbrix Facebook広告設定:iOS / Unity iOS
adbrixでFacebookアプリインストール(MAIA)とリエンゲージ(MAEA)広告を実施するための設定ガイドです。
*注意事項
- この機能を利用するためには、IGAW基本連携を完了してください。「IGAW基本連携:iOS」 「IGAW基本連携:Unity iOS」
- Facebookの計測機能を利用するためには IgaworksCore ver 2.2.2 以上を利用してください。
- この機能を利用するためにはIDFAを登録してください。「IGAW IDFAの登録:iOS」 「IGAW IDFAの登録:Unity iOS」
IgaworksCore 2.2.2では、Facebook SDKを同時に利用するケースに対する対応h方法を追加しました。
コードの連携
1. URL Scheme Pathの設定
Facebookの広告設定のためには、URL Scheme の設定が必要となります。「ディープリンク設定について」
アプリ内の特定ページにランディングできるpath値(Custom Quary)を設定してください。
* キャンペーンで計測するトラッキングURL発行の際に、Deep link Schemeとランディングページのpath値が必要となります。
2. URL情報の通知
ディープリンクを設定したFacebook広告からアプリが起動されると、ディープリンクのPath情報が渡されます。そのディープリンクのPathをSDKに渡します。
#Case1. Facebook SDKを連携していない場合
Facebook SDKを実装せず、IGAWorks SDKのみ利用するケースは以下のマニュアルのように連携してください。
- iOS
@interface AppDelegate () <IgaworksCoreDelegate>
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[IgaworksCore shared].delegate = self;
return YES;
}
#pragma mark - IgaworksCoreDelegate
//open url with deep link
- (void)didReceiveDeeplink:(NSString *)deepLink
{
if (deepLink.length > 0) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:deepLink]];
}
}
@interface AppDelegate () <IgaworksCoreDelegate>
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[IgaworksCore shared].delegate = self;
return YES;
}
#pragma mark - IgaworksCoreDelegate
//open url with deep link
- (void)didReceiveDeeplink:(NSString *)deepLink
{
if (deepLink.length > 0) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:deepLink]];
}
}
- Unity
public class IgaworksSample : MonoBehaviour
{
void Start ()
{
IgaworksCorePluginIOS.SetIgaworksCoreDelegate();
}
void Awake()
{
// add handle deep link event
IgaworksCorePluginIOS.didReceiveDeeplink += HandleDidReceiveDeeplink;
}
void OnDisable()
{
IgaworksCorePluginIOS.didReceiveDeeplink -= HandleDidReceiveDeeplink;
}
// handle deep link event
public void HandleDidReceiveDeeplink(string deepLink)
{
Debug.Log ("IgaworksSample : HandleDidReceiveDeeplink " + deepLink);
// url open
}
}
public class IgaworksSample : MonoBehaviour
{
void Start ()
{
IgaworksCorePluginIOS.SetIgaworksCoreDelegate();
}
void Awake()
{
// add handle deep link event
IgaworksCorePluginIOS.didReceiveDeeplink += HandleDidReceiveDeeplink;
}
void OnDisable()
{
IgaworksCorePluginIOS.didReceiveDeeplink -= HandleDidReceiveDeeplink;
}
// handle deep link event
public void HandleDidReceiveDeeplink(string deepLink)
{
Debug.Log ("IgaworksSample : HandleDidReceiveDeeplink " + deepLink);
// url open
}
}
#Case2. Facebook SDKを連携した場合
Facebook SDKの FetchDeferredAppLinkData APIの使用可否によって2つのケースがございます。各ケースを確認して連携してください。
* 下記のマニュアルは Core2.2.2 以上に対応しています。【SDKダウンロード】
#case2-1. Facebook SDKのFetchDeferredAppLinkData APIを使用する場合
Facebook SDKのFetchDeferredAppLinkData APIを使用する場合、下記のマニュアルで連携してください。
- iOS ( setReferralUrl API )
@interface AppDelegate () <IgaworksCoreDelegate>
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[IgaworksCore shared].delegate = self;
if (launchOptions[UIApplicationLaunchOptionsURLKey] == nil) {
[FBSDKAppLinkUtility fetchDeferredAppLink:^(NSURL *url, NSError *error) {
if (error) {
NSLog(@"Received error while fetching deferred app link %@", error);
}
if (url) {
NSLog(@"Facebook SDK: Received fetching deferred app link %@", url);
[IgaworksCore setReferralUrl:url];
// open the app with deeplink url
[[UIApplication sharedApplication] openURL:url];
}
}];
}
return YES;
}
#pragma mark - IgaworksCoreDelegate
//open url with deep link
- (void)didReceiveDeeplink:(NSString *)deepLink
{
NSLog(@"Received deeplink url %@", deepLink);
}
@interface AppDelegate () <IgaworksCoreDelegate>
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[IgaworksCore shared].delegate = self;
if (launchOptions[UIApplicationLaunchOptionsURLKey] == nil) {
[FBSDKAppLinkUtility fetchDeferredAppLink:^(NSURL *url, NSError *error) {
if (error) {
NSLog(@"Received error while fetching deferred app link %@", error);
}
if (url) {
NSLog(@"Facebook SDK: Received fetching deferred app link %@", url);
[IgaworksCore setReferralUrl:url];
// open the app with deeplink url
[[UIApplication sharedApplication] openURL:url];
}
}];
}
return YES;
}
#pragma mark - IgaworksCoreDelegate
//open url with deep link
- (void)didReceiveDeeplink:(NSString *)deepLink
{
NSLog(@"Received deeplink url %@", deepLink);
}
- Unity ( SetReferralUrl API )
FB.Mobile.FetchDeferredAppLinkData(DeepLinkCallback);
void DeepLinkCallback(IAppLinkResult result)
{
if (!String.IsNullOrEmpty(result.Url))
{
IgaworksCorePluginIOS.SetReferralUrl(result.Url);
}
}
case2-2. Facebook SDKのFetchDeferredAppLinkData APIを使用しない場合
FB.Mobile.FetchDeferredAppLinkData(DeepLinkCallback);
void DeepLinkCallback(IAppLinkResult result)
{
if (!String.IsNullOrEmpty(result.Url))
{
IgaworksCorePluginIOS.SetReferralUrl(result.Url);
}
}
Facebook SDKのFetchDeferredAppLinkData APIを使用しない場合は、#Case1のマニュアルで連携してください。
3. Facebookキャンペーンの設定及びテストFacebook広告設定のための設定及びテストに関しては、以下のマニュアルをご確認ください。
「adbrix : Facebookのアプリキャンペーンの設定」