Mandatory Functions
For the SDK to fully function and provide better ad targeting, SevenOneAds must be notified of any page updates and what type of content the current page is containing. On each full screen update the API pageUpdated()
must be called. This will most commonly happen one page transitions in the app, and the SDK should therefore be notifed on each onResume()
/viewDidAppear()
(see sample below). It should also be notified of any custom full screen page updates, such as pull to refresh etc.
Note: The different page domains should be agreed upon beforehand. If you are uncertain about which page domains to send, please contact your publisher manager.
override fun onResume() {
super.onResume()
SevenOneAds.pageUpdated(<pageTopDomain>,
<pageSubDomain>,
<contentURL>,
<customPageTargeting>)
}
override func viewDidAppear(_ animated: Bool) {
SevenOneAds.shared.pageUpdated(pageTopDomain: <pageTopDomain>,
pageSubDomain: <pageSubDomain>,
contentUrl: <contentURL>,
customPageTargeting: <customPageTargeting>)
}
pageTopDomain
: sets the top page domain. This would be the top topic of the current page, for example "football". The supported domains for your integration will be provided by SOM.pageSubDomain
: (Optional, default: null) sets the sub page domain. This would be the sub topic of the current page, for example "champions-league". The supported domains for your integration will be provided by SOM.contentURL
: (Optional, default: null) sets the content url.customPageTargeting
(Optional, default null) allows to send in custom targeting key/value parameters for the specific page. A single key can have multiple values. Only targeting key/values registered by SOM will be added to the ad requests, unregistrated values will be ignored. If you want to enable custom page targeting, please contact your publisher manager to add it to your configuration.
Note: If your application is running on iOS 13, please refer to the changes below.
iOS 13
An important note is adapting to the changes introduced by iOS 13 in terms of presentation style of view controllers (see here for more info). In iOS 13, view controllers are presented as a sheet by default in contrast to previous versions where they used to cover the entire screen. This means that navigating between view controllers might cause the presenting view controller’s viewDidAppear()
function to not get called when returned to that view controller. If your application is using segues/navigation controllers/etc. to present different view controllers, you need to make sure viewDidAppear()
still gets called when you return on a presenting view controller. For this reason, it's important that you override the modalPresentationStyle
of your presented view controller to .fullScreen
to ensure that the presented view controller covers the entire screen and the presenting view controller's viewDidAppear()
function gets called when returned to it, which can be done on the Storyboard (by setting the segue kind to Present Modally
and the presentation style to Full Screen
) or programatically as shown below.
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let vc = segue.destination as? YourDestinationViewController {
vc.modalPresentationStyle = .fullScreen
}
}