关于iOS内支付。个人认为比较重要的一个就是Bundle id ,Product id .Bundle id不管在哪来讲都是一个非常重要的东西。
如果itunes connect 里相关设置都已设好。那么接下来可以新建一个项目 。
关于framework不要忘记。Storekit.framework
targets->Summary ->Bundle id 看看是否和itunes connect 里的一致
代理;SKProductsRequestDelegate
NSString *us = [NSString stringWithFormat:@"com.snda.test"]; // NSSet *set = [NSSet setWithObject:us]; _productRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:set]; _productRequest.delegate = self; [_productRequest start]; //开始请求 //回调。 -(void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response { NSArray *myProduct = response.products; if([response.invalidProductIdentifiers count]>0) { //这里主要给一个提示,可能是因为iTunes connect 里没设置好. NSLog(@"invalidProductIdentifiers:%@",response.invalidProductIdentifiers); NSLog(@"the invalidProductIdentifiers error"); NSLog(@"You did not complete all the financial requirements"); NSLog(@"You did not use an explicit App ID."); NSLog(@"You did not use the Provisioning Profile associated with your explicit App ID."); } NSLog(@"Product Count:%d",[myProduct count]); for(SKProduct *product in myProduct) //这里就表示能成功读了产品相关信息。 { NSLog(@"Product localizedTitle:%@" , product.localizedTitle); NSLog(@"Product localizedDescription: %@" , product.localizedDescription); NSLog(@"Product price: %@" , product.price); NSLog(@"Product productIdentifier: %@" , product.productIdentifier); } NSLog(@"productsRequest"); }