Skip to content

Commit

Permalink
Merge pull request #696 from IABTechLab/dsc/prebid-ios-documentation
Browse files Browse the repository at this point in the history
Add iOS to Prebid mobile documentation
  • Loading branch information
dcaunt authored Sep 4, 2024
2 parents c3527d0 + da62e73 commit b0cd224
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 105 deletions.
2 changes: 1 addition & 1 deletion docs/guides/integration-mobile-client-side.md
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ If the response status indicates that the DII has been opted out of UID2, you mi
## Optional: UID2 Prebid Mobile SDK Integration
:::important
The UID2 Prebid Mobile SDK integration is for Android only, and requires version 1.4.0 of the SDK for Android.
The UID2 Prebid Mobile SDK integration requires version 1.4.0 of the UID2 SDK for Android, or version 1.5.0 of the UID2 SDK for iOS.
:::
<PrebidMobileSDK />
2 changes: 1 addition & 1 deletion docs/guides/integration-prebid.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,6 @@ For detailed instructions, refer to one of the following integration guides:

## Prebid Mobile SDK Support for Mobile Devices

UID2 integration with Prebid is supported for Android mobile devices using the Prebid Mobile SDK.
UID2 integration with Prebid is supported for Android and iOS mobile devices using the Prebid Mobile SDK.

