로딩중입니다
[iOS] adbrix Facebook 广告设置 : Native iOS、Unity iOS
3/17/2016 12:19:15 PM

adbrix Facebook 广告设置 : iOS、Unity iOS


此文档是在 adbrix 中设置 Facebook Mobile App 启动(MAIA)、Mobile App 参加(MAEA) 广告 的集成指南。


*注意事项

    - 为了使用此功能,必须先完成 IGAW 共同事项。 [IGAW 共同集成 : iOS] [IGAW 共同集成 : Unity iOS]

    - 为了使用 Facebook 广告跟踪功能,SDK 版本需在 IgaworksCore ver 2.2.2 以上。

    - 为了使用此功能,需要登录 IDFA 内容。[IGAW Apple IDFA 登录 : iOS] [IGAW Apple IDFA 登录 : Unity iOS] 

     * 更新内容 *
     在 IgaworksCore 2.2.2 版本上添加同时使用 Facebook SDK 的接入方式。



代码集成


1. 设置 DeepLink

为了跟踪 Facebook 广告,需在应用内设置 DeepLink。[How to set Deeplink?]

需设置可以达到应用内指定页面的 Path 值。(Custom Query)

 * 在 adbrix 中创建跟踪链接时,需要 DeepLink Scheme 和跳转页面的 Path 值。



2. 接收 DeepLink 信息

通过设置了 DeepLink 的 Facebook 广告打开应用时,传达 DeepLink 的 Path 信息。已收到的 Path 信息再传达 SDK。


#情况 1. 不集成 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]];
    }
}


  • Unity iOS

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
	}

}



#情况 2. 集成 FaceBook SDK 时

根据 Facebook SDK 里 FetchDeferredAppLinkData API 的使用与否,提供 2种指南。选择对应的内容进行集成。

* 为了集成以下功能,必须集成 Core2.2.2  版本以上。[转移至下载页面]


情况 2-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);
}


  • Unity iOS ( SetReferralUrl API )

FB.Mobile.FetchDeferredAppLinkData(DeepLinkCallback);

void DeepLinkCallback(IAppLinkResult result)
{
    if (!String.IsNullOrEmpty(result.Url))
    {
        IgaworksCorePluginIOS.SetReferralUrl(result.Url);
    }    
}



情况 2-2. 不使用 FaceBook SDK 的 FetchDeferredAppLinkData API 时

不使用 Facebook SDK 的 FetchDeferredAppLinkData API 时,参考上述提到的 #情况1 指南。




3. Facebook 广告设置和测试

为了进行 Facebook 广告,请参考 adbrix 跟踪链接生成方法、Facebook 广告设置和测试方式。

详细内容参考如下

[监测广告效果 : Facebook App Install Campaign]