我正在尝试将Tapjoy奖励的视频应用到我的应用程序中,但是它们并没有出现。
private var directPlayPlacement: TJPlacement? = null
private var TJlistener: TJPlacementListener? = null下面是我的initTapJoy()函数:
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);
}这是showTapjoyRewardedVideo()函数:
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
请注意,我已经将我的设备添加为测试设备,它们仍然没有出现,此外,我还要求来自不同国家的人打开奖励视频,因为我认为他们没有适用于我的国家的视频,不起作用。
编辑:我忘了提到,使用上面的代码,另一个名为AppLaunch的默认位置显示为一个模式,这意味着集成起作用了,但是它不适用于奖励的视频。
任何帮助都将不胜感激!
发布于 2020-09-17 05:40:00
解决方案是让我的货币获得TapJoy的批准,我的代码中没有任何错误。
https://stackoverflow.com/questions/63789963
复制相似问题