For details, see [UID2 Mobile Integration for Prebid Mobile SDK](integration-prebid-mobile-summary.md).
3 changes: 2 additions & 1 deletion docs/snippets/_mobile-docs-enable-logging.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ UID2Manager.init(
<TabItem value='ios' label='iOS'>

```swift
// On iOS, you must set UID2Settings before you first access UID2Manager.shared. Changes made to settings after first access are not read.
// On iOS, you must set UID2Settings before you first access UID2Manager.shared.
// Changes made to settings after first access are not read.
UID2Settings.shared.isLoggingEnabled = true
```

Expand Down
124 changes: 22 additions & 102 deletions docs/snippets/_mobile_docs_prebid-mobile.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

This section is for participants who want to integrate with UID2 and use the [Prebid Mobile SDK](https://prebid.org/product-suite/prebid-mobile/) for header bidding in Android <!-- and iOS -->applications.
This section is for participants who want to integrate with UID2 and use the [Prebid Mobile SDK](https://prebid.org/product-suite/prebid-mobile/) for header bidding in Android and iOS applications.

The UID2 Prebid integration monitors the state of the `UID2Identity`. Whenever the state changes, the Prebid integration automatically updates Prebid’s external user IDs. This includes when an identity is refreshed, resulting in a new advertising token.

Expand All @@ -13,92 +13,20 @@ This integration requires a Prebid Server setup.

To configure your UID2 Prebid for Mobile integration, follow the steps below.

1. Set up Prebid's Mobile SDK for Android, following the steps in [Prebid SDK Integration for Android](https://docs.prebid.org/prebid-mobile/pbm-api/android/code-integration-android.html).
1. Set up Prebid's Mobile SDK, following the steps in [Prebid SDK Integration for Android](https://docs.prebid.org/prebid-mobile/pbm-api/android/code-integration-android.html) or [Prebid SDK Integration for iOS](https://docs.prebid.org/prebid-mobile/pbm-api/ios/code-integration-ios.html).

2. Add the UID2 Mobile SDK to your app, following the steps in [Add the UID2 Mobile SDK to Your Mobile App](#add-the-uid2-mobile-sdk-to-your-mobile-app).

3. The UID2 Prebid integration is distributed as a separate module, so you must add it as a dependency in your project. Follow the installation instructions that apply to your integration, out of the following options:

- **Gradle**: Include the following in your Gradle configuration:
```js
implementation("com.uid2:uid2-android-sdk-prebid:1.4.0")
```

- **Maven**: To install with Maven, add the SDK as a dependency in the `pom.xml` file:
```xml
<dependency>
<groupId>com.uid2</groupId>
<artifactId>uid2-android-sdk-prebid</artifactId>
<version>1.4.0</version>
</dependency>
```

4. After adding the dependency, you'll need to configure the integration. First initialize the `UID2Manager`, and then Prebid, as shown in the following examples.

<Tabs groupId="language-selection">
<TabItem value='android' label='Android Kotlin'>
```js
UID2Manager.init(context = this)

PrebidMobile.initializeSdk(this) { Log.i(TAG, "Prebid: $it") }
prebid = UID2Prebid().apply {
initialize()
}
```
</TabItem>
<TabItem value='android-java' label='Android Java'>
```js
UID2Manager.init(this);

PrebidMobile.initializeSdk(this, status -> Log.i(TAG, "Prebid: " + status));

prebid = new UID2Prebid();
prebid.initialize();
```
</TabItem>
</Tabs>

5. Configure a callback that's passed in during initialization.

The UID2 Prebid integration periodically updates Prebid by setting the relevant external IDs when a new identity is generated or an existing token is refreshed.

This process is destructive, which means that if your application uses external IDs from another source, you'll need to provide those to the UID2 Prebid integration so that all external IDs are retained while the UID2 token is updated.

This is done via the callback, which must be passed in during initialization, as shown in the following examples.

<Tabs groupId="language-selection">
<TabItem value='android' label='Android Kotlin'>
```js
prebid = UID2Prebid(
externalUserIdFactory = ::getExternalIds,
).apply {
initialize()
}
```
</TabItem>
<TabItem value='android-java' label='Android Java'>
```js
prebid = new UID2Prebid(UID2Manager.getInstance(), () -> getExternalIds());
prebid.initialize();
```
</TabItem>
</Tabs>

<!--
1. Set up Prebid's Mobile SDK for Android, following the steps in [Prebid SDK Integration for Android](https://docs.prebid.org/prebid-mobile/pbm-api/android/code-integration-android.html).

2. Add the UID2 Mobile SDK to your app, following the steps in [Add the UID2 Mobile SDK to Your Mobile App](#add-the-uid2-mobile-sdk-to-your-mobile-app).

3. The UID2 Prebid integration is distributed as a separate module, so you must add it as a dependency in your project. Follow the installation instructions that apply to your integration, out of the following options.

<Tabs groupId="language-selection">
<TabItem value='android' label='Android'>
#### Installing with Gradle
<Tabs groupId="dependency-selection">
<TabItem value='gradle' label='Gradle (Android)'>
Include the following in your Gradle configuration:
```js
implementation("com.uid2:uid2-android-sdk-prebid:1.4.0")
```
#### Installing with Maven
</TabItem>
<TabItem value='maven' label='Maven (Android)'>
To install with Maven, add the SDK as a dependency in the `pom.xml` file:
```xml
<dependency>
Expand All @@ -108,28 +36,17 @@ To configure your UID2 Prebid for Mobile integration, follow the steps below.
</dependency>
```
</TabItem>
<TabItem value='ios' label='iOS'>
#### Installing with Package.swift
Add the following dependency to Package.swift:
<TabItem value='cocoapods' label='CocoaPods (iOS)'>
Add the following entry in your `Podfile`:
```js
dependencies: [
.package(url: "https://github.com/IABTechLab/uid2-ios-sdk.git", from: "1.2.0"), // TODO change
]
```
#### Installing with Xcode
In the XCode user interface, under Package Dependencies, add the following entry for your apps:
| Name | Location | Dependency Rule |
| :----------- | :------------------------------------------- |:----------------------------------------|
| uid2-ios-sdk | `[email protected]:IABTechLab/uid2-ios-sdk.git` | Up to next major version: 1.2.0 < 2.0.0 |

#### Installing with CocoaPods

Add the following entry in your `Podfile`:

```
pod 'UID2', '~> 1.2' // TODO change
pod 'UID2Prebid', '~> 1.5'
```
</TabItem>
<TabItem value='spm' label='SPM (iOS)'>
:::warning
Integration via Swift Package Manager is not supported until it is supported by the Prebid Mobile SDK itself. For details, see [Prebid's Mobile SDK documentation](https://docs.prebid.org/prebid-mobile/pbm-api/ios/code-integration-ios.html#swift-pm).
:::
</TabItem>
</Tabs>

4. After adding the dependency, you'll need to configure the integration. First initialize the `UID2Manager`, and then Prebid, as shown in the following examples.
Expand All @@ -155,9 +72,10 @@ To configure your UID2 Prebid for Mobile integration, follow the steps below.
prebid.initialize();
```
</TabItem>
<TabItem value='ios' label='iOS'>
<TabItem value='ios' label='iOS Swift'>
Initialize an instance of UID2Prebid and hold a strong reference to it. UID2Prebid only observes the UID2Manager while the instance is retained.
```js
// TODO
self.prebid = UID2Prebid()
```
</TabItem>
</Tabs>
Expand Down Expand Up @@ -186,9 +104,11 @@ To configure your UID2 Prebid for Mobile integration, follow the steps below.
prebid.initialize();
```
</TabItem>
<TabItem value='ios' label='iOS'>
<TabItem value='ios' label='iOS Swift'>
```js
// TODO
self.prebid = UID2Prebid(thirdPartyUserIDs: {
// return externalUserIDs
})
```
</TabItem>
</Tabs> -->
</Tabs>

0 comments on commit b0cd224

Please sign in to comment.