Because the development of an application has an in-house payment to advertising function, the method provided by Apple has never been used, and it feels a bit complicated, so we chose a third-party component Parse to solve this problem, which is simple and easy to operate;
To simplify Apple's official payment method, there are only two Block methods in the factory. The following is a simple purchase process:
In the application: didfinishlaunchingwitexceptions: Method of AppDelegate
// Use the product identifier from iTunes to register a handler.[PFPurchase addObserverForProduct:@"ProductID" block:^(SKPaymentTransaction *transaction) { // Write business logic that should run once this product is purchased. }];
Called at the place of purchase
[PFPurchase buyProduct:@"ProductID" block:^(NSError *error) { if (!error) { // Run UI logic that informs user the product has been purchased, such as displaying an alert view. }}];
However, when I test The real machine, The Error Domain = Parse Code = 146 "The operation couldn't be completed. (Parse error 146 .), this error is returned even if a new project is created.
The official website of Parse provides answers to this error because it is not careful enough to ignore the solution for many times: ① it may be that the product ID (ProductID) has a problem or does not exist. ② My problem is that the device cannot be purchased due to jailbreak.
Solution: ① check the ID on itunes;
② Uninstall the Assync plug-in Cydia and restart the device;
③ None of the above. Try another device without jailbreak.
This article from the "fresh wind wave" blog, please be sure to keep this source http://duxinfeng.blog.51cto.com/3911492/1285986