Skip to end of metadata
Go to start of metadata

We do not maintain the support for BlackBerry anymore

Version History

 

 Click Here to Expand Version History!
DateAuthorChangesVersion
29/11/2013JLInitial version1.0.1
09/05/2014DDModified in line with 1.1.01.1.0
28/05/2014DDUpdated to cover 1.1.11.1.1
30/05/2014DDFixed sample code1.1.2
02/07/2014JLAdded auto refresh to SSmaatoAPIBlackBerry 1.1.3

Latest Version

Introduction

This document gives step-by-step instructions on

  • Setup and build the SmaatoSDK for BlackBerry 10 static library project
  • Setup and build the SmaatoSDKSample project
  • Setup up a new BlackBerry 10 cascades application project with the Smaato SDK 1.1.0 for BlackBerry 10.
  • Use SmaatoSDK in the cascades project.

Supported Devices

  • BlackBerry Z10
  • BlackBerry Q10
  • BlackBerry Z30
  • BlackBerry Q5

Supported BB10 OS Versions

  • BlackBerry OS 10.1
  • BlackBerry OS 10.2

Supported Screen Sizes

 

  • 768 x 1280
  • 720 x 1280
  • 720 x 720

 

Development Environment

  • QNX Momentics IDE for Mac OS X 10.2.xxx
  • BlackBerry 10 Native SDK 10.1 or 10.2

 

Project Setup

Setup and build the SmaatoSDKSample project

To setup the SmaatoSDKSample project in Momentics:

  1. Open Momentics with a workspace.
  2. Open File menu and click Import.
  3. Select Existing Projects into Workspace in General section.
  4. Set the ‘root directory’ to the SmaatoSDKSample path on the local disk.
  5. Tick the SmaatoSDKSample project in the Projects list
  6. Click Finish button to import

To build the SmaatoSDKSample project in Momentics

  1. Right click the imported SmaatoSDKSample project in project explorer.
  2. Select Build Configurations
  3. Select Set Active.
  4. Click the targeted build configuration.
  5. Right click the project and click Build Project to build.

Setup new Cascades project

The steps below show how to set up a new Cascades project in Momentics with the Smaato SDK.

  1. Open Momentics with a workspace.
  2. Create a Cascades project: File -> New -> Project -> BlackBerry Project -> Cascades -> Select Any Template -> Follow the wizard to finish
  3. Add standard blackberry platform libraries. Some of these libraries may already be added by the project template. Right-click on project->Configure->Add Library->Standard BlackBerry Library->Next->Tick the following libraries->Next->Finish
      • Qt Core
      • Qt XML
      • Qt Network
      • BlackBerry Data Access
      • BlackBerry Device Info
      • BlackBerry Application Platform
      • BlackBerry System
      • BlackBerry Application Core
      • Pim Lib
  4. Add include directories to all configurations: Right-click on project -> Properties -> C/C++ General -> Paths and Symbols -> Select “GNU C” in Languages -> Add the path below to all the configurations
    • ${QNX_TARGET}/usr/include/qt4 (Momentics does not add this path to the project properly if the project is created with a location containing existing source code. So, this step is necessary to ensure the path is properly set.)

  5. Add SmaatoSDK library: Right-click on project->Configure->Add Library->External Library

    • Put the file path of libSmaatoSDKDevice.a in the Device Library field.

    • Put the file path of libSmaatoSDKSimulator.a in the Simulator Library field.

    • Add SmaatoSDK public folder to the Include Folders list.

  6. Remove unnecessary SmaatoSDK library file entries from the bardescriptor.xml

    • Open bar-descriptor.xml.

    • Select Assets tab.

    • Go through each build configurations and remove the entries of the SmaatoSDK library file added by step 5.

  7. Add permissions to bar-descriptor.xml. Smaato SDK needs the permissions below to be fully functional.

    • Device Identifying Information (read_device_identifying_information) (Mandatory. Required for retrieving device pin. The SmaatoSDK doesn’t request any ad from server if this permission is not granted.)

    • Location (access_location_services) (Optional. Required for requesting current location from the device’s location services.)

  8. Modify the [Project Name].pro file

    • Add LIBS += -lQtLocationSubset (QtLocationSubset is not available in the standard library list. Therefore, it needs to be added to the .pro file.)

 

Use SmaatoSDK in Cascades project

Use SSmaatoAdView for displaying ads

SSmaatoAdView class displays ads and handles touch events and JavaScript function callbacks. It supports ads in one format, Img.

SSmaatoAdView is designed to hide all the implementation details from the sdk user, including ad requests and data processing, touch events handling, JavaScript bridge function callbacks handling, ad view resizing, external application launching and etc.

