Requirements
- iOS Target: 13+
- Swift Version: 5.1
- Minimum Xcode: XCode 11
Installation
To install our SDK in your Swift application, there are 2 options:Via Xcode (Recommended)
- Go to File > Add Packages…
- Enter the SDK repository URL
https://github.com/nemu-brazil/nemu-swift-sdk.git - Choose version
From 1.0.0
import NemuTrackingLib
Or via Package.swift (When using SPM in the manifest):
Info.plist to find it: build settings in Xcode → Info.plist. In your Info.plist, add:
Registering UID to the SDK session
For total security and integrity of your application user data,
all UIDs registered by our SDK are encrypted before being
stored on our servers.
setUserId() method, passing the defined UID of the user who just completed the login process as an argument. Example:
Example: UIKit applications with AppDelegate
InAppDelegate, after recovering the user from the session (for example, via UserSessionManager), call the SDK’s setUserId method:
Retrieving UTMs when sending sale event to Nemu API
ThegetLastSessionHistory() method returns an object containing the UTMs from the user’s last session. Use this object when sending the sale information to the Nemu API.
Testing the SDK and ensuring everything is right – Swift SDK
To test the complete integration flow and ensure everything is working correctly with Nemu’s SDK in Swift, follow the steps below:1. Initialize the SDK in Debug mode
To view detailed SDK logs, enable debug mode when initializing it. Simply pass theisDebugMode parameter as true during initialization:
AppDelegate or in the SwiftUI @main struct.
2. Click on a deep link that redirects to the app with UTMs
If your application is not yet configured to receive deep links, follow our guide to configure Universal Links on iOS. Use a link like this (with UTMs) to perform the test:3. Check application logs
With the SDK correctly configured and debug mode enabled, you should see the following logs in the console when opening the app via deep link:Log explanation:
- Connection to Nemu: The SDK was successfully initialized and validated the token and pixel ID.
- UTM Extraction: The SDK correctly read and stored the deep link parameters.
- UID Registered: The app passed the user’s unique identifier using
setUserId.
4. Check the recovery of UTMs with getLastSessionHistory()
As a final step, call the getLastSessionHistory() method and validate if the UTM data is being correctly retrieved.
"||nemu_xiI85afzrP" at the end of utm_content is Nemu’s internal session identifier. It must be sent exactly like this when registering sales in the Nemu API.