Open a list of my apps in the App Store within my App

前端 未结 2 810
深忆病人
深忆病人 2021-02-14 07:03

I have checked the (Top Paid Apps) sample code from Apple website where you can see all the top apps in the App store, I want to do the same in my app but to show only my apps i

2条回答
  •  灰色年华
    2021-02-14 07:35

    This is pretty easy with the SKStoreProductViewController introduced in iOS 6. With that users can buy your other apps right within the application.

    First add StoreKit.framework to your project. Then find the iTunes URL that links to your apps using iTunes. You can copy the link from the iTunes Store. For example the URL for the Apple apps is http://itunes.apple.com/de/artist/apple/id284417353?mt=12 It contains the iTunes identifier, that you pass to the SKStoreProductViewController.

    Sample code:

    #import "ViewController.h"
    #import 
    
    @interface ViewController ()
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad
    {
        [super viewDidLoad];
        [self showMyApps];
    }
    
    -(void)showMyApps
    {
        SKStoreProductViewController* spvc = [[SKStoreProductViewController alloc] init];
        [spvc loadProductWithParameters:@{SKStoreProductParameterITunesItemIdentifier : @284417353}
                        completionBlock:nil];
        spvc.delegate = self;
        [self presentViewController:spvc animated:YES completion:nil];
    
    }
    
    -(void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController
    {
        [self dismissViewControllerAnimated:YES completion:nil];
    }
    
    @end
    

提交回复
热议问题