Before you can begin working with TPLLBA on iOS, you need to download the TPLLBA SDK for iOS.
To build a project using the TPLLBA SDK for iOS, you need version 9.0 or later of Xcode.
TPLLBA SDK for iOS is available as a CocoaPods pod. CocoaPods is an open source dependency manager for Swift and Objective-C Cocoa projects.
If you don't already have the CocoaPods tool, install it on macOS by running the following command from the terminal. For details, see the CocoaPods Getting Started guide.
sudo gem install cocoapods
Create a Podfile for the TPLLBA SDK for iOS and use it to install the API and its dependencies:
-
If you don't have an Xcode project yet, create one now and save it to your local machine. (If you're new to iOS development, create a Single View Application.)
-
Create a file named
Podfilein your project directory. This file defines your project's dependencies. -
Edit the
Podfileand add your dependencies. Here is an example which includes the dependencies you need for the TPLLBA SDK for iOS:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
target 'YOUR_APPLICATION_TARGET_NAME_HERE' do
pod 'TPLLBA'
end-
Save the
Podfile -
Open a terminal and go to the directory containing the
Podfile:
cd <path-to-project>-
Run the
pod installcommand. This will install the APIs specified in thePodfile, along with any dependencies they may have. -
Close Xcode, and then open (double-click) your project's
.xcworkspacefile to launch Xcode. From this time onwards, you must use the.xcworkspacefile to open the project.
The code below demonstrates how to start engine of TPLLBA in application.
Now, Update a few methods inside your app's AppDelegate class.
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
LBAds.shared().initializeAdsWithAppId("APP_ID")
return true
} func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
// Convert token to string
let deviceTokenString = deviceToken.reduce("", {$0 + String(format: "%02X", $1)})
LBAds.shared().setAPNSToken(deviceTokenString)
} func applicationDidEnterBackground(_ application: UIApplication) {
LBAds.shared().applicationDidEnterBackground()
}
func applicationDidBecomeActive(_ application: UIApplication) {
LBAds.shared().applicationWillEnterForeground()
}
Add following code to show the ads notifications
func application(_ application: UIApplication, didReceive notification: UILocalNotification) {
LBAds.shared().notificationTapped(notification)
}Following settings are required for propely working sdk
- App Transport Security Settings : Allow Arbitrary Loads : YES
- Privacy - Location Always Usage Description : [Message to Display User]
- Privacy - Location Always and When In Use Usage Description : [Message to Display User]
- Privacy - Location When In Use Usage Description : [Message to Display User]
In Capabilities:
- Enable Background Modes for Location Updates and Background Fetch
- Turn On Remote Notifications