简体   繁体   中英

Check if InApp Purchases are Restricted

On the iPhone I can go into General->Restrictions and lock out InApp purchases. On the code side how do I check if the user has done this?

There is a StoreKit class called SKPaymentQueue which has a class method canMakePayments which can tell you if a user can make purchases which you can check

if ([SKPaymentQueue canMakePayments]) {
    // user can make purchases
} else {
    // no purchases can be made, show error
}

The Documentation says:

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