B4i Library iAd library

This library allows you to integrate Apple's iAD services in your app.

SS-2015-01-19_10.23.05.png


Before you can use this service you need to agree to Apple's terms in iTunes Connect and set the bank and tax details.
Usage example:
B4X:
Sub Process_Globals
   Public App As Application
   Public NavControl As NavigationController
   Private Page1 As Page
   Private iad As AdBannerView
End Sub

Private Sub Application_Start (Nav As NavigationController)
   NavControl = Nav
   Page1.Initialize("Page1")
   Page1.Title = "Page 1"
   Page1.RootPanel.Color = Colors.White
   NavControl.ShowPage(Page1)
   iad.Initialize("iad", iad.SIZE_BANNER)
   Page1.RootPanel.AddView(iad, 0, 100%y - 50dip, 100%x, 50dip)
End Sub

Private Sub Page1_Resize(Width As Int, Height As Int)
   Dim adHeight As Int
   If App.iPadDevice Then
     adHeight = 66dip
   Else
     If Width > Height Then 'landscape
       adHeight = 32dip
     Else
       adHeight = 50dip
     End If
   End If
   iad.SetLayoutAnimated(0, 1, 0, 100%y - adHeight, 100%x, adHeight)
End Sub
Sub iAD_ActionBegin
   Log("action begin")
End Sub
Sub iAD_ActionFinish
   Log("action finish")
End Sub
Sub iAD_FailedToReceiveAd (ErrorCode As String)
   Log("Error: " & ErrorCode)
End Sub
Sub iAD_ReceiveAd
   Log("Received ad")
End Sub

You must set the correct size in Page_Resize event as done in the above code.
When the user presses on an ad the full ad will either be displayed inside your app or in the browser. If the app is displayed inside your app then the ActionBegin and ActionFinish events will fire when the ad is visible. You can use these events to "pause" your app while the app is displayed.

Test ads will show automatically when the app is signed with a non-store certificate.

Library installation

The zip file contains three files with the following extensions: .xml, .a and .h.
You need to copy the xml file to the internal libraries folder on the Windows computer.
If you are using a local Mac builder then you need to copy the .a and .h files to the Mac Libs folder.
 

Attachments

  • iAD.zip
    9.9 KB · Views: 77

Hypnos

Active Member
Licensed User
Longtime User
Thank you Erel!

Hi ilan, please share with us if you know which one got better result (Admob vs iAD). Thanks!
 

ilan

Expert
Licensed User
Longtime User
erel, i have added iad and its working...

i will upload soon a new app incl. source code (its a simple one someone ask me here to do if i will have the time for it)
 
Last edited:

John Decowski

Member
Licensed User
Longtime User
how do I link my account to my app? where do I just put the key/certificate files i downloaded from apple? Or is it something i simply link in iTunes connect? sorry new to iad.
 

ilan

Expert
Licensed User
Longtime User
hi, i have one question please.
i am using on 2 of my apps the iAD lib
i have uplaoded them about 3 month ago and i have just noticed that the only ad i see is "You are connected to iAD"
as on the screenshot on the first post

no other ads are coming, do i need to set anything ? i wanted to update those apps and they were rejected from apple with the following reason:

We found that your app uses the iOS Advertising Identifier but does not include ad functionality. This does not comply with the terms of the iOS Developer Program License Agreement, as required by the App Store Review Guidelines......

what have i missed?
 

ilan

Expert
Licensed User
Longtime User
i think i know why...

...Therefore, your development and ad hoc builds will only display test advertisements. Only the distribution build that is submitted to the App Store will display real ads. Unfortunately, that means that you'll need to wait and download your own application from the store to see real ads in action in your application....
 

ilan

Expert
Licensed User
Longtime User
still a problem

apple dont want to accept my app because:

Hi,

To reiterate, iAd does not use the IDFA. This means that iAd does not use the AdSupport framework, ASIdentifierManager, or the Advertising Identifier. These are currently included in your app's binary, but should not be included in your app.

Please check your code - including any third-party libraries - to remove any instances of:

class: ASIdentifierManager
selector: advertisingIdentifier
framework: AdSupport.framework

We are unable to proceed with our review until your app is no longer using the IDFA by removing the instances above.

A previous build of your app being out of compliance is not a reason for this version submitted to be. Please make these changes before resubmitting.

Best Regards,

App Store Review

only iAd lib is checked! (iAdmob is unchecked)

the app was accepted once by apple now after changing only one line that does not have anything to do with iAD they dont want to accept it
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
iAdMob is the only library that uses the AdSupport.framework.

Compile your app in release mode. On your Mac go to the project folder -> Payload - app file -> Show Package Contents.

Copy the executable file to another folder and open a terminal at that folder.

Now run:
nm <executable file> | grep adver

Or ASI instead of adver.

Does it find any reference?
 

ilan

Expert
Licensed User
Longtime User
iAdMob is the only library that uses the AdSupport.framework.

Compile your app in release mode. On your Mac go to the project folder -> Payload - app file -> Show Package Contents.

Copy the executable file to another folder and open a terminal at that folder.

Now run:
nm <executable file> | grep adver

Or ASI instead of adver.

Does it find any reference?


hi erel, i did what you said and no reference where found with ASI or adver

i send you the file so you can check by your self (maybe i did somthing wrong)

if there is no such reference what do they want from me??
 

Attachments

  • mb.zip
    426.9 KB · Views: 4

ilan

Expert
Licensed User
Longtime User
2 of my apps that uses iAD (they are the only one) where rejected, i tested also the other one and no references!

scr1.jpg
 
Top