Free forever Marketing SDK with a dashboard for in-app SplashScreen banners with built-in analytics
AdaptivePlus is the control center for marketing campaigns in mobile applications.
CocoaPods is a dependency manage which automates and simplifies the process of using 3rd-party libraries in your projects. See the Get Started section for more details.
Add following to your Podfile
platform :ios, '11.0'
pod 'AdaptivePlus-iOS', '2.0.13'
and run following command.
$ pod install
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let settings = AdaptivePlusSettings(
url: "YOUR_ADAPTIVE_PLUS_API_URL",
clientId: "YOUR_CLIENT_ID",
clientSecret: "YOUR_CLIENT_SECRET",
apiKey: "YOUR_API_KEY"
)
AdaptivePlus.initialize(settings: settings, verbose: true/false)
return true
}
AdaptivePlusSettings
with apiKey
and other credentials that you received upon account registrationAdaptivePlus.instance.set(language: .en)
Default locale is .default
, which takes your app’s preferred locale.
It can take one of the following values .en/.ru/.kz/.default
.
let user = AdaptivePlusUser(userId: {String?})
AdaptivePlus.start(user: user, completion: { isStarted in
if isStarted {
print("AdaptivePlus started successfully")
} else {
print("AdaptivePlus did not start")
}
})
Method takes 2 optional arguments:
isStarted
.let apView = APView(publicationPageKey: "YOUR_PUBLICATION_PAGE_KEY")
view.addSubview(apView)
NSLayoutConstraint.activate([
apView.leftAnchor.constraint(equalTo: leftAnchor),
apView.rightAnchor.constraint(equalTo: rightAnchor),
apView.centerYAnchor.constraint(equalTo: centerYAnchor)
])
Note that the height of APView
will be calculated automatically and it’s constraint should not be set by the developer.
let apViewless = APViewless(publicationPageKey: "YOUR_PUBLICATION_PAGE_KEY")
func preloadContents() {
apViewless.preloadContents()
}
func showStory() {
apViewless.showStory()
}
Note that the method preloadContents()
should be called before method showStory()
. If showStory()
gets called before preloadContents()
nothing will be shown.
To make SDK experience more personalized, you can provide following user data to AdaptivePlusUser
:
let user = AdaptivePlusUser(
// In app Client Identifier (Email/Phone/Internal user id)
userId: "test user id",
// Client location (latitude & longitude)
userCoordinate: CLLocationCoordinate2D(latitude: 10.0, longitude: 123.0),
// Clinet gender
gender: AdaptivePlusUser.Gender.male,
// Client age
age: 22,
// In app Client Properties (Country/VIP Status, etc)
properties: ["education": "Bachelor", "country": "Kazakhstan"])
userId: String?
- In app Client Identifier (Email/Phone/Internal user id)
userCoordinate: CLLocationCoordinate2D?
- user location (latitude & longitude). Required to display geo-oriented content to the user
properties: [String: String]?
- user properties, e.g. - country, education, etc. User properties help SDK to select and show content relevant to the user
APView
via corresponding method:apView.reload()
APViewDelegate
and set delegate
property of APView
as follows:extension YourClass {
func setAPViewDelegate() {
apView.delegate = self
}
}
extension YourClass: APViewDelegate {
func apViewDidUpdateContent(view: APView) {
// handle content update action
}
func apViewDidTriggerCustomAction(view: APView, name: String, parameters: [String : Any]) {
// implementation of AdaptivePlus CustomAction
}
}
APViewlessDelegate
and set delegate
property of APViewless
as follows:extension YourClass {
func setAPViewlessDelegate() {
apViewless.delegate = self
}
}
extension YourClass: APViewlessDelegate {
func apViewlessDidFinish(viewless: APViewless) {
// do some your actions when story closed if needed
}
func apViewlessDidTriggerCustomAction(name: String, parameters: [String: Any]) {
// implementation of AdaptivePlus CustomAction
}
}
Note that the method apViewlessDidFinishStories
gets called after showStory()
even it didn’t show any story.
To observe network logs of the SDK - pass true
to verbose
method:
AdaptivePlus.initialize(settings: adaptivePlusSettings, verbose: true)
Do not forget to switch Verbose Mode off for the release build of your app.