iOS Question Admob with b4xpages problem

Waldemar Lima

Well-Known Member
Licensed User
Longtime User
i am trying wrap admob banner in b4xmainpage with this code :

B4X:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private ad As AdView
    Private ads_panel As Panel
End Sub

Public Sub Initialize
    
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    

    ad.Initialize("ad", "ca-app-pub-3940256099942544/6300978111 ", Main.PagesManager.MainPage, ad.SIZE_BANNER)
    Root.AddView(ad, ads_panel.Left,ads_panel.Top, 320dip, 50dip)

End Sub

'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.

Sub Button1_Click
    xui.MsgboxAsync("Hello world!", "B4X")
End Sub

Sub Ad_AdScreenDismissed
  
End Sub

Sub Ad_FailedToReceiveAd (ErrorCode As String)
    Log("Failed: " & ErrorCode)
End Sub

Sub Ad_PresentScreen
  
End Sub
Sub Ad_ReceiveAd
  
End Sub

and when i debug show this messages >

B4X:
Application_Start
Error occurred on line: 25 (B4XMainPage)
Expected: UIViewController, object type: b4i_b4xmainpage
Stack Trace: (
  CoreFoundation       7769FFAC-4FCD-332D-A4BE-DA2F0E2FFEA5 + 1250136
  libobjc.A.dylib      objc_exception_throw + 60
  CoreFoundation       7769FFAC-4FCD-332D-A4BE-DA2F0E2FFEA5 + 136476
  FortDay              -[B4IObjectWrapper setObject:] + 276
  FortDay              +[B4IObjectWrapper createWrapper:object:] + 108
  FortDay              -[b4i_b4xmainpage _b4xpage_created::] + 988
  CoreFoundation       7769FFAC-4FCD-332D-A4BE-DA2F0E2FFEA5 + 1277892
  CoreFoundation       7769FFAC-4FCD-332D-A4BE-DA2F0E2FFEA5 + 6096
  FortDay              +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1608
  FortDay              -[B4ICommon CallSubDebug4::::] + 1080
 FortDay              -[B4ICommon CallSubDebug2::::] + 372
 FortDay              -[b4i_b4xpagesmanager _createpageifneeded::] + 1192
 FortDay              -[b4i_b4xpagesmanager _showpage::] + 892
 FortDay              -[b4i_b4xpagesmanager _addpage:::] + 1584
 FortDay              -[b4i_b4xpagesmanager _addpageandcreate:::] + 684
 FortDay              -[b4i_b4xpagesmanager _initialize:::] + 2012
 FortDay              -[b4i_main _application_start:] + 780
 CoreFoundation       7769FFAC-4FCD-332D-A4BE-DA2F0E2FFEA5 + 1277892
 CoreFoundation       7769FFAC-4FCD-332D-A4BE-DA2F0E2FFEA5 + 6096
 FortDay              +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1608
 FortDay              -[B4IShell runMethod:] + 448
 FortDay              -[B4IShell raiseEventImpl:method:args::] + 2172
 FortDay              -[B4IShellBI raiseEvent:event:params:] + 1580
 FortDay              __33-[B4I raiseUIEvent:event:params:]_block_invoke + 60
 libdispatch.dylib    E749B178-A64D-3363-83EF-863A6073A06B + 8500
 libdispatch.dylib    E749B178-A64D-3363-83EF-863A6073A06B + 13740
 libdispatch.dylib    _dispatch_main_queue_callback_4CF + 832
 CoreFoundation       7769FFAC-4FCD-332D-A4BE-DA2F0E2FFEA5 + 706772
 CoreFoundation       7769FFAC-4FCD-332D-A4BE-DA2F0E2FFEA5 + 685452
 CoreFoundation       CFRunLoopRunSpecific + 480
 GraphicsServices     GSEventRunModal + 164
 UIKitCore            UIApplicationMain + 1936
 FortDay              main + 124
 libdyld.dylib        9DB07277-A537-351D-AB86-5408CB5F12C3 + 4996
)
Application_Active

someone can help me ?
 
Top