[TIMOB-19626] Add FB Audience Network Support to Facebook Module
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | Low |
Status | Closed |
Resolution | Won't Fix |
Resolution Date | 2018-01-23T13:58:52.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | n/a |
Labels | ads, android, facebook, ios, module, titanium |
Reporter | Ghassan |
Assignee | Unknown |
Created | 2015-05-21T01:28:02.000+0000 |
Updated | 2018-08-02T22:20:02.000+0000 |
Description
Current Facebook Module missing support for FB Audience Network for iOS and Android as indicated on facebook at:
https://developers.facebook.com/docs/audience-network/getting-started#ads_sdk
Facebook iOS Banner Instructions: // Import the SDK header file and declare that you are implementing // the FBAdViewDelegate protocol: #import
Facebook iOS Interstitial: // Import the SDK header file and declare that you are implementing // the FBInterstitialAdDelegate protocol: #import
FB iOS Native Placement: // Import the SDK header file and declare that you are implementing // the FBNativeAdDelegate protocol: #import
FB Android Banner: // Edit your activity's layout XML file to include a // RelativeLayout to contain the AdView:
FB Android Interstitial: // Declare the InterstitialActivity in AndroidManifest.xml: //
FB Android Native Placement: // In the Activity that will launch the native ad, // implement the AdListener interface and add the following: import com.facebook.ads.*; private NativeAd nativeAd; private void showNativeAd(){ nativeAd = new NativeAd(this, "347360645445128_445223535658838"); nativeAd.setAdListener(new AdListener() { @Override public void onError(Ad ad, AdError error) { ... } @Override public void onAdLoaded(Ad ad) { ... } @Override public void onAdClicked(Ad ad) { ... } }); nativeAd.loadAd(); } // The next step is to extract the ad metadata and use its properties // to build your customized native UI. Modify the onAdLoaded function // above to retrieve the ad properties. For example: @Override public void onAdLoaded(Ad ad) { if (ad != nativeAd) { return; } String titleForAd = nativeAd.getAdTitle(); Image coverImage = nativeAd.getAdCoverImage(); Image iconForAd = nativeAd.getAdIcon(); String socialContextForAd = nativeAd.getAdSocialContext(); String titleForAdButton = nativeAd.getAdCallToAction(); String textForAdBody = nativeAd.getAdBody(); Rating appRatingForAd = nativeAd.getAdStarRating(); // Add code here to create a custom view that uses the ad properties // For example: LinearLayout nativeAdContainer = new LinearLayout(this); TextView titleLabel = new TextView(this); titleLabel.setText(titleForAd); nativeAdContainer.addView(titleLabel); ... // Add the ad to your layout LinearLayout mainContainer = (LinearLayout)findViewById(R.id.MainContainer); mainContainer.addView(nativeAdContainer); // Register the native ad view with the native ad instance nativeAd.registerViewForInteraction(nativeAdContainer); }
Is there any plan on implementing this? It would be a good thing to have the possibility to include other ad networks besides Admob.
Yes, we'd like to support this, but when is the real issue. This will have to move to after 7.0.0 SDK, so this will be the first for 7.1.0.
After checking some general requirements of this effort, I would recommend to *not* making it part of Ti.Facebook - simply because the .framework takes 60+ MB space and will blow up the app size even when not used. Instead, here is a simple implementation for Hyperloop using Cocoapods that does the same thing but only if you need it:
Add
pod 'FBAudienceNetwork'
to your PodfileImport the framework
Load the ad (taken as an example from [the official docs](https://developers.facebook.com/docs/audience-network/ios-interstitial))
Closing old "Won't fix" tickets. If you disagree, please reopen.