Flutter SDK
This guide is intended for developers who want to integrate AdsPostX into their Flutter application. It is assumed that you already have an account with AdsPostX.
If you do not have an account with AdsPostX, you can create one now before continuing.
In addition to the general Flutter environment setup, you will need to install iOS build support tools/Xcode and/or Android build support tools/Android Studio, and Cocoapods, depending on your target platforms.
Minimum deployment target
For iOS: iOS13
For Android: minSDK = 24
Open Terminal and go to the root folder of your Flutter project.
Then enter the following command:
Wait for the Flutter plugin to finish installing in your project.
Integrating adspostx_flutter plugin in your app consists of three steps.
- Initializing AdsPostX
- Loading Offers
- Displaying Offers
Include the AdsPostX initialization code anywhere in the app but make sure to call it before loading & showing offers.
Also, be sure to import 'package:adspostx_flutter/adspostx_flutter.dart'; when you are calling adspostxPlugin functions.
where
Parameter Name | Parameter Type | Description |
accountId | String required | accountId as provided |
init returns a bool value indicating if the call is successful or not and it can also throw an exception in case of errors.
Once the init call is successful, call the load function to load Offers. This must be called before displaying offers.
where
Parameter Name | Parameter Type | Description |
attributes | Map required | attributes and their values you want to send to AdsPostX in the payload. If there are no attributes to send, just send empty "{}". Note: All attributes must be passed based on the supported list below. |
Currently, the following attributes are supported:
Attribute Name | Attribute Data Type |
String | |
firstname | String |
lastname | String |
mobile | String |
confirmationref | String |
amount | double |
currency | String |
paymentType | String |
ccbin | String |
language | String |
country | String |
zipcode | String |
orderid | String |
offerid | String |
loadOffers returns a bool value indicating if the offer is loaded successfully or not and it can also throw an exception in case of errors.
Once init and loadOffers calls are successful, call showOffers to display offers in your app.
where
Parameter Name | Parameter Type | Description |
 |  |  |
presentationStyle | int required | It must have only 2 values. either 0 or 1. where 0 - pop up style and 1 - full screen size. |
isTransparent | bool required | true - transparent background. false - Non-transparent background. |
topMargin | int required | Describes top margin in %. Must be between 0-15.  1st parameter: describes top margin in %. (should be in between >= 0 and <=15)  |
rightMargin | int required | Describes right margin in %. Must be between 0-15. |
bottomMargin | int required | Describes bottom margin in %. Must be between 0-15. |
leftMargin | int required | Describes left margin in %. Must be between 0-15. |
Margins will be calculated based on orientation. If in landscape orientation, margin will be calculated considering the device height. If in portrait orientation, margin will be calculated considering the device width.
After displaying offers, the loadOffers function must be called again before displaying offers again.
showOffers returns a bool value indicating if the offers are shown successfully or not and it can also throw an exception in case of errors.
The default value for Environment is live.
We recommend using test environment only in development, not in production. 
Make sure to call this method before init() call.
setEnvironment returns a bool value indicating if the call is successful or not and it can also throw an exception in case of errors.
By default, Debug Log is disabled.
Enabling Debug Log will give you more debug information related to offers.
We recommend enabling logs only in development - not in production. Make sure to call this method before init() call.
enableDebugLog returns a bool value indicating if the call is successful or not and it can also throw an exception in case of errors.
Also, add the following code to the client application's 'AppDelegate' method supportedInterfaceOrientationsFor window
Open & Navigate to <flutter_client_app>/ios and Open Runner.xcworksapce in XCode.
Navigate to Appdelegate.swift and import AdsPostX
and add the following code.
1) You may encounter min sdk error error in Android while integrating adspostx flutter plugin.
Ans:
change
2) You may encounter the below error in android:
Ans:
add 'maven { url 'https://jitpack.io' }' to repositories along with mavencentral() and google().
3) Getting below error when pod installing in iOS.
Ans:
Set ios13 as min deployment target in pod file. also set min deployment to iOS13 in XCode Project.
If you're running into any issues while going through the integration process, feel free to contact us at help@adspostx.com.