简体   繁体   中英

TapJoy Rewarded Videos ads not showing

I'm trying to implement Tapjoy Rewarded Videos into my app, however they're not showing up.

private var directPlayPlacement: TJPlacement? = null
private var TJlistener: TJPlacementListener? = null

Here's my initTapJoy() function:

  fun initTapJoy() {
    val connectFlags: Hashtable<String, Any> = Hashtable<String, Any>()
    connectFlags[TapjoyConnectFlag.ENABLE_LOGGING] = "true";
    connectFlags[TapjoyConnectFlag.USER_ID] = AppPreferences.token;

    val callbackTJ = object : TJConnectListener {
        override fun onConnectSuccess() {
            this.tapJoyConnectSuccess()
            Timber.d(TAG, "TapJoy SDK connected");
        }

        override fun onConnectFailure() {
            Timber.d(TAG, "TapJoy SDK not connected");
        }

        fun tapJoyConnectSuccess() {
            Tapjoy.setActivity(activity);
            Tapjoy.setUserID(AppPreferences.token);

            directPlayPlacement = Tapjoy.getPlacement("RewardedVideo", TJlistener)

            TJlistener = object : TJPlacementListener  {
                override fun onRequestSuccess(p0: TJPlacement?) {
                    if (p0 != null) {
                        Timber.i("Tapjoy on request success, contentAvailable: %s", p0.isContentAvailable)
                    } else {
                        initTapJoy()
                    }
                }

                override fun onRequestFailure(p0: TJPlacement?, p1: TJError?) {
                    //activity.toast(getString(R.string.adds_content_empty))
                    Log.d(TAG,"onRequestFailure")
                }

                override fun onContentReady(p0: TJPlacement?) {}

                override fun onContentShow(p0: TJPlacement?) {}

                override fun onContentDismiss(p0: TJPlacement?) {
                    initTapJoy()
                }

                override fun onPurchaseRequest(p0: TJPlacement?, p1: TJActionRequest?, p2: String?) {}

                override fun onRewardRequest(p0: TJPlacement?, p1: TJActionRequest?, p2: String?, p3: Int) { }

                override fun onClick(p0: TJPlacement?) {
                    if (p0 != null) {
                        TapjoyLog.i(TAG, "onClick for direct play placement " + p0.getName())
                    }
                }

            }

            directPlayPlacement?.videoListener = object: TJPlacementVideoListener {
                override fun onVideoStart(p0: TJPlacement?) {}

                override fun onVideoError(p0: TJPlacement?, p1: String?) {
                    activity.toast(getString(R.string.adds_content_empty))
                }

                override fun onVideoComplete(p0: TJPlacement?) {
                    getReward(4)
                }

            }

            //load ad
            if (directPlayPlacement != null) {
                directPlayPlacement!!.requestContent();
            } else {
                Log.d(TAG, "Tapjoy SDK must finish connecting before requesting content.")
            }


        }
    }

    Tapjoy.connect(activity, API_KEY, connectFlags, callbackTJ);

    Tapjoy.setDebugEnabled(true);

}

And this is the showTapjoyRewardedVideo() function:

private fun showTapJoyRewardedVideo() {
        if (directPlayPlacement == null) {
            Log.d(TAG, "Tapjoy: Direct Play placement is null. No direct play video to show")
        }
        if (directPlayPlacement?.isContentAvailable!!) {
            if (directPlayPlacement!!.isContentReady) {
                directPlayPlacement!!.showContent();
            } else {
                Log.d(TAG, "Tapjoy: Video not ready to show")
            }
        } else {
            Log.d(TAG, "Tapjoy: No video to show")
        }

    }

LogCat: http://prntscr.com/udhl8e

Please note that I've added my device as a Test device, they're still not showing up, plus I asked people from different countries to open rewarded videos, as I thought they don't have videos available for my country, didn't work.

EDIT: I forgot to mention that using the above code, another default Placement called AppLaunch was showing up as a modal, meaning that the integration worked, however it doesn't work for the rewarded videos.

Any help would be highly appreciated!

解决方案是让我的货币得到 TapJoy 的批准,我的代码没有任何问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM