iOS
Quick Start with Google Admob
This walkthrough shows how to show Google Admob's Native Ads in story format with Storyly in your iOS application.
You can also check out the demo on GitHub
Before you begin
This walkthrough contains sample instance information. However, if you want to work with your own content as well, please login into Storyly Dashboard and get your instance token.
The sample instance information for testing purposes;
eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhY2NfaWQiOjc2MCwiYXBwX2lkIjo0MDUsImluc19pZCI6NDA0fQ.1AkqOy_lsiownTBNhVOUKc91uc9fDcAxfQZtpm3nj40
Also, you need to update required settings from Storyly Dashboard Ad Settings to enable Ads in the instance.
Warning
Please check Google AdMob Mobile Ads SDK(iOS) Quick Start Guide for correct integration.
You need to create a Native Ad Unit Id or for testing purposes use Test Ads
Installation
Warning
Storyly Monetization SDK targets
iOS 10
or higher.
CocoaPods
Storyly Monetization SDK is available through CocoaPods. CocoaPods is a dependency manager for Cocoa projects. To integrate Storyly Monetization SDK into your Xcode project using CocoaPods, specify it in your Podfile
:
use_frameworks!
pod 'StorylyMonetization'
Then run pod install
.
Warning
Please note that CocoaPods version should be 1.9+
Carthage
Storyly Monetization SDK is available through Carthage. To integrate Storyly Monetization SDK into your Xcode project using Carthage, specify it in your Cartfile
:
binary "https://prod-storyly-media.s3.eu-west-1.amazonaws.com/storyly-monetization-sdk/Carthage/StorylyMonetization.json"
binary "https://prod-storyly-media.s3.eu-west-1.amazonaws.com/storyly-sdk/Carthage/Storyly.json"
binary "Carthage/GoogleMobileAds.json" == 8.7.0
Then run carthage update --use-xcframeworks
.
After, add the frameworks to your Xcode project: Go to targets and select your application. Click plus button from the Frameworks, Libraries, and Embedded Content
section and add StorylyMonetization.xcframework
, Storyly.xcframework
and GoogleMobileAds xcframeworks
. If you can't find, add from Add Other > Add files
dialog. Frameworks will be located at Carthage/Build/
.
Warning
Please note that a custom solution is required to support GoogleMobileAds with Carthage. This walkthrough's setup contains GoogleMobileAds.json file in Carthage folder with following content;
{ "8.7.0": "https://dl.google.com/googleadmobadssdk/googlemobileadssdkios.zip" }
Warning
Please note that Carthage version should be 0.38+
Initialize StorylyAdProvider
You need to import related modules to use StorylyMonetization:
import StorylyMonetization
@import StorylyMonetization;
You need to set a StorylyAdProvider
to your StorylyView
instance to enable monetization feature.
self.storylyView.storylyAdViewProvider = StorylyMonetization.StorylyAdViewProvider(rootViewController: self,
adMobAdUnitId: ADMOB_NATIVE_AD_ID)
Just hit the run. Now, you should be able to enjoy Storyly
with ads π!
Google AdMob Consent Management
Before you begin
You may check Forward consent to the Google Mobile Ads SDK documentation for details.
StorylyAdViewProviders
provides a parameter, named adMobAdExtras
, in its constructor to pass additionalParameters
to Google AdMob.
Updated 6 months ago