Implementing Facebook Native Ads

Hello,

We will have to implement Facebook Native Ads in our new app. Facebook Native Ads require platform native views. You target a UIView and a UIViewController as a delegate and Facebook SDK handles the rest from showing the ad to handling clicks. I guess this means we need to use a native theme to integrate FB Native Ads, right? Or do you think it’s possible to implement by the help of NativeViewHost and some Uno code? If so, what about the UIViewController delegate?

Thanks in advance.

Hi!

We are currently working on the feature to make it easy to host thirdparty nativeviews like this. I dont have any solid ETA for it, but its a very high priority feature.

In your case this will need to be implemented from Uno and the code will looke something like this:

public class FacebookNativeAd : Fuse.Controls.Panel { }

namespace Facebook.Ads.iOS
{
    // Pseudo code based on the upcoming native viewhost feature
    extern(iOS) class Ad : UIView
    {
        public Ad() : base(Create()) { }

        [Foreign(Language.ObjC)]
        static ObjC.Object Create()
        @{
            return [[FacebookAdView alloc] init];
        @}
    }

    extern(iOS) public class AdViewHost : Fuse.iOS.ViewHost<FacebookNativeAd>
    {
        Ad _ad;
        protected override UIView Create()
        {
            return _ad ?? (_ad = new Ad());
        }
    }
}

Please let me know if you have any feedback on the code above.

Hi!

Nice to know that this feature will be implemented. I hope it gets released in a few weeks :slight_smile:

Thanks for the help.