In this article, you will find step-by-step instructions to add Connectif Mobile SDK to your iOS project. This is the beginning of integrating your mobile app with Connectif, once you have reviewed that you meet the prerequisites to perform it.
1. Requirements to add Connectif Mobile SDK to your iOS project
- You will need to have your Mobile App integration activated in Connectif to access the integration configuration for your key. You can check our implementation guide.
- Developed as an iOS library in Swift.
- Minimum supported version: iOS 13.
- Implemented in the app with Apple Push Notification Service for receiving push notifications.
2. How to add Connectif Mobile SDK to your iOS project
1. Add the SDK
Currently, Connectif iOS SDK can be installed via Swift Package Manager (SPM). If you need a different repository, feel free to contact us to discuss your case.
To add the iOS SDK dependency through Swift Package Manager:
- Go to File > Add Package Dependencies.
- Make sure you have a GitHub account associated with Xcode (it should appear in the left column as Source Control Account). If not, you can add it by clicking the "+" symbol found in that same column.
- Enter the URL of our repository in the right search bar, for example:
https://github.com/connectif/Connectif-iOS-SDK
- Select the SDK when it appears in the central view.
- Click the Add Package option.
- In the target selection dialog, choose your app as the target for the Connectif iOS SDK and click Add Package.
2. Initialize the SDK
A good place to initialize the SDK is in the AppDelegate’s application(_:didFinishLaunchingWithOptions:), although this will depend on your app's nature.
Optionally, you can retrieve the email of users who registered or logged in before implementing the Connectif Mobile SDK by adding the user's email when initializing the SDK.
The email must meet these requirements:
- A valid email must have a username, followed by @, a domain, and an extension, without spaces or special characters.
- A maximum of 200 characters.
Email example:
class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) - Bool {
Connectif.initialize(apiKey: "YOUR_API_KEY", email: "useremail@example.com")
return true
}
}
3. (Optional) Log Configuration
When initializing the SDK, you can indicate the log level you want to display (default: LogLevel.NONE).
Each level includes the logs from the previous level, so INFO level will display all logs.
- NONE: Disables all logs.
- ERROR: Only errors are logged.
- WARN: Warnings and errors are logged.
-
INFO: Info messages, warnings, and errors are logged.
4. Implement User Tracking
Once you have configured the initialization, you can start tracking users by implementing various notifications.
- Notify Page Visit Event
- Notify Product Visit Event
- Notify Purchase Event
- Notify Search Event
- Notify Cart Information
- Notify Contact Information
- Notify Newsletter Subscription
- Notify Login Event
- Notify Registration Event
- Notify Custom Event
Keep Learning!
To fully leverage the potential of your Connectif account, we recommend the following articles:
- Complete Guide to Integrating Connectif with Your Mobile App.
- Apple Push Notifications Service Setup, to enable push sending and receiving via the iOS Mobile SDK.
- Android SDK Get Started, to add Connectif Mobile SDK to your Android project.
- Firebase Cloud Messaging Setup, to enable push sending and receiving via the Android Mobile SDK.