简体   繁体   中英

iOS: How to check if In-App purchase enabled?

There are some function to check if user enable some feature. Just like location or camera roll.

But, how to check if In-App purchase enabled?

this may help on you:

Swift

if SKPaymentQueue.canMakePayments() {

    // you can, so start adding the payment to the payment queue
} else {

    // you may not, handle the rejection
}

ObjC

if ([SKPaymentQueue canMakePayments]) {

     // you can, so start adding the payment to the payment queue
} else {

     // you may not, handle the rejection
}

it is from the SKPaymentQueue class reference about canMakePayments() class method:

true if the user is allowed to authorize payment. false if they do not have permission.

and further explanation for the same method:

An iPhone can be restricted from accessing the Apple App Store. For example, parents can restrict their children's ability to purchase additional content. Your application should confirm that the user is allowed to authorize payments before adding a payment to the queue. Your application may also want to alter its behavior or appearance when the user is not allowed to authorize payments.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM