Note that there are some explanatory texts on larger screens.

plurals
  1. POunlock content in UINavigationController
    primarykey
    data
    text
    <p>I have built an app that includes an <code>IAP</code> (<code>In App Purchase</code>). The app is built using a <code>UINavigationController</code>. When the user decides to purchase the content, the unlock feature unlocks the content. The user then taps on the back button, and they are taken back to the main menu, where they can then access the rest of the app. All of this works fine.</p> <p>My problem is that when the user goes to an unlocked <code>viewController</code> that is part of the <code>UINavigationController</code>, then returns to the main menu page, the app has cleared its memory of the fact that the user has purchased the unlocked content and (I am assuming) uses the <code>property.enabled = no;</code> attribute that is set in the <code>viewDidLoad</code> method of this initial main menu <code>viewController</code> to re-lock content when the main page is reloaded.</p> <p>So, my question is how can I let the app know that the user has purchased the in-app content, and to keep the content unlocked after the user has strayed from the main menu page?</p> <p>I am thinking that maybe I can declare <code>BOOL appPurchased;</code> in the <code>mainMenuViewController</code>. Then from the newly unlocked <code>viewControllers</code>, include a <code>prepareForSegueMethod</code> that sets the <code>BOOL</code> to <code>YES</code> which will in turn enable the purchased content in an <code>if</code> statement.</p> <p>Something like this:</p> <ol> <li><p>declare <code>BOOL appPurchased;</code> in <code>mainMenuViewController.m</code> after <code>@implementation</code></p></li> <li><p>implement the following method in <code>mainMenuViewController.m</code>:</p></li> </ol> <blockquote> <pre><code>(void) viewWillAppear:(BOOL)animated { if (appPurchased) { [self enableLockedContent]; } else if (!appPurchased){ nil; } } </code></pre> </blockquote> <ol> <li>In <code>UnlockedContentViewController</code>, implement the following method which is connected to a <code>UIButton</code>:</li> </ol> <blockquote> <pre><code>(IBAction)toMainMenu:(id)sender { UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; UIViewController *mainMenu = [mainStoryboard instantiateViewControllerWithIdentifier:@"cover"]; [self.navigationController pushViewController:mainMenu animated:YES]; } </code></pre> </blockquote> <p>I can't figure out how to write <code>MainMenuViewController.appPurchase =YES;</code> in the above <code>(IBAction)toMainMenu:(id)sender</code> method.</p> <p>Is this configuration of sending a <code>BOOL</code> value back to the <code>mainViewController</code> anywhere close to working? Is there a better way?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload