Customizing in app browser - adform/adform-ios-sdk GitHub Wiki
It is possible to customize the in-app browser used by the SDK to open banner clicks. You can do so by adopting ad view delegate protocols AFAdInlineDelegate
, AFAdOverlayDelegate
, AFVideoPlayerDelegate
and implementing appropriate ... willOpenSafariViewController:
and ... willOpenInternalBrowser:
methods. On iOS 9+ links are opened in SFSafariViewController therefore you need to implement only ... willOpenSafariViewController:
method, if your app supports earlier versions of iOS you will need to implement ... willOpenInternalBrowser:
method also. On older iOS versions a custom in-app browser view controller is used.
An example below demonstrates how to set in-app browsers bar tint color for AdInline ad view.
Swift
// Methods from AFVideoPlayerDelegate protocol.
func videoPlayer(_ videoPlayer: AFVideoPlayerController, willOpen safariViewController: SFSafariViewController) {
safariViewController.preferredBarTintColor = UIColor.red
}
func videoPlayer(_ videoPlayer: AFVideoPlayerController, willOpenInternalBrowser browserViewController: AFBrowserViewController) {
browserViewController.toolBar.barTintColor = UIColor.red
}
// Methods from AFAdInlineDelegate protocol.
func adInline(_ adInline: AFAdInline, willOpen safariViewController: SFSafariViewController) {
safariViewController.preferredBarTintColor = UIColor.red
}
func adInline(_ adInline: AFAdInline, willOpenInternalBrowser browserViewController: AFBrowserViewController) {
browserViewController.toolBar.barTintColor = UIColor.red
}
Objective-C
- (void)videoPlayer:(AFVideoPlayerController *)videoPlayer willOpenSafariViewController:(SFSafariViewController *)safariViewController {
safariViewController.preferredBarTintColor = UIColor.redColor;
}
- (void)adInline:(AFAdInline *)adInline willOpenInternalBrowser:(AFBrowserViewController *)browserViewController {
browserViewController.toolBar.barTintColor = UIColor.redColor;
}