0

I've been trying to incorporate in-app purchase to my iOS app, with which users who want to be annoyed with Ad being displayed on the screen can disable those Ads by purchasing the product. The app uses UITabBarController, and the screen on which users can purchase the product is different from the screen users see the Ad - in other words, I use different view controllers set on to different tabs in UITabBarController.

However, when users have completed purchasing the product, they still keep seeing those Ads on the screen, and it's only after the next time when users launch the app that those Ads are completely removed from the screen.

However, Apple documentation infers that they reject an app that forces users to restart the app. I think this includes the situation I'm talking about right now, so I would like to know how to restart the app internally - in other words, I want to restart the app as if it's launched from scratch only within the app, probably by calling UIApplication and its methods or something like that.

How can I restart the app in such a way? Or maybe is it a better way to cope with this purchasing issue? Also, if that can be restarted from within the app, should I write the payment code (SKProductsRequest and SKPaymentTransactionObserver) in the view controller that manages the in-app purchase, or in AppDelegate.m?

I use iOS 7.1 and Xcode 5.1.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Blaszard
  • 30,954
  • 51
  • 153
  • 233
  • 4
    There is no way for you to programatically relaunch an app. Instead solve this issue" "and it's only after the next time when users launch the app that those Ads are completely removed from the screen." Find out why this is the case and then address that. – Gruntcakes Apr 10 '14 at 18:39
  • It's because I have different view controllers set to different tabs in `UITabBarController`. Not sure whether it's feasible, but maybe initialize a new view controller and set it to the appropriate tab? – Blaszard Apr 10 '14 at 19:43
  • You can change tabs, change view controllers, do whatever is necessary. If you have a different VC that comes into play only after the in-app purchase then yes creating that and swapping out the old one is certainly feasible. – Gruntcakes Apr 10 '14 at 20:00
  • Woofbeans, can you post it as your answer? I find that your answer is the most insightful and deserve being accepted, since my actual VC is not just the display/hide ad banner and hence I see it more appropriate to create new VC and set it to the tab. – Blaszard Apr 12 '14 at 00:30

2 Answers2

1

Simply hide the AdBannerView as appropriate. You can set a flag in NSUserDefaults that the user made the purchase and trigger off that when displaying the view with the ads in it.

See: Programmatically hiding Apple iAd ADBannerView

Community
  • 1
  • 1
nsdebug
  • 364
  • 2
  • 8
0

You can also change the frame of the Tabbar & change its height, when user have purchased the app without ads.
And send adbanner to back with sendSubviewToBack method.
Hope this will help you.

Amit Bhavsar
  • 1,273
  • 12
  • 23