-
Notifications
You must be signed in to change notification settings - Fork 3
iOS Device SDK docs are added to our minfraud docs #1649
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b44f56d
Mention Java as well for the Android SDK
PatrickCroninMM da68f72
Add iOS Device SDK page
PatrickCroninMM 6e19540
Wire-up new page
PatrickCroninMM 460d0c0
Readme fragment was not found in document, but does work
PatrickCroninMM 92bf5f3
Add notes to check for the latest version
PatrickCroninMM File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,138 @@ | ||
| --- | ||
| draft: false | ||
| title: iOS | ||
| --- | ||
|
|
||
| {{< alert warning >}} The MaxMind Device SDK for iOS is currently in beta. | ||
| {{</ alert >}} | ||
|
|
||
| The MaxMind Device SDK for iOS collects device data and sends it to MaxMind so | ||
| that the minFraud service can assign a Device ID and use it to detect fraud | ||
| across sessions. The SDK exposes both a Swift API and an Objective-C API; | ||
| Objective-C classes use an `MM` prefix. | ||
|
|
||
| ## Requirements | ||
|
|
||
| - iOS 15.0+ | ||
| - Swift 5.9+ | ||
| - Xcode 15.0+ | ||
|
|
||
| ## Installation | ||
|
|
||
| Add the MaxMind Device SDK as a Swift Package dependency. In Xcode, choose | ||
| **File > Add Package Dependencies…** and enter the repository URL | ||
| `https://github.com/maxmind/device-ios.git`. | ||
|
|
||
| Or add it to your `Package.swift`: | ||
|
|
||
| ```swift | ||
| dependencies: [ | ||
| // Check https://github.com/maxmind/device-ios/releases for the latest version. | ||
| .package(url: "https://github.com/maxmind/device-ios.git", from: "0.1.0") | ||
| ] | ||
| ``` | ||
|
|
||
| Check the [device-ios releases](https://github.com/maxmind/device-ios/releases) | ||
| for the latest version. | ||
|
|
||
| ## Initialization | ||
|
|
||
| Initialize the SDK with your | ||
| [MaxMind account ID](https://support.maxmind.com/knowledge-base/articles/find-your-maxmind-account-id). | ||
| Replace `MAXMIND_ACCOUNT_ID` with your account ID. | ||
|
|
||
| {{< codeset >}} | ||
|
|
||
| ```swift | ||
| import MinFraudDevice | ||
|
|
||
| let config = SDKConfig(accountID: MAXMIND_ACCOUNT_ID) | ||
| let tracker = DeviceTracker(config: config) | ||
| ``` | ||
|
|
||
| ```objc | ||
| @import MinFraudDevice; | ||
|
|
||
| MMSDKConfig *config = [[MMSDKConfig alloc] initWithAccountID:MAXMIND_ACCOUNT_ID]; | ||
| MMDeviceTracker *tracker = [[MMDeviceTracker alloc] initWithConfig:config]; | ||
| ``` | ||
|
|
||
| {{</ codeset >}} | ||
|
|
||
| ## Collect and send device data | ||
|
|
||
| Call `collectAndSend()` to collect device data and send it to MaxMind. The Swift | ||
| API uses Swift concurrency (`async`/`await`); the Objective-C API uses a | ||
| completion handler. | ||
|
|
||
| {{< codeset >}} | ||
|
|
||
| ```swift | ||
| import MinFraudDevice | ||
|
|
||
| do { | ||
| let result = try await tracker.collectAndSend() | ||
| print("Device data sent successfully") | ||
| } catch { | ||
| print("Failed to send device data: \(error)") | ||
| } | ||
| ``` | ||
|
|
||
| ```objc | ||
| [tracker collectAndSendWithCompletion:^(MMTrackingResult *result, NSError *error) { | ||
| if (error) { | ||
| NSLog(@"Failed to send device data: %@", error); | ||
| return; | ||
| } | ||
| NSLog(@"Device data sent successfully"); | ||
| }]; | ||
| ``` | ||
|
|
||
| {{</ codeset >}} | ||
|
|
||
| ## Explicit device linking examples | ||
|
|
||
| Capture the `trackingToken` from the `collectAndSend()` result and pass it to | ||
|
PatrickCroninMM marked this conversation as resolved.
|
||
| your backend for inclusion in the minFraud API request. | ||
|
|
||
| {{< codeset >}} | ||
|
|
||
| ```swift | ||
| import MinFraudDevice | ||
|
|
||
| do { | ||
| let result = try await tracker.collectAndSend() | ||
| let token = result.trackingToken | ||
| // Send the tracking token to your backend | ||
| sendTokenToBackend(token) | ||
| } catch { | ||
| print("Failed to send device data: \(error)") | ||
| } | ||
| ``` | ||
|
|
||
| ```objc | ||
| [tracker collectAndSendWithCompletion:^(MMTrackingResult *result, NSError *error) { | ||
| if (error) { | ||
| NSLog(@"Failed to send device data: %@", error); | ||
| return; | ||
| } | ||
| // Send the tracking token to your backend | ||
| [self sendTokenToBackend:result.trackingToken]; | ||
| }]; | ||
| ``` | ||
|
|
||
| {{</ codeset >}} | ||
|
|
||
| On your backend, include the token in the minFraud API request: | ||
|
|
||
| ```json | ||
| { | ||
| "device": { | ||
| "ip_address": "2001:db8::ff00:42:8329", | ||
| "tracking_token": "token-value-from-client" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| For full SDK documentation, see the | ||
| [device-ios README](https://github.com/maxmind/device-ios#readme). | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.