Mobile SDKs: Integrate Bazaarvoice into your native Android and iOS apps.
Installation
The Bazaarvoice Mobile SDKs provide access to most of the core products Bazaarvoice offers. To learn more, go to the Mobile SDK documentation home page.
Contents
Introduction
This guide shows you how to install and configure the Bazaarvoice Mobile SDK into your iOS app. Please make sure you have all the needed requirements for your application first! Bazaarvoice supports XCode 8.0 or higher.
Versioning
The Mobile SDK for iOS provides support for Objective-C and Swift programming languages. The SDK is versioned so that we can release new features, bug fixes and improvements without compromising the stability of applications using older versions.
This table summarizes the major version releases. For more information refer to the Mobile SDK for iOS (Objective-C) Github repo.
Version | Release Date | Status |
---|---|---|
1 | Jul 16, 2012 | Deprecated |
2 | Jan 23, 2013 | Deprecated |
3 | Dec 21, 2015 | Deprecated |
4 | May 4, 2016 | Deprecated |
5 | Oct 31, 2016 | Supported |
6 | Nov 28, 2016 | Supported |
7 | Mar 06, 2018 | Supported |
8 | Oct 12, 2018 | Latest |
This table summarizes the major version releases. For more information refer to the Mobile SDK for iOS (Swift) Github repo.
Version | Release Date | Status |
---|---|---|
1 | Feb 28, 2020 | Latest |
- Deprecated
- These versions should not be expected to return data and/or may experience service degradation. Documentation specific to these versions may no longer be available. These versions should not be used by any applications.
- Supported
- Supported versions continue to receive security and bug fixes, but applications using these versions should be upgraded to the latest version when possible to take advantage of new features. New applications should not use these versions.
- Latest
- This is newest version. New applications should use the most recent release of this version.
Identifier for Advertisers (IDFA)
The Identifier for Advertisers (IDFA) is a random device identifier assigned by Apple to a user’s device. The IDFA is used for tracking and identifying a user (without revealing personal information). Advertisers use this to track data so they can deliver customized advertising.
In iOS 13 and earlier, the IDFA was available by default with the exception of users who had limited ads personalization in the settings on their iOS devices.
With the release of iOS 14, users are required to explicitly give permission in order to use the IDFA. Adding the AppTrackingTransparency
permission to your apps adds an ATT alert that asks users to allow access to and use of identifiers like IDFA.
Request App Tracking Transparency authorization
If you are using BVSDK version 8.4.0 and above or BVSwift version and above 1.4.0, To display the App Tracking Transparency authorization request for accessing the IDFA, update your Info.plist to add the NSUserTrackingUsageDescription key with a custom message describing your usage. Here is an example description text
<key>NSUserTrackingUsageDescription</key> <string> Your data will be used to provide you a better and personalized ad experience. </string>
The usage description appears in the App Tracking Transparency dialog box
Installing the BVSDK
We support installation of the Bazaarvoice SDK for iOS with CocoaPods, Carthage, Dynamic Framework, or straight up source code. Choose the solution that best fits your development environment.
By default, each BV module of the Cocoapods installs the BVCore + BVAnalytics modules.
- Install the latest version of CocoaPods. Bazaarvoice supports Cocoapods 1.1.0 or higher.
- Add the pods for which you have an API key into your
Podfile
:# each pod is a subpsec so you only need to add the lines for the component you are installing. pod 'BVSDK/BVAnalytics' // Automatically installed by any of the submodules below pod 'BVSDK/BVCommon' pod 'BVSDK/BVCommonUI' pod 'BVSDK/BVConversations' pod 'BVSDK/BVConversationsStores' pod 'BVSDK/BVConversationsUI' pod 'BVSDK/BVCurations' pod 'BVSDK/BVCurationsUI' pod 'BVSDK/BVNotifications' pod 'BVSDK/BVRecommendations'
- Run the following command from a terminal:
$ pod install
- Open the managed
.xcworkspace
file to open your project in Xcode. 5. In the future, to update to the latest version of the SDK, just run:$ pod update
By default, each BV module of the Cocoapods installs the BVCore + BVAnalytics modules.
- Install the latest version of CocoaPods. Bazaarvoice supports Cocoapods 1.1.0 or higher.
- Add the pods for which you have an API key into your
Podfile
:# each pod is a subpsec so you only need to add the lines for the component you are installing. pod 'BVSwift/BVAnalytics' // Automatically installed by any of the submodules below pod 'BVSwift/BVCommon' pod 'BVSwift/BVConversations' pod 'BVSwift/BVCurations' pod 'BVSwift/BVRecommendations'
- Run the following command from a terminal:
$ pod install
- Open the managed
.xcworkspace
file to open your project in Xcode. 5. In the future, to update to the latest version of the SDK, just run:$ pod update
- Install the latest version of Carthage.
- Add the following line to your
Cartfile
:github "bazaarvoice/bv-ios-sdk"
- Follow the Carthage installation instructions.
- In the future, to update to the latest version of the SDK, run the following command:
$ carthage update
- Install the latest version of Carthage.
- Add the following line to your
Cartfile
:github "bazaarvoice/bv-ios-swift-sdk"
- Follow the Carthage installation instructions.
- In the future, to update to the latest version of the SDK, run the following command:
$ carthage update
- Download the latest
BVSDK.framework.zip
from our GitHub releases page. - Drag
BVSDK.framework
to the "Embedded Binaries" section of your Xcode project's "General" settings. Make sure to select "Copy items if needed". - Head to the "Build Phases" section of your Xcode project settings, and create a new "Run Script Build Phase". Paste the following snippet into the text field:
bash "${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/BVSDK.framework/integrate-dynamic-framework.sh"
- Download the latest
BVSwift.framework.zip
from our GitHub releases page. - Drag
BVSwift.framework
to the "Embedded Binaries" section of your Xcode project's "General" settings. Make sure to select "Copy items if needed". - Head to the "Build Phases" section of your Xcode project settings, and create a new "Run Script Build Phase". Paste the following snippet into the text field:
bash "${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/BVSwift.framework/integrate-dynamic-framework.sh"
- Clone this repo, or download the latest release from GitHub:
-
Copy all the source folders under
/BVSDK
, except theSupport
folder, into your project. Make sure to select Copy items if needed.
- Clone this repo, or download the latest release from GitHub:
-
Copy all the source folders under
/BVSWift
, except theSupport
folder, into your project. Make sure to select Copy items if needed.
Add a Package Dependency
We are supporting Swift Package Manager integration for Bazaarvoice’s iOS Swift SDK(BVSwift) from version 1.5.0. To add BVSwift package dependency to your Xcode project, use the GitHub Repository and follow the steps listed below
You can add the Swift Package Manager dependency to your Xcode Project by following any one of the below steps:
-
Select File > Swift Packages > Add Package Dependency and enter BVSwift repository URL
-
You can also select the Project and go to the Swift Packages, click the + button, and enter BVSwift repository URL.
-
You can also navigate to your target’s General pane, and in the “Frameworks, Libraries Embedded Content” section, click the + button, select Add Other, and choose Add Package Dependency.
Configuring the BVSDK
Once you have installed the source code for the SDK, you are now ready to initialize the BVSDKManager
with your API key(s) and envrionment (staging versus production).
The table below will generate a configution file for your SDK. The values you set will generate the necessary script and Mobile SDK intialization code to get you up and running quickly.
Each client application should have its own API key. If you need to generate a new key for Conversations please see Conversations Requesting API Keys.
For all other API keys or if you don't know your client ID, contact Bazaarvoice Support or your implementation team.
Products | Production | Staging |
---|---|---|
Curations | ||
Conversations | ||
Conversations for Stores | ||
Product Recommendations & Advertising | ||
Analytics Locale |
Enter your Client ID and at least one API key.
Add the correct import statements so you can reference the Mobile SDK modules you are using.
@import BVSDK;
import BVSDK
import BVSwift
Initialize the BVSDKManager
in your XCode project.
After you have completed the previous steps, insert the following code in AppDelegate#applicationDidFinishLaunchingWithOptions
:
Staging
[BVSDKManager configure:BVConfigurationTypeStaging]; //Configure with Staging API keys
Production
[BVSDKManager configure:BVConfigurationTypeProd]; //Configure with Prod API keys
Initialize the BVSDKManager
in your XCode project.
After you have completed the previous steps, insert the following code in AppDelegate#applicationDidFinishLaunchingWithOptions
:
Staging
BVSDKManager.configure(.staging) //Configure with Staging API keys
Production
BVSDKManager.configure(.prod) //Configure with Prod API keys
Initialize the BVManager
in your XCode project.
Staging
BVManager.sharedManager.getConfiguration
Production
BVManager.sharedManager.getConfiguration
Programatically configuring the BVSDK
The BVSDKManager
can also be configured programatically. This scenario is not typically recommended, however, you can use this method if you need to modify your API keys within the same application session.
NSDictionary *configDict = @{ @" apiKeyConversations" : @" YOUR_API_KEY", @"clientId" : @" YOUR_CLIENT_ID" }; [BVSDKManager configureWithConfiguration:configDict configType:BVConfigurationTypeStaging ];
The BVSDKManager
can also be configured programatically. This scenario is not typically recommended, however, you can use this method if you need to modify your API keys within the same application session. Configure the BVSDKManager
programmatically for the Conversations API like the Swift example below. Call BVSDKManager.configure(...)
when you need to update the API key and environment in use.
let configDict = ["clientId": "YOUR_CLIENT_ID", "apiKeyConversations": "YOUR_API_KEY"]; BVSDKManager.configure(withConfiguration: configDict, configType: .staging)
The BVManager
can also be configured programatically.
var config: BVConversationsConfiguration = { () -> BVConversationsConfiguration in let analyticsConfig: BVAnalyticsConfiguration = .configuration(locale: Locale(identifier: "locale"), configType: .staging(clientId: "clientId")) return BVConversationsConfiguration.all( clientKey: "passkey", configType: .staging(clientId: "clientId"), analyticsConfig: analyticsConfig) }() //replace "locale", “clientId”, “passkey” placeholders with relevant value
This config variable needs to be passed in all requests.