Crash cordova-plugin-inapppurchase


#1

Sometimes my application crashing after restorePurchases or buy.
Only on iOS

@Injectable()
export class Purchaser {

  gotInfo = false;

  constructor(public adv: Advmob) {

  }

  init() {

    InAppPurchase
      .getProducts(['remove_ad', 'fullyearnot'])
      .then((products) => {
        console.log(products);
        this.makeReady(products);
      }, (err) => {
        console.log(err);
      });

  }

  isIt = false;
  functions = [];


  restore() {
    if (this.makeQuery) return;
    else this.makeQuery = true;
    this.onReady().then(() => {

      InAppPurchase
        .restorePurchases()
        .then((purchases) => {
          this.makeQuery = false;
          console.log(purchases);
          for (let p of purchases) {
            if (p.productId == "remove_ad" && (p.state == 3 || p.state == 0)) {
              console.log("disabling");
              this.adv.disable();
            }
          }
        })
        .catch((err) => {
          this.makeQuery = false;
          console.log(err);
        });
    })

  }

  makeQuery = false;

  makeReady(d) {
    console.log("it ready", d, this, this.isIt);
    this.isIt = true;
    for (let f of this.functions) {
      f();
    }
  }

  onReady() {
    return new Promise((ok) => {
      console.log("itReady", this.isIt);
      if (!this.isIt) {
        this.functions.push(ok);
      } else {
        ok();
      }
    });
  }


  buyAd() {
    return new Promise((ok, no) => {
        if (this.makeQuery) return;
        else this.makeQuery = true;
        this.onReady().then(() => {
          InAppPurchase.buy("remove_ad").then(
            () => {
              this.makeQuery = false;
              this.adv.disable();
              ok();
            },
            (e) => {
              this.makeQuery = false;
              no();
            });

        });
      }
    );
  }
}

Error in:

#import <UIKit/UIKit.h>

int main(int argc, char* argv[])
{
    @autoreleasepool {
        int retVal = UIApplicationMain(argc, argv, nil, @"AppDelegate");
        return retVal;
    }

ionic plugins

com.verso.cordova.clipboard 0.1.0 "Clipboard"
cordova-plugin-admobpro 2.25.2 "AdMob Plugin Pro"
cordova-plugin-console 1.0.4 "Console"
cordova-plugin-crosswalk-webview 2.1.0 "Crosswalk WebView Engine"
cordova-plugin-datepicker 0.9.3 "DatePicker"
cordova-plugin-device 1.1.3 "Device"
cordova-plugin-extension 1.5.1 "Cordova Plugin Extension"
cordova-plugin-google-analytics 1.6.0 "Google Universal Analytics Plugin"
cordova-plugin-inappbrowser 1.6.1 "InAppBrowser"
cordova-plugin-inapppurchase 1.1.0 "In App Purchase"
cordova-plugin-network-information 1.2.1 "Network Information"
cordova-plugin-splashscreen 4.0.1 "Splashscreen"
cordova-plugin-statusbar 2.1.3 "StatusBar"
cordova-plugin-whitelist 1.2.2 "Whitelist"
ionic-plugin-deploy 0.6.5 "IonicDeploy"
ionic-plugin-keyboard 2.2.1 "Keyboard"
onesignal-cordova-plugin 2.0.10 “OneSignal Push Notifications”

ionic info

Your system information:

Cordova CLI: 6.3.1
Ionic Framework Version: 2.0.0-rc.5
Ionic CLI Version: 2.1.18
Ionic App Lib Version: 2.1.9
Ionic App Scripts Version: 1.0.0
ios-deploy version: 1.9.0
ios-sim version: 5.0.11
OS: macOS Sierra
Node Version: v6.9.2
Xcode version: Xcode 8.2.1 Build version 8C1002