iOS SDK
Ensure you have completed the Prerequisites section before continuing.
Installation
The minimum supported version for iOS is 12.0. To set the Minimum SDK target,
- Open your iOS project in XCode
- Select your Target > General > Deployment Info > Ensure that the version is set to 12.0+
Using Cocoapods
- Update your Podfile:
platform :ios, '12.0' # must be 12 or higher
# ...
target 'YOUR_TARGET_NAME' do
# ...
pod 'DashX'
# ...
end
- Open Terminal in your project's root directory and run:
pod install
Using Carthage
Specify the dependency in your Cartfile:
github "dashxhq/dashx-ios"
Run the following command:
carthage update
Using Swift Package Manager
- In your Xcode project, go to File > Add Packages
- Paste the following URL in "Search or Enter Package URL":
https://github.com/dashxhq/dashx-ios.git
Configuration
DashX needs to be initialized as early as possible in your application's lifecycle, which can be done in the AppDelegate class within the application(_:didFinishLaunchingWithOptions:) method:
import DashX
// ...
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
DashX.configure(
withPublicKey: "...", // required
baseURI: "...", // optional
targetEnvironment: "..." // optional
)
// ...
return true
}
Your Public Key is not sensitive, and can be stored in code or within Info.plist. If you're using multiple Environments, we recommend creating separate targets for each Environment, and then creating *.xcconfig files for each combination of Target & Configuration.
- Learn more about xcconfig.
- Check out the
Configfolder in DashX Demo iOS App for an example.
Permissions
dashx-ios SDK offers the following methods to request permissions
// Permission to receive Notification Permissions
DashX.requestNotificationPermission()
Additionally we track network information information about the current network connection, containing bluetooth, carrier, cellular, and wifi.
Troubleshooting
As an optional step, you can set the log level for debugging your integration:
DashXLog.setLogLevel(to: .debug)
By default, the log level is set to .error. You can set it to one of: .debug (most logs), .info, .error or .off (no logs).
Usage
User Management
do {
try DashX.identify(withOptions: [
"uid": "123",
"firstName": "John",
"lastName": "Doe"
])
} catch {
// Error Handling
}
Analytics
DashX.track("Button Clicked", withData: [
"label": "Click here",
"placement": "top"
])
Messaging
// Manage user contact for Push Notification
DashX.subscribe()
DashX.unsubscribe()
// Manage User Preferences
DashX.fetchStoredPreferences { _preference_ in
// ...
} failureCallback: { _ in
// ...
}
DashX.saveStoredPreferences { _preference_ in
// ...
} failureCallback: { _ in
// ...
}