3
该应用程序是这样的,所有内容只能在用户订阅计划(1个月,3个月,6个月或一年)后才能访问。所以最初当应用程序第一次安装时,出现了购买这些方案的选项。一旦用户选择一个方案并进行购买,他就可以进入。MKStoreKit 4.0自动更新订阅
我在应用程序初始化委托:didFinishLaunchingWithOptions: 在第一个ViewController中,我侦听kProductFetchedNotification通知。一旦我收到我填充界面的所有产品。我还检查订阅是否有效
- (void)viewDidLoad {
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(productFetchSuccesful:) name:kProductFetchedNotification object:nil];
...
if([[MKStoreManager sharedManager] isSubscriptionActive:kFeatureAId]){
[self grantAccess];
}else if([[MKStoreManager sharedManager] isSubscriptionActive:kFeatureBId]){
...
...
}
-(void)productFetchSuccesful:(NSNotification*)notification{
NSArray *products = (NSArray*)[[MKStoreManager sharedManager] purchasableObjectsDescription];
NSLog(@"%@",products);
//*****populate ui
}
一旦接口被填充。每个预约方案相关的UIbuttons被链接到一个IBAction为
-(IBAction)purchaseSubscription:(id)sender{
UIButton *currentBtn = (UIButton*)sender;
switch (currrentBtn.tag) {
case product1Tag:
[[MKStoreManager sharedManager] buyFeature:kFeatureAId
onComplete:^(NSString* purchasedFeature)
{
NSLog(@"Purchased: %@", purchasedFeature);
[self grantAccess];
}
onCancelled:^
{
}];
break;
case product2Tag:
...
...
...
}
}
我在MKStoreKitConfigs.h设置的值已设置OWN_SERVER和共享机密
#define kConsumableBaseFeatureId @"com.mycompany.myapp."
#define kFeatureAId @"1month"
#define kFeatureBId @"7days"
#define kConsumableFeatureBId @"com.mycompany.myapp.005"
#define FishBasket @"FishBasket"
#define SERVER_PRODUCT_MODEL 1
#define OWN_SERVER @"http://testsite.com/demo/itunes"
#define REVIEW_ALLOWED 1
//#warning Shared Secret Missing Ignore this warning if you don't use auto-renewable subscriptions
#define kSharedSecret @"*****"
我都忍了服务器端代码但它似乎并没有工作。数据库中似乎也没有记录任何内容。
我该如何解决这个问题?
如何知道订阅何时完成/更新? http://stackoverflow.com/questions/13083429/mkstorekit-issubscriptionactive-always-return-false/ – Meghan