[SOLVED] Problem with plugin-x iOS IAP

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

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);

Thanks @hzlov , but the _productArray value is still nil

why there’s no implementation of the following function

-(void) configDeveloperInfo: (NSMutableDictionary*) cpInfo{
}

@hzlov please help me :frowning:

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'

Finally i found the problem :slight_smile:

-(void) configDeveloperInfo: (NSMutableDictionary*) cpInfo{
    
    [self requestProducts :[cpInfo objectForKey:@"iapKey" ]];
    
}