Introduction
Welcome to the documentation for the SensorsAnalyticsEncrypt library! This library provides secure encryption and decryption functionality for integrating Sensors Analytics into your iOS application.
Getting Started
To use the SensorsAnalyticsEncrypt library, you need to follow these steps:
- Install the library via Cocoapods by adding the following line to your Podfile:
pod 'SensorsAnalyticsEncrypt'
- Import the library into your project by adding the import statement:
import SensorsAnalyticsEncrypt
- Configure Sensors Analytics with the encryption feature, using your specific encryption algorithm and key. Refer to the Configuring Sensors Analytics section for more details.
- Encrypt your data before sending it to Sensors Analytics and decrypt it when retrieving from Sensors Analytics. Refer to the Encrypting Data section for more details.
Configuring Sensors Analytics
To configure Sensors Analytics with the encryption feature, follow these steps:
- In your AppDelegate file, inside the
didFinishLaunchingWithOptions
method, initialize Sensors Analytics using your server URL and app ID.let sensorsAnalytics = SensorsAnalytics.shared(withServerURL: "YOUR_SERVER_URL", andDebugMode: .off)
- Set the encryption algorithm and key for Sensors Analytics.
sensorsAnalytics?.setEncryptionAlgorithm("YOUR_ENCRYPTION_ALGORITHM", andKey: "YOUR_ENCRYPTION_KEY")
- Start the Sensors Analytics SDK.
sensorsAnalytics?.start()
Encrypting Data
To encrypt data before sending it to Sensors Analytics, use the following method:
let encryptedData = sensorsAnalytics?.encryptEvent(autoTrackEvent: ["key1": "value1", "key2": "value2"])
This method takes a dictionary of event properties as input and returns the encrypted data. You can then send this encrypted data to Sensors Analytics using its track method.
Decrypting Data
To decrypt data retrieved from Sensors Analytics, use the following method:
let decryptedData = sensorsAnalytics?.decryptEvent(encryptedEvent: encryptedData)
This method takes the encrypted data as input and returns the decrypted event properties as a dictionary.
Please note that you should only perform decryption on data that you have previously encrypted using the Sensors Analytics encryption method.
Conclusion
Congratulations! You now have a basic understanding of how to use the SensorsAnalyticsEncrypt library to securely encrypt and decrypt data when integrating Sensors Analytics into your iOS application.
For more advanced usage and details on additional features, please refer to the official SensorsAnalyticsEncrypt documentation.