The user must at least provide an Ad Space Id and a Publisher Id in order to get ads from server.

The user is able to set the size of the SSmaatoAdView directly. The ad will scale to fit the view.

If the ad request failed to return any valid ad from server, the SSmaatoAdView hides itself.

The SSmaatoAdView does not detect device orientation change. The user is responsible for it.

access_internet permission is required for using SSmaatoAdView for Richmedia ads.

Example:

Register SSmaatoAdView for QML in applicationui.cpp

qmlRegisterType<SSmaatoAdView>("smaatosdk", 1, 0, "SSmaatoAdView");

Use SSmaatoAdView in QML

import smaatosdk 1.0
.
.
.
SSmaatoAdView {
id: adView
adSpaceId: "0"
publisherId: "0"
preferredWidth: 768
preferredHeight: 128
viewSize: SSmaatoAdView.AdViewSizeNormal
format: 1
coppa: 0
age: 30
gender: SSmaatoAPI.Male
tags: "motorsport,travel"
queryString: "london,manchester"
zip: "M17 1LB"
autoRefreshPeriod: 0
onAdUpdated: {
if(success) {
// code for success update
} else {
// code for failed update
}
}
}

Detecting orientation change and update ad view

attachedObjects: [
OrientationHandler {
id: orientationHandler
onOrientationChanged: {
if(adView.viewSize ==
SSmaatoAdView.AdViewSizeFullScreenPortrait || adView.viewSize ==
SSmaatoAdView.AdViewSizeFullScreenLandscape) {
if(orientation == UIOrientation.Portrait) {
adView.viewSize =
SSmaatoAdView.AdViewSizeFullScreenPortrait;
} else{
adView.viewSize =
SSmaatoAdView.AdViewSizeFullScreenLandscape;
}
adViewPage.updateAd();
}
}
}
]

Use SSmaatoSDKInfo for the SDK info

SSmaatoSDKInfo class provides access to metadata about the SDK.

Example in C++:

SSmaatoSDKInfo sdkInfo;
QString version = sdkInfo.sdkVersion();
QString name = sdkInfo.sdkName();

Example in QML:
Register SSmaatoSDKInfo for QML in applicationui.cpp

qmlRegisterType<SSmaatoSDKInfo>("smaatosdk", 1, 0, "SSmaatoSDKInfo");
SSmaatoSDKInfo* sdkInfo = new SSmaatoSDKInfo();
qml->setContextProperty("sdkInfo", sdkInfo);

Access SSmaatoSDKInfo properties in QML

import smaatosdk 1.0
Page {
Container {
layout: StackLayout {
}
Label {
text: sdkInfo.sdkVersion
}
Label {
text: sdkInfo.sdkName
}
}
}

Request ads with SSmaatoAPI

SSmaatoAPI class handles the parameters for ad request and retrieves ads from server.

The user must provide a valid Publisher Id and a valid Ad Space Id to get ads from server. If the user does not explicitly set the other parameters, their default values are used or the parameter will not be sent with the request if it doesn't have default value.

Example:

Declare SSmaatoAPI object in header file.

SSmaatoAPI* mApi;

Request ad

mApi = new SSmaatoAPI(“AdSpaceId”, “PublisherId”);
QObject::connect(mApi, SIGNAL(adFetchFinished(QVariant)), this,
SLOT(onAdFetchFinished(QVariant)));
QObject::connect(mApi, SIGNAL(adFetchFailed(SSmaatoAPI::AdFetchError,
QString, QString)), this,
SLOT(onAdFetchFailed(SSmaatoAPI::AdFetchError, QString, QString)));
mApi ->setFormat(SSmaatoAPI:: AdFormatImg);
mApi ->fetchAd();

Handle response

void AdView::onAdFetchFinished(const QVariant& /* SSmaatoAd* */ ad) {
if (!ad.isNull()) {
SSmaatoAd* adptr = ad.value<SSmaatoAd*>();
SSmaatoAd::AdType adtype = adptr->getType();
if (adtype == SSmaatoAd::AdTypeImg) {
adptr->showAd();
showImageView(adptr->getAdImage());
}
}
}
void AdView::onAdFetchFailed(SSmaatoAPI::AdFetchError error, const
QString& code, const QString& message) {
hideAdView(true);
}

Start auto refresh

mApi->setAutoRefreshPeriod(15);

Stop auto refresh

mApi->setAutoRefreshPeriod(0);

or

mApi->stopAutoRefresh();

Re-start auto refresh after it is stopped with stopAutoRefresh()

mApi->startAutoRefresh();

Check auto refresh state

mApi->isAutoRefreshing();

  • No labels