Iphone iAp [response.products count] is empty - iphone

Thats the problem - i have no products in my response for the iAp products.
I've read many themes about it here, at stackoverflow, plus here:
http://troybrant.net/blog/2010/01/invalid-product-ids/
And its all "YES". But it still wont work.
My appid iAps is ON, my provisioning new, my iapps connected to the App, and Cleared for sale, so...
Please, help.
PS. All the identifiers, that i've sent, returns me in the response.invalidProductIdentifiers array
PPS. itunes connect account was linked in Australia. (But in the account all stores was included for selling)
- (void)sendProductRequest:(NSString *)ID {
SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithObject:ID]];
request.delegate = self;
[APPDELEGATE increaseNetworkUseCount];
[request start];
}
- (void)sendProductRequestForCourseTests {
[self sendProductRequest:#"au.bla.blabla.blablabla.inapptesting"]; // for example. 100% matching with my productID at itunes connect
}
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
for (int i = 0; i < [response.invalidProductIdentifiers count]; i ++) {
NSLog(#"%#", [response.invalidProductIdentifiers objectAtIndex:i]); // here we have my Product id
}
DbgLog(#"Products count in received responce: %d", [response.products count]); // here i've got Zero!
SKProduct* product = [response.products count] > 0 ? [response.products objectAtIndex:0] : nil;
if (product) {
//NSString *storeProductID = myProduct.productIdentifier;
//SKPayment *payment = [SKPayment paymentWithProductIdentifier:storeProductID];
SKPayment *payment = [SKPayment paymentWithProduct:product];
DbgLog(#"Payment request sent for product with id: %#", product.productIdentifier);
[[SKPaymentQueue defaultQueue] addPayment:payment];
} else {
[APPDELEGATE decreaseNetworkUseCount];
for (id <IAPManagerObserver> observer in observers) {
[observer IAPManager:self didFinishSuccessfully:NO withTransaction:nil];
}
}
[request autorelease];
}

check below points,
Does your project’s .plist Bundle ID match your App ID
Are you using the full product ID when when making an SKProductRequest
This is the normal scenario issue. Please check this items, it should resolve the issue.

Related

GData Objective-C Client Contact Service

I downloaded the last GData client via SVN https://code.google.com/p/gdata-objectivec-client/
I succesfully compiled it and I integrated successfully the static library inside my project.
I need to retrieve all gmail contacts about a google username:
- (GDataServiceGoogleContact *)contactService {
static GDataServiceGoogleContact* service = nil;
if (!service) {
service = [[GDataServiceGoogleContact alloc] init];
[service setShouldCacheResponseData:YES];
[service setServiceShouldFollowNextLinks:YES];
}
// update the username/password each time the service is requested
NSString *username = usr.text;
NSString *password = psw.text;
[service setUserCredentialsWithUsername:username
password:password];
return service;
}
- (IBAction)getContacts:(id)sender; {
GDataServiceGoogleContact *gc =[self contactService];
NSURL *feedURL = [GDataServiceGoogleContact contactFeedURLForUserID:usr.text];
GDataServiceTicket *ticket;
ticket = [gc fetchFeedWithURL:feedURL
delegate:self
didFinishSelector:#selector(ticket:finishedWithFeed:error:)];
[self startLoading];
}
The callback selector looks like this:
- (void)ticket:(GDataServiceTicket *)ticket finishedWithFeed:(GDataFeedContact *)feed
error:(NSError *)error {
[self stopLoading];
if (error == nil) {
NSArray *entries = [NSArray arrayWithArray:[feed entries]];
if ([entries count] > 0) {
for (GDataEntryContact *firstContact in entries) {
NSString *name = [((GDataNameElement*)[[firstContact name] fullName]) stringValue];
NSString *email = ([firstContact emailAddresses] != nil && [[firstContact emailAddresses] count]!=0) ? [[[firstContact emailAddresses] objectAtIndex:0] stringValueForAttribute:#"address"]: NSLocalizedString(#"not found",#"");
if (name == nil) {
name = email;
}
BBGmailContact *tmpContact = [[BBGmailContact alloc] initWithName:name email:email];
[contacts addObject:tmpContact];
[self.navigationController popViewControllerAnimated:YES];
}
[gmailDelegate contactsDidDownload:contacts];
} else {
[self createAlertView:NSLocalizedString(#"Warning", #"") message:NSLocalizedString(#"No contact found", #"")];
}
} else {
[self createAlertView:NSLocalizedString(#"Error", #"Error") message:NSLocalizedString(#"Please, check your user and password", #"")];
}
}
Why is every entry of entries a kind of class: GDataEntryBase instead GDataEntryContact?
Where is my error? Can someone help me?
Entries are created as GDataEntryBase if the application does not have the service-specific classes for Contacts compiled and linked into the app.
Be sure too that the appropriate build flags for the Contacts service are specified as described in the docs.

In-app purchase, show products but nothing happens

I am trying to implement IAPs in one app but I'm still having difficulties with it. I followed various tutorials but all of them are out of date and full of errors. The only one that could work that I found is this one:
But I'm having a problem, the 3 products appear on my tableview but then when I click on one of them nothing happens... cell become blue and that's all... Am I missing something?
Or is that tutorial incomplete?
How do I run the purchase attempt?
Here is my code:
-(void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
[productDetailsList addObjectsFromArray: response.products];
[productDisplayTableView reloadData];
}
-(void)request:(SKRequest *)request didFailWithError:(NSError *)error
{
NSLog(#"Failed to connect with error: %#", [error localizedDescription]);
}
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section
{
return [self.productDetailsList count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *GenericTableIdentifier = #"GenericTableIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: GenericTableIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier: GenericTableIdentifier];
}
NSUInteger row = [indexPath row];
SKProduct *thisProduct = [productDetailsList objectAtIndex:row];
[cell.textLabel setText:[NSString stringWithFormat:#"%# - %#", thisProduct.localizedTitle, thisProduct.price]];
return cell;
}
- (void)viewDidLoad
{
productDetailsList = [[NSMutableArray alloc] init];
productIdentifierList = [[NSMutableArray alloc] init];
for (short item_count=1; item_count <= 5; item_count++) {
[productIdentifierList addObject:[NSString stringWithFormat:#"com.mycompany.myapp.%d", item_count]];
}
SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithArray:productIdentifierList]];
request.delegate = self;
[request start];
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}
You need to have something in the lines of:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([SKPaymentQueue canMakePayments])
{
SKProduct *selectedProduct = [self.productDetailsList objectAtIndex:indexPath.row];
SKPayment *payment = [SKPayment paymentWithProduct:selectedProduct];
[[SKPaymentQueue defaultQueue] addPayment:payment];
}
}
Apple provides a decent step by step guide for handling in app purchases.
The main way to run IAPs involves a few different methods, but there are a few different steps you need to follow when implementing IAPs.
The first of these requirements are protocols. Please include each of the following protocols in your header file.
SKProductsRequestDelegate
SKPaymentTransactionObserver
SKRequestDelegate
You need the request methods:
-(void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
if(response.products.count > 0)
{
SKProduct* product;
for(int i = 0; i<response.products.count; i++)
{
product = [response.products objectAtIndex:i];
if([product.productIdentifier isEqualToString:#"product identifier"])
{
self.currentProduct = product;
[self beginPaymentWithProduct:product];
}
}
}
}
I used the if statement to keep track of which product was being purchased. You will need an if-statement in that for-loop for each product identifier if you have multiple products. Use this later to unlock whatever on completion of the purchase.
You will also need the beginPayment method:
- (void)beginPaymentWithProduct:(SKProduct*)product
{
SKPayment *payment = [SKPayment paymentWithProduct:product];
[[SKPaymentQueue defaultQueue] addPayment:payment];
}
You also need the payment processing methods. I will not post all of them here as this would take far too much space, but I will give you the prototypes.
-(void)requestDidFinish:(SKRequest *)request;
-(void)request:(SKRequest *)request didFailWithError:(NSError *)error;
- (void)recordTransaction:(SKPaymentTransaction *)transaction;
- (void)finishTransaction:(SKPaymentTransaction *)transaction wasSuccessful:(BOOL)wasSuccessful;
- (void)completeTransaction:(SKPaymentTransaction *)transaction;
- (void)restoreTransaction:(SKPaymentTransaction *)transaction;
- (void)failedTransaction:(SKPaymentTransaction *)transaction;
For each of your buttons in your table that are supposed to be purchasing, they will need to perform a method similar to this one on the didSelectRowAtIndex... method:
- (void)buyCoins:(id)sender
{
if([self canMakePurchases])
{
ualRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithArray:[NSArray arrayWithObjects: #"product identifier", nil]]];
[ualRequest setDelegate:self];
[ualRequest start];
}
}
This method will run the product request successfully. If you have all of these components in, you should have no problems.
I have used this code successfully in several apps.

Is the array order of requested products from itunes store always same ? IAP

I request the products from the itunes store with these codes :
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
NSLog(#"Loaded list of products...");
_productsRequest = nil;
NSArray * skProducts = response.products;
for (SKProduct * skProduct in skProducts) {
NSLog(#"Found product: %# %# %0.2f",
skProduct.productIdentifier,
skProduct.localizedTitle,
skProduct.price.floatValue);
}
_completionHandler(YES, skProducts);
_completionHandler = nil;
}
- (void)requestProductsWithCompletionHandler:(RequestProductsCompletionHandler)completionHandler {
_completionHandler = [completionHandler copy];
_productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:_productIdentifiers];
_productsRequest.delegate = self;
[_productsRequest start];
}
When someone press buy button I use this code
[[IAPHelper sharedInstance] requestProductsWithCompletionHandler:^(BOOL success, NSArray *products) {
if (success)
{
SKProduct *product = _products[NUMBER];
[[IAPHelper sharedInstance] buyProduct:product];
}
}];
I know the order of my products and I put their number where I wrote "NUMBER" above. I need to know if this product request's returning array is always in the same order.
Thank you all ...

Twitter Followers in iPhone sdk

How to make twitter followers list in iPhone sdk I m using MGTwitterEngine and when I try the following method:
[_engine getFollowersIncludingCurrentStatus:NO];
I m not getting followers list
USE like [_engine getFollowersIncludingCurrentStatus:YES];
And Call SOAuthEngine method to get list on console
- (void)userInfoReceived:(NSArray *)userInfo forRequest:(NSString *)connectionIdentifier {
NSLog(#"User Info Received: %#", userInfo);
followers = [[NSMutableArray alloc]init];
for (NSDictionary *u in userInfo ) {
Tweet *tweet = [[Tweet alloc]initWithTweetDictionary:u];
[followers addObject:tweet];
[tweet release];
}
[self.tableView reloadData];
}
Tweet is model class which has Dictionary and method like
- (NSString *)tweet {
return [tweets objectForKey:#"text"];
}

in app purchase non consumable product

I have written the following code.
But when i execute this code, i got log, which shows "no products available".
I am unable to find the reason.
-(void)viewDidLoad {
[super viewDidLoad];
if ([SKPaymentQueue canMakePayments])
{
SKProductsRequest *productsRequest=[[SKProductsRequest alloc]initWithProductIdentifiers:[NSSet setWithObject:#"com.cmp.name.prdt"]];
productsRequest.delegate=self;
[productsRequest start];
}
else {
NSLog(#"Parental Control are enabled");
}
}
-(IBAction)btnpurchase
{
NSString* isPurchased = [[NSUserDefaults standardUserDefaults] stringForKey:#"com.cmp.name.prdt"];
if ([#"purchased" compare:isPurchased]==NSOrderedSame)
{
///do some task
}
else
{
SKPayment * payment=[SKPayment paymentWithProductIdentifier:#"com.cmp.name.prdt"];
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
[[SKPaymentQueue defaultQueue] addPayment:payment];
}
}
-(void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
SKProduct *validProduct=nil;
int count=[response.products count];
if (count>0) {
validProduct=[response.products objectAtIndex:0];
}
else if(!validProduct)
{
NSLog(#"no products available");
}
}
-(void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{
for (SKPaymentTransaction *transaaction in transactions)
{
switch (transaaction.transactionState)
{
case SKPaymentTransactionStatePurchasing:
break;
case SKPaymentTransactionStatePurchased:
[[SKPaymentQueue defaultQueue]finishTransaction:transaaction];
[[NSUserDefaults standardUserDefaults] setObject:#"purchased" forKey:#"com.cmp.name.prdt"];
[[NSUserDefaults standardUserDefaults] synchronize];
break;
case SKPaymentTransactionStateRestored:
[[SKPaymentQueue defaultQueue]finishTransaction:transaaction];
break;
case SKPaymentTransactionStateFailed:
if (transaaction.error.code!=SKErrorPaymentCancelled) {
NSLog(#"Error encountered");
}
[[SKPaymentQueue defaultQueue] finishTransaction:transaaction];
break;
default:
break;
}
}
}
Could anyone help me out in this?
You can try out with following piece of code
//PRODUCT REQUEST DELEGATE METHOD
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
NSLog(#"The product request didReceiveResponse :%#",[response description]);
NSLog(#"The products are :%#",[response.products description]);
NSLog(#"The invalidProductIdentifiers are:%#",[response.invalidProductIdentifiers description]);
NSArray *products=response.products;
for(SKProduct *currentProduct in products){
NSLog(#"THE Product price is :%#",currentProduct.price);
NSLog(#"THE Product description is :%#",currentProduct.localizedDescription);
NSLog(#"THE Product title is :%#",currentProduct.localizedTitle);
NSLog(#"THE Product's product identifier is :%#",currentProduct.productIdentifier);
}
}
THIS WILL LOG THE PRODUCT DETAILS REGISTERED ON iTUNES CONNECT IN CONSOLE WINDOW
Unfortunately, Apple does not respond with any useful information about why your purchases do not show up. I would go through this checklist. In my apps, things didn't work for a few days, then the suddenly started working. Be sure your financial info is correct.