简体   繁体   中英

Tapjoy viewDidClose called twice

I am trying to integrate Tapjoy offer wall in my app.

My code:

// Get notifications when Tapjoy views open or close.
    TapjoyConnect.getTapjoyConnectInstance().setTapjoyViewNotifier(new TapjoyViewNotifier()
    {
        @Override
        public void viewWillOpen(int viewType)
        {
            TapjoyLog.i(TAG, "viewWillOpen: ");
        }

        @Override
        public void viewWillClose(int viewType)
        {
            TapjoyLog.i(TAG, "viewWillClose: ");
        }

        @Override
        public void viewDidOpen(int viewType)
        {
            TapjoyLog.i(TAG, "viewDidOpen: ");
        }

        @Override
        public void viewDidClose(int viewType)
        {
            TapjoyLog.i(TAG, "viewDidClose: ");

            TapjoyConnect.getTapjoyConnectInstance().getTapPoints(new TapjoyNotifier() 
            {

                @Override
                public void getUpdatePointsFailed(String arg0) 
                {
                    System.out.println(arg0);

                }

                @Override
                public void getUpdatePoints(String arg0, int arg1) 
                {

                    System.out.println(arg0);
                    System.out.println(arg1);
                    if(arg1 > 0)
                    {
                        AppResources.setValueToShredPrefrences("gold_coins",           
     AppResources.gold_coins + arg1);
                    }
                    AppResources.ShowToast(m_context, "gold coin earned: " + arg1, Toast.LENGTH_SHORT);


                }
            });

            finish();

        }
    });

The problem is that method getUpdatePoints inside viewDidClose always return 1 which means that the user scored one point even if the user didnt do anything.

Further more, when user does something like watch a video after that viewDidClose is called twice, making the user receive two points when he should have get 1 point.

This is testing scenarios, i would be happy to see an example of integrating the Tapjoy offer wall properlly, thanks!

(can't post comments because low reputation)

I've got the same problem, both in that viewDidClose gets called twice and getTapPoints always returns 1. However, I've noticed that it returns 0 until the device completes at least one test offer.

I will update this answer if I discover anything else.

Both issues have disappeared upon moving to another device. This leads me to believe that either a) the device I was using is giving bad identifiers / is otherwise not supported or b) test mode is currently broken.

After enabling test mode for this second device, viewDidClose is again being called twice. The test offer, for one unit of currency, was added to the total that's being sent in getTapPoints (so now every time the view closes I get 4 instead of 1 like I did on the other device, because I'd completed 3 units worth of offers before switching to test mode.)

In conclusion, it appears that the issue of viewDidClose getting called twice is caused by test mode, and getting a value of 1 for getTapPoints is a result of the test offer only being counted once towards your total redeemable value.

Rereading your question, you seem to misunderstand the value that gets sent back when you call getTapPoints. This is the device's cumulative total earned points, not how many points have been earned since it was last called. So if you don't complete any offers, you'll get the same value as you did before. I usually keep a value in my app of the previous total, and then only give the user the difference between that value and what gets returned by getTapPoints.

All of this was done with version 10.1.1 of the tapjoyconnectlibrary.

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