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