Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions content/minfraud/track-devices/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ Device ID.
text: "Track devices on your website using JavaScript."
- heading: "Android"
url: "/minfraud/track-devices/android"
text: "Track devices in your Android app using Kotlin."
text: "Track devices in your Android app using Kotlin or Java."
- heading: "iOS"
url: "/minfraud/track-devices/ios"
text: "Track devices in your iOS app using Swift or Objective-C."
{{</ link-group/container >}}

<!-- prettier-ignore-end -->
Expand Down Expand Up @@ -61,9 +64,10 @@ changes.
3. Include the token in your minFraud API request's `device` object as
`tracking_token`.

See the [Web](/minfraud/track-devices/web#explicit-device-linking-examples) and
[Android](/minfraud/track-devices/android#explicit-device-linking-examples)
guides for platform-specific examples.
See the [Web](/minfraud/track-devices/web#explicit-device-linking-examples),
[Android](/minfraud/track-devices/android#explicit-device-linking-examples), and
[iOS](/minfraud/track-devices/ios#explicit-device-linking-examples) guides for
platform-specific examples.

### Token handling

Expand Down
2 changes: 2 additions & 0 deletions content/minfraud/track-devices/android.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ Add the MaxMind Device SDK dependency to your app-level `build.gradle` file.
```kotlin
// build.gradle.kts (Kotlin DSL)
dependencies {
// Check https://search.maven.org/artifact/com.maxmind.device/device-sdk for the latest version.
implementation("com.maxmind.device:device-sdk:0.2.0")
}
```

```groovy
// build.gradle (Groovy DSL)
dependencies {
// Check https://search.maven.org/artifact/com.maxmind.device/device-sdk for the latest version.
implementation 'com.maxmind.device:device-sdk:0.2.0'
}
```
Expand Down
138 changes: 138 additions & 0 deletions content/minfraud/track-devices/ios.md
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
Comment thread
PatrickCroninMM marked this conversation as resolved.
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
Comment thread
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).
5 changes: 5 additions & 0 deletions hugo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ title = 'MaxMind'
pageRef = '/minfraud/track-devices/android'
parent = 'Track Devices'
weight = 20
[[menus.minfraud]]
name = 'iOS'
pageRef = '/minfraud/track-devices/ios'
parent = 'Track Devices'
weight = 30
[[menus.minfraud]]
name = 'minFraud Alerts'
pageRef = '/minfraud/alerts'
Expand Down
1 change: 1 addition & 0 deletions lychee.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ exclude = [
'^https://www\.maxmind\.com/en/accounts/', # MaxMind account pages (require login)
'^https://search\.maven\.org/#', # Hash-based JS routing, not HTML fragments
'^https://github\.com/maxmind/device-android', # README fragment not parseable
'^https://github\.com/maxmind/device-ios', # README fragment not parseable
'^https://github\.com/maxmind/device-tracking', # README fragment not parseable
'maxmind-ip-network-data#anycast', # Fragment not parseable on support site
'fraud-prevention/overview#buy-now', # Fragment not parseable on maxmind.com
Expand Down
2 changes: 2 additions & 0 deletions stopwords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,13 @@ mmapiwsid
mmdb
mmdbinspect
mmdblua
MMSDK
Movistar
Msxml
Nord
Norte
Nubilum
objc
Odido
omni
onFailure
Expand Down
Loading