iOS Question B4XPages : Close button doesn't work for InterstitialAd

ykucuk

Well-Known Member
Licensed User
Longtime User
Hello, I'm displaying an InterstitialAd on the B4Xpages main page. When the ad is clicked, it redirects to the ad page, but when I click on the close button, nothing happens. It doesn't close the ad.

The following Google warning appears on the log screen. I'm using it for the first time, and I don't have any knowledge. What should I do?

B4X:
<Google> Status bar could not be hidden for full-screen ad. Ensure that your app is configured to allow full-screen ads to control the status bar. For example, consider whether you need to set the childViewControllerForStatusBarHidden property on your ad's rootViewController.

Can you help me with this issue, please?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Tested with this code:
B4X:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private iad As InterstitialAd
End Sub

Public Sub Initialize
'    B4XPages.GetManager.LogEvents = True
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")
    iad.Initialize("iad", "ca-app-pub-3940256099942544/4411468910")
End Sub

Private Sub Button1_Click
    iad.RequestAd
End Sub

Sub iad_Ready (Success As Boolean)
    If Success Then
        Log("iad is ready.")
        iad.Show(B4XPages.GetNativeParent(Me))
    Else
        Log("Failed to load full screen ad: " & LastException)
    End If
End Sub

Sub iAd_Closed
    Log("closed")
End Sub

Private Sub iad_AdClosed
    Log("adclosed")
End Sub

Private Sub iad_AdOpened
    Log("iad opened")
End Sub

Works fine.
 
Upvote 0

ykucuk

Well-Known Member
Licensed User
Longtime User
Tested with this code:
B4X:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private iad As InterstitialAd
End Sub

Public Sub Initialize
'    B4XPages.GetManager.LogEvents = True
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")
    iad.Initialize("iad", "ca-app-pub-3940256099942544/4411468910")
End Sub

Private Sub Button1_Click
    iad.RequestAd
End Sub

Sub iad_Ready (Success As Boolean)
    If Success Then
        Log("iad is ready.")
        iad.Show(B4XPages.GetNativeParent(Me))
    Else
        Log("Failed to load full screen ad: " & LastException)
    End If
End Sub

Sub iAd_Closed
    Log("closed")
End Sub

Private Sub iad_AdClosed
    Log("adclosed")
End Sub

Private Sub iad_AdOpened
    Log("iad opened")
End Sub

Works fine.
Correct. It's working when the close button is in the middle of the screen. It doesn't work when the close button is in the top right corner.
Please check the attachment.
I thought it was about SafeArea because it seems ad is shown not in the safe area
B4X:
Private Sub B4XPage_Resize (Width As Float, Height As Float)
    #if B4i
    Dim r As Rect = B4XPages.GetNativeParent(Me).SafeAreaInsets
    Root.SetLayoutAnimated(0, r.Left, r.Top, Width - r.Right - r.Left, Height - r.Bottom - r.Top)
    #end if
End Sub
 

Attachments

  • Screenshot 2023-06-15 at 12.15.21 PM.png
    Screenshot 2023-06-15 at 12.15.21 PM.png
    108.6 KB · Views: 87
Upvote 0

ykucuk

Well-Known Member
Licensed User
Longtime User
Are you hiding the status bar? Best to take the code I posted and try to reproduce it.
Hello. I ran the same code you wrote.(b4xsample project) I am not hiding the status bar. The IsStatusBarHidden function returns a false value. I am receiving the following message in the log console.
B4X:
<Google> Status bar could not be hidden for full screen ad. Ensure that your app is configured to allow full screen ads to control the status bar. For example, consider whether you need to set the childViewControllerForStatusBarHidden property on your ad's rootViewController.
 
Upvote 0
Top