iOS - 应用内购买和应用程序已变为活动状态
我正在使用后台方法开发 4.0 的应用程序。我正在使用每次启动应用程序时递增的数字来更新用户默认值。看起来在 4.0 中 didFinishLaunchingWithOptions 不会在每次启动应用程序时触发,只有在第一次启动时(如果它尚未在后台)才会触发。所以现在,我的用户默认值是在 applicationDidBecomeActive 方法中递增。不确定这是不是正确的地方。我对 Flurry Analytics 和其他一些我想在每次“启动”应用程序时实例化的东西做了同样的事情。
我注意到在应用内购买期间 applicationDidBecomeActive 方法会触发两次。它不仅错误地增加了我的用户默认值,就像重新启动应用程序一样,它还重新初始化 flurry 和 applicationDidBecomeActive 方法中的其他项目。
我做错了什么?每次“启动”应用程序时我是否应该使用另一种方法?
谢谢, 豪伊
I'm working on an app for 4.0 using the background methods. I'm updating the user defaults with a number that is incremented each time the app is launched. Looks like in 4.0 didFinishLaunchingWithOptions doesn't fire each time the app is launched, only the first time it's launched if it's not already in the background. So right now, my user default is incrementing within the applicationDidBecomeActive method. Not sure if this is the right place. I did the same thing with Flurry Analytics and some other stuff that I want to instantiate each time the app is "launched".
I noticed that during an in-app purchase the applicationDidBecomeActive method fires twice. Not only is it falsely incrementing my user default as if the app was relaunched, it is also reinitializing flurry and the other items in the applicationDidBecomeActive method.
What am I doing wrong? Should I be using another method each time the app is "launched"?
Thanks,
Howie
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许您可以尝试
applicationWillEnterForeground
而不是使用applicationDidBecomeActive
。Maybe you could try
applicationWillEnterForeground
instead of usingapplicationDidBecomeActive
.