美文网首页
使用RMStore简化iOS内置付费开发

使用RMStore简化iOS内置付费开发

作者: 陈旭冉 | 来源:发表于2014-06-16 08:24 被阅读1837次

    使用RMStore可以大大简化iOS内置付费的开发工作。

    获取IAP为购买做准备

    NSSet *products = [NSSet setWithArray:@[@"fabulousIdol", @"rootBeer", @"rubberChicken"]];
    [[RMStore defaultStore] requestProducts:products success:^(NSArray *products, NSArray *invalidProductIdentifiers) {
        NSLog(@"Products loaded");
    } failure:^(NSError *error) {
        NSLog(@"Something went wrong");
    }];
    

    购买产品

    [[RMStore defaultStore] addPayment:@"waxLips" success:^(SKPaymentTransaction *transaction) {
        NSLog(@"Product purchased");
        [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"product ID"]; // 将购买信息保存起来
    } failure:^(SKPaymentTransaction *transaction, NSError *error) {
        NSLog(@"Something went wrong");
    }];
    

    Restore已购

    [[RMStore defaultStore] restoreTransactionsOnSuccess:^{
        NSLog(@"Transactions restored");
    } failure:^(NSError *error) {
        NSLog(@"Something went wrong");
    }];

    相关文章

      网友评论

          本文标题:使用RMStore简化iOS内置付费开发

          本文链接:https://www.haomeiwen.com/subject/brcjtttx.html