Have you ever wondered how you could manage ads and premium users in the same app? How great would it be if ads could be linked to an IAP mechanism?

To make managing premium accounts easier, we’re excited to announce In-App Purchase Ad Removal Prompt for iOS. It is a new handy feature in the Appsfire iOS SDK that lets you prompt users to go premium after they have dismissed ads in your application.

This is how it works:
1. You choose the prompt frequency, either based on the number of days between ad impressions or on the number of ad dismissed.
2. When the user dismisses ads and the capping is reached, we prompt him about the premium option and IAP available.
3. Depending on the user decision, we drive him to your in-app purchase logic and mechanism.

Grab our latest iOS SDK in order to use this new feature.

Integrating the In-App Purchase Ad Removal Prompt

You will first need to import the AFAdSDKIAP class which will include all the necessary headers.

#import "AFAdSDKIAP.h"

Instantiate a AFAdSDKIAPProperty object which will allow you to configure the properties and frequencies of the alert view.

AFAdSDKIAPProperty *property = [AFAdSDKIAPProperty propertyWithBlock:^(AFAdSDKIAPProperty *property) {
  property.title = @"Remove Advertisement";
  property.message = @"Do you want to purchase the premium version of the app and remove ads?";
  property.cancelButtonTitle = @"Skip";
  property.buyButtonTitle = @"Buy ($0.99)";
  property.buyBlock = ^{
    // Code that will be executed when the user will tap the "Buy" button.
}];

For a complete list of the available properties please check the AFAdSDKIAPProperty.h header file. Here is the list of the frequency cappings:


Capping Name
Description
daysCountUntilFirstPrompt
Number of days until the first UIAlertView is displayed.
daysCountBeforeReminding
Number of days before displaying the UIAlertView again after the user tapped on the "Cancel" button.
dismissCountUntilFirstPromptModal
Number of times modal ads like Sushi or Uramaki are dismissed and after which the first UIAlertView should be displayed.
dismissCountBeforeRemindingModal
Number of modal dismiss before displaying the UIAlertView again after the user tapped on the "Cancel" button.
displayCountUntilFirstPromptSashimi
Number of Sashimi display after which first the UIAlertView should be displayed.
displayCountBeforeRemindingSashimi
Number of Sashimi display before showing again the UIAlertView after the user tapped on the "Cancel" button.
dismissCountUntilFirstPromptUdonNoodle
Number of times Udon Noodle is dismissed and after which the first UIAlertView should be displayed.
dismissCountBeforeRemindingUdonNoodle
Number of Udon Noodle dismiss before displaying the UIAlertView again after the user tapped on the "Cancel" button.

After configuring your property, you will need to apply it. This is done via the -setProperty:andError method. The error parameters will let your know if something went wrong with the property you just provided.

NSError *error;
[AFAdSDKIAP setProperty:property andError:&error];

if (error) {
  // Check why setting the property failed.
}

The buyBlock block is executed when the user taps on the "Buy" button, this will be the moment for you to proceed with your in-app purchase to remove ads. At the end of the process, if the user bought the option, you will need to disable the in-app purchase ad removal prompt. This is done via -setProperty:andError by passsing nil to the property:

[AFAdSDKIAP setProperty:nil andError:nil];

Example


// Creating a property. AFAdSDKIAPProperty *property = [AFAdSDKIAPProperty propertyWithBlock:^(AFAdSDKIAPProperty *property) { property.title = @"Remove Advertisement"; property.message = @"Do you want to purchase the premium version of the app and remove ads?"; property.cancelButtonTitle = @"Skip"; property.buyButtonTitle = @"Buy ($0.99)"; // Those capping parameters are optional, you may want to use the default ones, see the header file. // Time based capping applied to all the formats. property.daysCountBeforeReminding = 7; property.daysCountUntilFirstPrompt = 7; // Sushi & Uramaki property.dismissCountUntilFirstPromptModal = 10; property.dismissCountBeforeRemindingModal = 10; // Udon Noodle property.dismissCountUntilFirstPromptUdonNoodle = 10; property.dismissCountBeforeRemindingUdonNoodle = 10; // Sashimi property.displayCountUntilFirstPromptSashimi = 100; property.displayCountBeforeRemindingSashimi = 100; property.buyBlock = ^{ // Insert your code to trigger the purchase of your in-app purchase option to remove ads. // At the end of the purchase, do not forget to disable the in-app purchase ad removal // prompt via `[AFAdSDKIAP setProperty:nil andError:nil];` }; }]; // Setting the property. [AFAdSDKIAP setProperty:property andError:&error]; if (error) { NSLog(@"In-app purchase property not valid : %@", error); }

Testing

In order to test you alert view configuration you can activate the debug:

[AFAdSDKIAP setDebugModeEnabled:YES];

When activating the debug mode, the alert view is always displayed after:
- a Sushi, Uramaki or an UdonNoodle has been dismissed.
- a Sashimi has been viewed.

Please do not forget to remove this for your production builds.

Disabling reminder

By default the reminder mechanism is enabled. If you want to disable it and only display the alert view once, you may want to set the shouldRemind property to NO:

property.shouldRemind = NO;