// // ToyRatePromptHandler.cpp // SteveandMaggieToyApp // // Created by Katarzyna Kalinowska-Górska on 10/09/2020. // #include "ToyRatePromptHandler.h" #include "cocos2d.h" #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) #include "NativeAndroid/RatePromptHandler_android.h" #elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) #include "RatePromptHandler_ios.h" #endif const char* ToyRatePromptHandler::RATE_PROMPT_HANDLER_COUNT_UD_KEY = "RATE_PROMPT_HANDLER_COUNT_UD_KEY"; //void ratePromptHandler_nativePresentPromptIfApplicable(); void ToyRatePromptHandler::countUp(){ int counter = ToyRatePromptHandler::getCounterValue(); if(counter < ToyRatePromptHandler_CounterValue){ ToyRatePromptHandler::setCounterValue(counter+1); } } bool ToyRatePromptHandler::presentRatePromptIfApplicable(){ if(ToyRatePromptHandler::getCounterValue() == ToyRatePromptHandler_CounterValue){ ToyRatePromptHandler::setCounterValue(ToyRatePromptHandler_CounterValue+1); ratePromptHandler_nativePresentPromptIfApplicable(); return true; } return false; } int ToyRatePromptHandler::getCounterValue(){ return cocos2d::UserDefault::getInstance()->getIntegerForKey("RATE_PROMPT_HANDLER_COUNT_UD_KEY", 0); } void ToyRatePromptHandler::setCounterValue(int value){ cocos2d::UserDefault::getInstance()->setIntegerForKey("RATE_PROMPT_HANDLER_COUNT_UD_KEY", value); cocos2d::UserDefault::getInstance()->flush(); }