App rejected - Restore Button IAP

Apple wants that you implement a restore purchase for any Non-Consumable purchase that you are selling.

From some button you have to call the sdkbox::IAP::restore(). Also you have to implement the callbacks onRestored(const sdkbox::Product& p) in case that something is restored and onRestoreComplete(bool ok, const std::string &msg) when all the restoration is completed (succesful or not).

Here is what we do for our unlocking inapp purchase:

void CustomIAPManager::onRestoreButton()
{
      restoredSomething = false;
     sdkbox::IAP::restore();
}

//This callback is only called everytime that something is restored, can be 0, 1 or a few times
void CustomIAPManager::onRestored(const sdkbox::Product& p)
{
    CCLOG("Purchase Restored: %s", p.id.c_str());
    if(p.name.compare(INAPPUNLOCKID)==0){
        CustomLockingManager::getInstance()->unlock();
        restoredSomething = true;
        CustomNativeAlert::show("Purchase restored","Your purchase was restored","Fine!");
    }
}

void CustomIAPManager::onRestoreComplete(bool ok, const std::string &msg)
{
    CCLOG("Restoration:%d:%s", , ok, msg.data());
    if(!restoredSomething)
       CustomNativeAlert::show("Restore failed", "Are you sure that you can restore anything?", "Accept");
}

PD. It works for Android and IOS! Just use the same id/name for the product

5 Likes