ToyRatePromptHandler.cpp
1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//
// 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();
}