AdaptivePlus is the control center for marketing campaigns in mobile applications.
- iOS 11.0 or later
- Xcode 12.0 or later
- Swift 4.2 or later
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 installfunc 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
}- Create
AdaptivePlusSettingswithapiKeyand other credentials that you received upon account registration - Initialize SDK with your AdaptivePlusSettings and optional boolean field (default value is 'false') 'verbose', when set to 'true' allows to observe network logs of the SDK
AdaptivePlus.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:
- AdaptivePlusUser - user of your system/service, useful for identifying the same user across multiple devices
- Completion - completion handler which will be called after start method completed with boolean
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
- You can reload the content of an
APViewvia corresponding method:
apView.reload()- You can implement
APViewDelegateand setdelegateproperty ofAPViewas 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
}
}- You can implement
APViewlessDelegateand setdelegateproperty ofAPViewlessas 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.
- Shows SDK generated content: able to display Images & GIFs & Texts, execute simplest set of actions on click, etc.
- Action list contains:
(1) Web URL Opening in WebView dialog window,
(2) DeepLink call to any application in iOS,
(3) Send SMS & Call Phone,
(4) Custom action