로딩중입니다
[AOS] adbrix Facebook 广告设置 : Native Android、Unity Android
3/17/2016 12:04:45 PM

adbrix Facebook 广告设置 : Android、Unity Android


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


*注意事项

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

    - 使用此功能,SDK 版本需在如下; 
       a. Mobile App 启动广告(MAIA) : IgawCommon ver 4.2.0 以上
       b. Mobile App 参加广告(MAEA) : 
IgawCommon ver 4.2.1 以上


代码集成


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 时,参考如下内容。

  • Android

//添加跟踪 Facebook 的 API
IgawCommon.setDeferredLinkListener(this, new DeferredLinkListener() {
    @Override
    public void onReceiveDeeplink(String s) {
        try {
            Log.i("IGAWORKS", "Facebook Deeplink: " + s);
            Intent i = new Intent(Intent.ACTION_VIEW);
            i.addCategory(Intent.CATEGORY_BROWSABLE);
            i.setData(Uri.parse(s));
            MainActivity.this.startActivity(i);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
});


  • Unity Android

IgaworksUnityPluginAOS.Common.setDeferredLinkListener();
IgaworksUnityPluginAOS.OnReceiveDeferredLink = mOnReceiveDeferredLink;

 void mOnReceiveDeferredLink(string deeplink)
    {
        Debug.Log(string.Format("mOnReceiveDeferredLink deeplink: {0}", deeplink));
    }



#情况 2. 集成 FaceBook SDK 时

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

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


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

使用 Facebook SDK 的 FetchDeferredAppLinkData API 时,参考如下内容进行集成。

  • Android ( setReferralUrl API)

AppLinkData.fetchDeferredAppLinkData(MainActivity.this, new AppLinkData.CompletionHandler() {
    public void onDeferredAppLinkDataFetched(AppLinkData appLinkData) {
        if (appLinkData != null) {
            try {
                Bundle bundle = appLinkData.getArgumentBundle();
                // Get deeplink from ApplinkData
                String deeplink = bundle.getString(AppLinkData.ARGUMENTS_NATIVE_URL);
                // Report deeplink for IgawCommon to get tracking parameters
                //IgawCommon.setReferralUrl(MainActivity.this, deeplink);
                //4.2.5 版本开始 setReferralUrl 变更 setReferralUrlForFacebook。
                //IgawCommon.setReferralUrlForFacebook(MainActivity.this, deeplink);
                // Deeplinking
                Intent i = new Intent(Intent.ACTION_VIEW);
                i.addCategory(Intent.CATEGORY_BROWSABLE);
                i.setData(Uri.parse(deeplink));
                MainActivity.this.startActivity(i);
            } catch (Exception e) {
                e.printStackTrace();
            }
        } 
    }
});


  • Unity Android ( setReferralUrl API)

FB.Mobile.FetchDeferredAppLinkData(DeepLinkCallback);  
void DeepLinkCallback(IResult result)
{
    Debug.Log("DeepLinkCallback call ");
    if (result != null && !string.IsNullOrEmpty(result.RawResult))
    {
        try
        {
            Dictionary<string, object> jsonObjects = MiniJson.Deserialize(result.RawResult) as Dictionary<string, object>;
            string extras = (string)jsonObjects["extras"];
            Dictionary<string, object> extrasJSON = MiniJson.Deserialize(extras) as Dictionary<string, object>;
            string nativeURL = (string)extrasJSON["com.facebook.platform.APPLINK_NATIVE_URL"];                   
            // Report deeplink for IgawCommon to get tracking parameters
            // IgaworksUnityPluginAOS.Common.setReferralUrl(nativeURL);
            // setReferralUrl 变更 setReferralUrlForFacebook。
            IgaworksUnityPluginAOS.Common.setReferralUrlForFacebook(nativeURL);
} catch (Exception e) { Debug.Log("Error: " + e.Message); } } }


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

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




3. Facebook 广告设置和测试

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

详细内容参考如下

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