英文:
TapJoy Rewarded Videos ads not showing
问题
我正在尝试将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截图:
LogCat截图
请注意,我已将我的设备添加为测试设备,但它们仍然没有显示出来。而且,我请来了来自不同国家的人打开激励视频,因为我认为可能是因为我的国家没有可用的视频,但也没有成功。
编辑:我忘记提到,使用上面的代码,另一个名为AppLaunch的默认放置会显示为模态窗口,这意味着集成成功,但对于激励视频却不起作用。
任何帮助将不胜感激!
英文:
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!
答案1
得分: 2
解决方法是通过TapJoy获得我的货币审批,我的代码没有问题。
英文:
The solution was to get my currency approved by TapJoy, there was nothing wrong in my code.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论