Beginning with FB SDK v4.34 for iOS and Android, Hybrid Mobile App Events are available. This feature provides a way for developers to use App Events for a native Android or iOS web app by converting Facebook Pixel events into App Events. With App Events you get more reliable optimization, more detailed integration with Facebook Analytics, the benefits of retry, batching, and other native Facebook SDK persistence assurances.
When you augment a webview from iOS or Android, we inject a window level object called
fbmq_<YOUR_APP_ID>. The Pixel, when set up to look for a mobile bridge, finds this window level
fbmq object each time an
fbq call is made. If the
fbmq object is found, the Pixel issues a call to a method on this object. This in turn triggers a native iOS or Android callback where we fire an SDK
Update the Facebook Pixel code within the application web container to reference your Facebook App ID. This sends an event to the Pixel that you would like to send App Events instead of Pixel Events.
fbq('init', <YOUR_PIXEL_ID>); fbq('set', 'mobileBridge', <YOUR_PIXEL_ID>, <YOUR_APP_ID>);
Update your native app with a call to augment your webview.
augmentWebView adds a new Android
AppEvents using the specified context.
For technical reasons, we only support WebView on Android 4.2 and higher.
For technical reasons, we only support WKWebView on iOS 8.0 and higher.
After your code changes log Pixel Events as usual. We will intercept these events and send them as native App Events instead of Pixel Events.
Visit our App Events Guide to learn more.