views:

233

answers:

0

I am having trouble connecting to the AppStore from within my application. Everything runs fine in the Simulator but when I run on device the app cannot connect to the Appstore.

Here is the code that connects to the Appstore

#import "BuyController.h"#import "InAppPurchaseManager.h"
#import "SKProducts.h"
#define kInAppPurchaseProUpgradeProductId @"com.vigyaapan.iWorkOut1"

@implementation BuyController

- (IBAction)buy:(id)sender{             
    /* get the product description (defined in early sections)*/
    //[self requestProUpgradeProductData];
    if ([SKPaymentQueue canMakePayments])
    {

        InAppPurchaseManager *Observer = [[InAppPurchaseManager alloc] init];
        [[SKPaymentQueue defaultQueue] addTransactionObserver:Observer];            //NSURL *sandboxStoreURL = [[NSURL alloc]initWithString:@"http://sandbox.itunes.apple.com/verifyReceipt"];          //[[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"http://sandbox.itunes.apple.com"]];
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://phobos.apple.com/WebObjects/ com.vigyaapan.iWorkOut1?id=9820091347&;amp;amp;amp;amp;mt=8"]];
                    //[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=301349397&;amp;amp;amp;amp;mt=8"]];
        SKPayment *payment = [SKPayment paymentWithProductIdentifier:@"com.vigyaapan.iWorkOut1"];
        [[SKPaymentQueue defaultQueue] addPayment:payment];
    }
    else
    {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"MyApp" message:@"You are not authorized to purchase from AppStore"
        delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
        [alert show];
        [alert release];
    }
    //return [SKPaymentQueue canMakePayments];} SKPayment *payment = [SKPayment paymentWithProductIdentifier:kInAppPurchaseProUpgradeProductId];
    [[SKPaymentQueue defaultQueue] addPayment:payment]; 
    //[self requestProUpgradeProductData];  /* get the product description (defined in early sections)*/
}
@end