I finally started using sdkbox.
I use Auto installer but it was failed to modified Cococs2dxActivity.java apart from copying jar files.
So i modified manually, now almost working fine.
But after purchase onSuccess is not getting called, item has been purchased that i can see through sdkbox debug lines.
Listeners working fine in loading screen when game starts, for IAP::restore()
But listeners not working in main menu where buy button is there.
I am using version 3.8.1 and sdkbox 0.5.7.1
One more thing i have some code for leaderboard/achievements in AppActivity.java
Okay, so i got it working by removing listener from loading screen at start.
So that means we can have only one listener through out game for IAP?
then how we can restore status of items at beginning of game?
or am i missing something?
Help me out.
And yes i did call IAP::removeListener(); in destructer of my loading screen class.
EDIT:
still onCanceled or onFailure not getting called.
@slackmoehrle Thanks for writing code but i know how to write singleton.
My question was how to handle singleton to current scene.
Suppose take below example,
void IAPSingleton::onSuccess(const Product &p)
{
// if its called from main_menu
MainMenu::getInstance()->onSuccess(p);
// if its called from ingame purchase screen
GamePlay::getInstance()->onSuccess(p);
// etc...
CCLOG("Purchase Success: %s", p.id.c_str());
}
void IAPSingleton::onFailure(const Product &p, const std::string &msg)
{
// if its called from main_menu
MainMenu::getInstance()->onFailure(p, msg);
// if its called from ingame purchase screen
GamePlay::getInstance()->onFailure(p, msg);
// etc...
CCLOG("Purchase Failed: %s", msg.c_str());
}
Because its very important to show appropriate msg popup and animation depend on response.
I hope you got the point.
Just take Touch listener for an example, we can have in all scene, why not same way for IAP listeners?
Its very difficult to use this way. @nite is it same for all sdkbox plugins??