1

going to app store from app using this code

NSURL *myApplicationURL = [NSURL URLWithString:stringURL];

[[UIApplication sharedApplication]openURL:myApplicationURL];

Now how can i comeback from app store to app using cancel button.

Thanks for help.

Undo
  • 25,519
  • 37
  • 106
  • 129
user1452248
  • 767
  • 2
  • 11
  • 28

3 Answers3

3

Once you exit your Application you have no way to come back automatically, the user has to open the App again.

You can use show a modal SKStoreProductViewController (available on iOS 6) to show the AppStore inside your Application.

picciano
  • 22,341
  • 9
  • 69
  • 82
redent84
  • 18,901
  • 4
  • 62
  • 85
2

It is easy with the SKStoreProductViewController as redent84 answered and it is introduced in iOS 6+. With that users can buy your other apps right within the application.

First add StoreKit.framework to your project and add #import to header file.

Then find the Apple id of the app by going in iTunes connect manage applications and clicking on app will show you apple id and other details and pass that to the SKStoreProductViewController.

Below is the code

#import "ViewController.h"
#import <StoreKit/SKStoreProductViewController.h>

@interface ViewController ()<SKStoreProductViewControllerDelegate>
@end

@implementation ViewController

- (void)viewDidLoad
{
[super viewDidLoad];
[self showMyApps];
}

-(void)AppStoreAction:(id)sender{

NSDictionary *appParameters = [NSDictionary dictionaryWithObject:@"533886215"
                                                          forKey:SKStoreProductParameterITunesItemIdentifier];

SKStoreProductViewController *productViewController = [[SKStoreProductViewController alloc] init];
[productViewController setDelegate:self];
[productViewController loadProductWithParameters:appParameters
                                 completionBlock:^(BOOL result, NSError *error)
{

}];
[self presentViewController:productViewController
                   animated:YES
                 completion:nil];

}

 -(void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController
  {
[self dismissViewControllerAnimated:YES completion:nil];
}

@end

In earlier versions you could link to the App Store: [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://itunes.apple.com/de/artist/apple/id284417353?mt=12"]] but with this once you exit app you cannot go back to your app.

But with this SKProductViewController you can hit cancel button and go back to your app.

Hope it helps.

user1120133
  • 3,244
  • 3
  • 48
  • 90
-1

try this ........You can use a URL scheme if you have control of the web page. Simply add a link using your scheme.

If your scheme is myapp: then:

Return to the app

See this site for a tutorial. http://mobile.tutsplus.com/tutorials/iphone/ios-sdk-working-with-url-schemes/ refer:Return back to iPhone app from safari

Community
  • 1
  • 1
08442
  • 521
  • 2
  • 13