The Agillic SDK enables you to utilize the Agillic platform from within your iOS App. The SDK currently includes the following functionality:
- Register devices used by a recipient in your mobile application.
- Register a recipient token required to send a Push Notification to a device using Apple PN on iOS or Firebase Cloud Messaging for Android. When registered, this token will allow sending push notifications to recipients via the Agillic Dashboard.
- Track recipient App Views. Tracking can be paused and resumed when requested by the user. Tracked events can be used to define Target Groups in the Agillic Dashboard which can be used to direct targeted marketing and other communication.
Other useful information:
- Read more about the Agillic Platform on the official Agillic website.
- And in our Developer portal.
- The Agillic SDK for Android can be found here: Agillic Android SDK
- Requires minimum iOS 11+
See the subsections below for details about the different installation methods.
Add a package by selecting File
→ Add Packages…
in Xcode’s menu bar.
Search for the Agillic iOS SDK using the repo's URL:
https://github.com/agillic/agillic-ios-sdk.git
For detailed documentaion on setting up the Agillic SDK with Swift Package Manger see: Swift Package Manager
NOTE: This is not the recommended method.
- Download this repository by selecting
Code
→Download ZIP
. - Open Downloads and locate ./src/AgillicSDK folder
- Drag and drop the AgillicSDK to your project
- Make sure to check
Copy items if needed
and Add to your App Target. - The Agillic SDK are dependant on the Snowplow iOS Tracker SDK version 1.7.1 and FMDB (OUT OF SCOPE)
In order to use AgillicSDK you have to initialize and configure it first.
You can configure your Agillic instance in code:
AGILLIC API KEY
AGILLIC API SECRET
AGILLIC SOLUTION ID
See how to setup your Agillic Solution and obtain these values in the Agillic Solution Setup Guide.
Start by importing the AgillicSDK Module into your AppDelegate.swift
file
import AgillicSDK
Initialize and configure the Agillic SDK upon launch
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
Agillic.shared.configure(apiKey: "AGILLIC API KEY", apiSecret: "AGILLIC API SECRET", solutionId: "AGILLIC SOLUTION ID")
return true
}
Your Agillic SDK instance is now ready for usage.
Optionally you can enable logging for debug usage.
Agillic.shared.logger.logLevel = .verbose
Prerequisites
- You need to make sure to do this AFTER
Agillic.shared.configure()
. - You must do this upon every launch before doing any App View Tracking.
- Register has to be done in your Sign Up/Sign In flow but also on you splash screen if users are automatically logged in with an Access Token.
RECIPIENT ID
- Has to matchRECIPIENT.EMAIL
in the Agillic Recipient Table
Agillic.shared.register(recipientId: "RECIPIENT ID")
Prerequisites
-
Configure your app to be able to receive Push Notifications Read this toturial
-
Read the Agillic Push Notification Setup document to learn how to send Push Potifications to your iOS application directly from your Agillic Solution.
-
Request permission for Remote Push Notifications in your App and obtain the Push Token from APNS NOTE: This requires you to have already obtained the Recipient ID and that you store this across app sessions - this is currently only supported for unknown recipients.
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { granted, error in
if let error = error {
print("Error: \(error.localizedDescription)")
} else {
DispatchQueue.main.async {
application.registerForRemoteNotifications()
}
}
}
return true
}
Read deviceToken
and add it to your Agillic Recipient.
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
let pushToken = deviceToken.map { String(format: "%02.2hhx", $0) }.joined()
// Register with PushToken
Agillic.shared.register(recipientId: "RECIPIENT ID", pushNotificationToken: pushToken)
}
NOTE: Work in progress
NOTE: Work in progress
NOTE: Work in progress
Track recipient behavior with App View Tracking.
App View Tracking is typically located in your UIViewController
file, but can be used elsewhere if needed.
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
let appView = AgillicAppView(screenName: "app://sublevel-1/sublevel-2")
Agillic.shared.tracker.track(appView)
}
The screenName
is the value that can be matched in the Condition Editor.
We suggest to use a hierarchical naming convention, prefixed with app://
ex:
app://sublevel-1/sublevel-2/...
Examples of usage:
app://landingpage
app://landingpage/sign-up/step-2
app://dashboard
app://product-offers
app://product-offers/21
app://menu/profile/edit
TODO: Usage in combination with 'Deeplinking' and 'Dynamic Links'
Please provide any feedback via a GitHub Issue.
Agillic SDK for iOS is available under the Apache 2.0 license. See LICENSE file for more info.
Copyright 2021 Agillic
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.