Setup HyBid (Pre v:2.3.0) - pubnative/pubnative-hybid-ios-sdk GitHub Wiki
As you might have noticed, we changed our product name from PubNativeLite to HyBid. What that means is that if your project uses the old PubNativeLite SDK, we encourage you to check out the Migration to HyBid.framework document here for a smooth migration.
There are 2 ways that you can install HyBid into your application;
- Download HyBid.framework and simply drag and drop the HyBid.framework file to Embedded Binaries section on project configuration page.
or
- If you're using CocoaPods, you can add the following line to your
Podfile
.
pod 'HyBid', '2.2.1'
- Select your target and navigate to the Build Phases. Then, add a Run Script step to your build steps.
- Put it after your step to Embed Frameworks, set it to use
/bin/sh
and enter the following script:
APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"
find "$APP_PATH" -name 'HyBid.framework' -type d | while read -r FRAMEWORK
do
FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"
echo "Executable is $FRAMEWORK_EXECUTABLE_PATH"
EXTRACTED_ARCHS=()
for ARCH in $ARCHS
do
echo "Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME"
lipo -extract "$ARCH" "$FRAMEWORK_EXECUTABLE_PATH" -o "$FRAMEWORK_EXECUTABLE_PATH-$ARCH"
EXTRACTED_ARCHS+=("$FRAMEWORK_EXECUTABLE_PATH-$ARCH")
done
echo "Merging extracted architectures: ${ARCHS}"
lipo -o "$FRAMEWORK_EXECUTABLE_PATH-merged" -create "${EXTRACTED_ARCHS[@]}"
rm "${EXTRACTED_ARCHS[@]}"
echo "Replacing original executable with thinned version"
rm "$FRAMEWORK_EXECUTABLE_PATH"
mv "$FRAMEWORK_EXECUTABLE_PATH-merged" "$FRAMEWORK_EXECUTABLE_PATH"
done
To use the Adapters in your project, simply import PubnativeLite/PubnativeLiteDemo/Adapters
folder and all of its content to your project.
To use the Adapters in your Swift project, ensure that you've imported PubnativeLite/PubnativeLiteDemo/Adapters/HyBid-Bridging-Header.h
to your project and the Objective-C Bridging Header build setting under Swift Compiler - Code Generation has a path to the header
Add the HyBid.framework
to your code.
Swift:
import HyBid
Objective-C:
#import <HyBid/HyBid.h>
Before making any requests, you must initialise HyBid iOS SDK by calling init()
method and wait for its completion. Ideally, you should call this init()
method in your app's AppDelegate.
Swift:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
//...
//....
HyBid.initWithAppToken("<YOUR_APP_TOKEN_HERE>") { (success) in
if (success) {
print("HyBid Successfully Initialized")
}
}
//...
//....
return true
}
Objective-C:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//...
//....
[HyBid initWithAppToken:@"<YOUR_APP_TOKEN_HERE>" completion:^(BOOL success) {
if (success) {
NSLog(@"HyBid initialisation completed");
}
}];
//...
//....
return YES;
}
There are certain parameters that should be configured in the SDK before doing any type of interaction with it. Ensure to configure these parameters only 1 per session.
If your app is intended for children you should set COPPA as true
in order to protect the privacy of the information in their devices. It is disabled by default.
Swift:
HyBid.setCoppa(Bool)
Objective-C:
[HyBid setCoppa:BOOL];
In development, you should set Test Mode as true
for our SDK and disable it in the release. It allows not to track impressions and tracks on the server side of development application:
Swift:
HyBid.setTestMode(Bool)
Objective-C:
[HyBid setTestMode:BOOL];
The SDK refreshes the user location after every ad request if the user has given permission for location tracking. This is done to keep the best accuracy possible. However if the app will do many requests in a short time it might display location updates very often which can be intrusive for some users.
You can disable this behaviour by setting the setLocationUpdatesEnabled on the HyBid class:
Swift:
HyBid.setLocationUpdates(Bool)
Objective-C:
[HyBid setLocationUpdates:BOOL];
If you want to improve targeting, first configure the HyBidTargetingModel
object that you want to pass on and then invoke the following method:
Swift:
var targeting = HyBidTargetingModel()
targeting.age = <AGE>
targeting.interests = <ARRAY_OF_THE_INTERESTS>
targeting.gender = "<GENDER>" // "f" for female, "m" for male
HyBid.setTargeting(targeting)
Objective-C:
HyBidTargetingModel *targeting = [[HyBidTargetingModel alloc] init];
targeting.age = <AGE>;
targeting.interests = <ARRAY_OF_THE_INTERESTS>;
targeting.gender = "<GENDER>"; // "f" for female, "m" for male
[HyBid setTargeting:targeting];
You can control the level of log that you want to see in your console. As default HyBidLogger
is set to HyBidLogLevelDebug
. There are 5 HyBidLogLevels;
- HyBidLogLevelNone
- HyBidLogLevelError
- HyBidLogLevelWarning
- HyBidLogLevelInfo
- HyBidLogLevelDebug
If you want to set a different HyBidLogLevel in your app, the best place is to do it in the HyBid initialization part.
Swift:
HyBid.initWithAppToken("<YOUR_APP_TOKEN_HERE>") { (success) in
if (success) {
HyBidLogger.setLogLevel(HyBidLogLevelDebug)
print("HyBid Successfully Initialized")
}
}
Objective-C:
[HyBid initWithAppToken:@"<YOUR_APP_TOKEN_HERE>" completion:^(BOOL success) {
if (success) {
[HyBidLogger setLogLevel:HyBidLogLevelDebug];
NSLog(@"HyBid initialisation completed");
}
}];
SKAdNetwork
is an attribution solution introduced by Apple. It validates advertiser-driven app installations without disclosing user-level data. With the iOS 14 update, the utilization of SKAdNetwork
framework will become more important since IDFA (Apple’s Identifier for Advertiser) is going to be opted-out by default.
- Add each
SKAdNetwork
ID with the keySKAdNetworkIdentifier
as a list to your App'sInfo.plist
under the keySKAdNetworkItems
.
PubNative's SKAdNetwork ID is: TL55SBB4FM.skadnetwork
<key>SKAdNetworkItems</key>
<array>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>TL55SBB4FM.skadnetwork</string>
</dict>
</array>
- Set your AppStore ID
Swift:
HyBid.setAppStoreAppID("NUMERIC_APPSTORE_ID_HERE")
Objective-C:
[HyBid setAppStoreAppID:@"NUMERIC_APPSTORE_ID_HERE"];