void PurchaseManager::init() { if(_init){ return; } #if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID TIAPDeveloperInfo pGoogleInfo; pGoogleInfo["GooglePlayAppKey"] = GOOGLE_APPKEY; if(pGoogleInfo.empty()) { char msg[256] = { 0 }; sprintf(msg, "Google App Key info is empty. PLZ fill your Google App Key info in %s(nearby line %d)", __FILE__, __LINE__); MessageBox(msg, "Google IAP Warning"); } s_protocolIAP = dynamic_cast<ProtocolIAP*>(PluginManager::getInstance()->loadPlugin("IAPGooglePlay")); s_protocolIAP->configDeveloperInfo(pGoogleInfo); #elif CC_TARGET_PLATFORM == CC_PLATFORM_IOS TIAPDeveloperInfo info; s_protocolIAP = dynamic_cast<ProtocolIAP*>(PluginManager::getInstance()->loadPlugin("IOSIAP")); info["iapKeys"] = IOS_PRODUCT_KEYS; s_protocolIAP->configDeveloperInfo(info); #endif #if COCOS2D_DEBUG s_protocolIAP->setDebugMode(true); #endif _init = true; }
void ProtocolIAP::configDeveloperInfo(TIAPDeveloperInfo devInfo) { if (devInfo.empty()) { PluginUtils::outputLog("ProtocolIAP", "The developer info is empty!"); return; } else { PluginJavaData* pData = PluginUtils::getPluginJavaData(this); PluginJniMethodInfo t; if (PluginJniHelper::getMethodInfo(t , pData->jclassName.c_str() , "configDeveloperInfo" , "(Ljava/util/Hashtable;)V")) { // generate the hashtable from map jobject obj_Map = PluginUtils::createJavaMapObject(&devInfo); // invoke java method t.env->CallVoidMethod(pData->jobj, t.methodID, obj_Map); t.env->DeleteLocalRef(obj_Map); t.env->DeleteLocalRef(t.classID); } } }