B4A Library Tappx ads service

Discussion in 'Additional libraries, classes and official updates' started by Erel, Mar 14, 2018.

  1. Erel

    Erel Administrator Staff Member Licensed User

    1. Register with Tappx and get an app key: https://www.tappx.com

    2. Download their AAR library and copy it to the additional libraries folder: https://repo1.maven.org/maven2/com/tappx/sdk/android/tappx-sdk/3.1.3/

    3. Add dependencies:
    Code:
    #AdditionalJar: tappx-sdk-3.0.9.aar
    #AdditionalJar: com.google.android.gms:play-services-ads
    4. Add to manifest editor:
    Code:
    CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
    AddPermission(android.permission.INTERNET)
    AddPermission(android.permission.ACCESS_NETWORK_STATE)
    AddApplicationText(
    <!-- Tappx Activities -->
    <
    activity
        android:name=
    "com.tappx.sdk.android.AdActivity"
        android:configChanges=
    "keyboardHidden|orientation|screenSize" />
    <
    activity
        android:name=
    "com.tappx.sdk.android.InterstitialAdActivity"
        android:configChanges=
    "keyboardHidden|orientation|screenSize"
        android:theme=
    "@style/Transparent" />
    <
    activity
        android:name=
    "com.tappx.sdk.android.VideoAdActivity"
        android:configChanges=
    "keyboardHidden|orientation|screenSize" />

    <
    service android:name="com.tappx.sdk.android.TrackInstallIntentService" />

    <!-- AdActivity from Google Play Services,, needed by Tappx -->
    <
    activity
        android:name=
    "com.google.android.gms.ads.AdActivity"
                android:configChanges=
    "keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
        android:theme=
    "@android:style/Theme.Translucent" />
    )
    Replace CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase) with the snippet from firebase integration tutorial if using an older version of B4A.

    5. Code, make sure to update the key:
    Code:
    Sub Globals
       
    Private const TappxKey As String = "Pub-8888-Android-6456"
       
    Private banner As JavaObject
    End Sub

    Sub Activity_Create(FirstTime As Boolean)
       CreateBanner(TappxKey)
       
    Activity.AddView(banner, 00320dip50dip)
    End Sub

    Sub CreateBanner (key As String)
       
    Dim banner As JavaObject
       
    Dim ctxt As JavaObject
       ctxt.InitializeContext
       banner.InitializeNewInstance(
    "com.tappx.sdk.android.TappxBanner"Array(ctxt, key))
       banner.RunMethod(
    "setAdSize"Array("BANNER_320x50"))
       banner.RunMethod(
    "loadAd"Null)
       
    Dim listener As Object = banner.CreateEventFromUI("com.tappx.sdk.android.TappxBannerListener""ad"Null)
       banner.RunMethod(
    "setListener",Array(listener))
    End Sub

    Sub Ad_Event (MethodName As String, Args() As Object) As Object
       
    Dim argsList As List = Args
       
    Log(MethodName & ": " & argsList)
       
    Return Null
    End Sub

    Sub Activity_Pause (UserClosed As Boolean)
       
    If UserClosed Then
           
    If banner.IsInitialized Then
               banner.RunMethod(
    "destroy"Null)
           
    End If
       
    End If
    End Sub
    Depends on JavaObject.
     
    Last edited: Oct 14, 2018
  2. mlc

    mlc Active Member Licensed User

    Thanks Erel.
    Very interesting to promote your app for free.
    I have already uploaded an app with his sdk, today is the first day and in just a few hours I had 1018 impressions of my app for free.

    Here I leave my "Guess-Link", https://www.tappx.com/?h=24b49ecbf874669c8f1ea5c067b98c28
    For every member that integrates his app after registering from my "Guess-Link" I will win extra promotion. 50000 tappix.
     
    Ohanian likes this.
  3. sorex

    sorex Expert Licensed User

    To make this comply with the EU GDPR misery we need to use the current SDK and some additional likes of code.

    But I'm having problems to convert the code to something working.
    (full example code can be found here > https://www.tappx.com/en/manual/?os=and#1_integration_gdpr)

    while the main aim is to use only the lines below based on the setting they select in my privacy policy page

    Code:
    Tappx.getPrivacyManager(context).grantPersonalInfoConsent();

    Tappx.getPrivacyManager(context).denyPersonalInfoConsent();
    I currently try to just display their own disclaimer so that I know that the privacy manager is working.

    Code:
    Tappx.getPrivacyManager(context).checkAndShowPrivacyDisclaimer(activity);
    looking at the .arr file there's a TappxPrivacyManager class.

    So I assumed this should be the code

    Code:
    Dim consentGDPR As JavaObject
    Dim ctxtGDPR As JavaObject
    ctxtGDPR.InitializeContext
    consentGDPR.InitializeNewInstance(
    "com.tappx.sdk.android.TappxPrivacyManager"Array(ctxtGDPR, Null))
    consentGDPR.RunMethod(
    "checkAndShowPrivacyDisclaimer"Null)
    but this gives java.lang.RuntimeException: Constructor not found. on the initializeNewInstance line.

    Can any javaObject expert give some advice on how to make this code working?
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    It should be:
    Code:
    Dim tappx As JavaObject
    tappx.InitializeStatic(
    "com.tappx.sdk.android.Tappx")
    Dim ctxt As JavaObject
    ctxt.InitializeContext
    Dim PrivacyManager As JavaObject = tappx.RunMethod("getPrivacyManager"Array(ctxt))
    'work with privacy manager
     
  5. sorex

    sorex Expert Licensed User

    Thanks, Erel.

    No errors with that method.

    But when I add the following line

    Code:
    PrivacyManager.RunMethod("checkAndShowPrivacyDisclaimer"Array(ctxt))
    nothing shows up BUT no ads are loaded either so I guess it's waiting for that consent grant/deny value.
    (their documentation mentioned that it ignores request untill the consent mode was selected)

    commenting that line and then using

    Code:
    PrivacyManager.RunMethod("grantPersonalInfoConsent"Null)
    makes the ads load again so I guess that's the way it's supposed to work.
     
  6. chris ash

    chris ash Member Licensed User

    Hi @sorex

    I have been reading this one with interest. Would you have a sample project that you could supply that has the basics of getting the adverts working with the GDPR requirements in place?

    I have had a go and managed to get some adverts but I am just a little unsure what I need to put and where.

    Thanks in advance for any assistance

    Kind Regards
    CAsh
     
  7. hookshy

    hookshy Well-Known Member Licensed User

    Do they have interstitials as well?
     
  8. Douglas Farias

    Douglas Farias Expert Licensed User

    hi @Erel.
    thx for the example.
    can you make a sample code, of how add a intersticial with events? closed, ready etc...?

    thank you
     
  9. Erel

    Erel Administrator Staff Member Licensed User

    Where is the Java code?
     
  10. sorex

    sorex Expert Licensed User

    you can use the event callback for that.

    altho it makes more sense to do the load on a button press (go on with next level for example)

    Code:
    Sub tappxInterstitial_Event (MethodName As String, Args() As Object) As Object
        
    Select MethodName
            
    Case "onInterstitialShown"
                tappxInterstitialLoad
         
    End Select
    Return Null
    End Sub
     
    Douglas Farias likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice