yagoub
December 29, 2014, 10:31am
#1
HI,
i’m using plugin-x iOS IAP and cocos2d-x v3.3 ,my problem is, the following function returns NULL
, and _productArray
value is nil
-(SKProduct *)getProductById:(NSString *)productid{
for (SKProduct * skProduct in _productArray) {
if([skProduct.productIdentifier isEqualToString:productid]){
return skProduct;
}
}
return NULL;
}
Please help me !
Thanks
hzlov
December 29, 2014, 11:52am
#2
You should provide keys of IAP items like below for iOS so that _productArray
caches IAP information.
_inAppPurchase = dynamic_cast<ProtocolIAP*>(PluginManager::getInstance()->loadPlugin("IOSIAP"));
TIAPDeveloperInfo info;
info["iapKey"] = "item_id1, item_id2, item_id3";
_inAppPurchase->configDeveloperInfo(info);
_inAppPurchase->setResultListener(&_result);
yagoub
December 29, 2014, 12:17pm
#3
Thanks @hzlov , but the _productArray
value is still nil
yagoub
December 29, 2014, 12:32pm
#4
why there’s no implementation of the following function
-(void) configDeveloperInfo: (NSMutableDictionary*) cpInfo{
}
@hzlov please help me
yagoub
December 29, 2014, 3:44pm
#5
i have implemented it like this:
-(void) configDeveloperInfo: (NSMutableDictionary*) cpInfo{
_productArray= [[cpInfo objectForKey:@"iapKey" ]componentsSeparatedByString:@","];
}
But now the game crashs, and this is the log screen
-[__NSCFString productIdentifier]: unrecognized selector sent to instance 0x170032480
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString productIdentifier]: unrecognized selector sent to instance 0x170032480'
yagoub
December 30, 2014, 12:32pm
#6
Finally i found the problem
-(void) configDeveloperInfo: (NSMutableDictionary*) cpInfo{
[self requestProducts :[cpInfo objectForKey:@"iapKey" ]];
}