-
Notifications
You must be signed in to change notification settings - Fork 0
/
StoreProductController.m
67 lines (57 loc) · 2.19 KB
/
StoreProductController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//
// StoreProductController.m
// Line0New
//
// Created by line0 on 13-5-2.
// Copyright (c) 2013年 makeLaugh. All rights reserved.
//
#import "StoreProductController.h"
#import "UIDevice+DeviceInfo.h"
@implementation StoreProductController
+ (StoreProductController *)sharedInstance
{
static StoreProductController *storeProductController = nil;
if (!storeProductController)
{
storeProductController = [[StoreProductController alloc] init];
}
return storeProductController;
}
- (void)openAppInAppStoreWithAppId:(NSString *)appId
{
NSString *osVersion = [UIDevice systemVersion];
if ([osVersion compare:@"6.0"] == NSOrderedAscending)
{
NSString *appUrl = [NSString stringWithFormat:@"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=%@",appId];
NSURL *url = [NSURL URLWithString:appUrl];
[[UIApplication sharedApplication] openURL:url];
return;
}
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
SKStoreProductViewController *storeProductViewContorller = [[SKStoreProductViewController alloc] init];
storeProductViewContorller.delegate = self;
NSDictionary *param = @{SKStoreProductParameterITunesItemIdentifier : appId};
[storeProductViewContorller loadProductWithParameters:param
completionBlock:^(BOOL result, NSError *error)
{
if(error)
{
NSLog(@"error %@ with userInfo %@", error, [error userInfo]);
}
else
{
[self.rootViewController presentViewController:storeProductViewContorller
animated:YES
completion:^
{
// [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
}];
}
}];
}
- (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController
{
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
[self.rootViewController dismissModalViewControllerAnimated:YES];
}
@end