如何在整个应用程序中进行应用程序内购买? (从MULTIPLE视图中删除广告) [英] How to carry on In-App Purchase throughout whole app? (Remove ads from MULTIPLE views)

查看:107
本文介绍了如何在整个应用程序中进行应用程序内购买? (从MULTIPLE视图中删除广告)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为应用内购买编写了我的代码来移除广告,但它完美无瑕,但它只适用于我从中移除广告的视图控制器。我希望它能贯穿整个应用程序。我该怎么办?

I have written my code for an In-App Purchase to remove ads and it works flawlessly, except, it only works on the view controller where I removed my ads from. I want it to carry over throughout my whole app. How would I do that?

更好地理解:

我的应用程序中的几个视图控制器上有广告。我有一个信息视图控制器,您可以在其中购买广告的删除。问题是:它不会延续到我的其他视图,就像我回到菜单视图控制器一样。此外,当我返回信息视图时,它仍然有广告,直到我从购买恢复。我不希望用户持续恢复购买。如何使这个工作?

I have Ads on a few view controllers in my app. I have a Information view controller where you can purchase the removal of ads. The thing is : it does't carry over to my other views, as if I go back to the menu view controller. Also, when I go back into the Information view, it still has the ad until I restore from purchases. I don't want the users to continuously restore purchases. How do get this to work?

推荐答案

Daniel Storm的回答是正确的。下面是Swift等价物:

Daniel Storm's answer is correct. Below is the Swift equivalent:

let defaults = NSUserDefaults.standardUserDefaults()

if !defaults.boolForKey("removeAds") {
    // Not Purchased.
}

// Upon the successful purchase of your IAP, you set the key to true.
defaults.setBool(true, forKey: "removeAds")

// Save your changes.
NSUserDefaults.standardUserDefaults().synchronize()

我建议关注Objective- C语法,这样你就可以在将来自己翻译这样的东西。这很简单,阿米特。 Mark Daniel的回答是正确的。

I would recommend touching up on Objective-C syntax so you can translate things like this yourself in the future. It's fairly simple, Amit. Mark Daniel's answer as correct.

这篇关于如何在整个应用程序中进行应用程序内购买? (从MULTIPLE视图中删除广告)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