Page tree
Skip to end of metadata
Go to start of metadata

Upgrading from HyprMediate iOS 2.2 to 2.4

Remove the HyprMediate.framework and any ad providers and their HyprAdapter files. Click 'Move to Trash' when removing.

Drag and drop the new 2.4 version of the HyprMediate.framework (available in the SDK disk image) file into your Xcode project. Select "copy items if needed" and "create groups" when prompted.

Verify Target Membership

  1. Select HyprMediate.framework in the Project Navigation tab.

2. From the File inspector tab, ensure that it has been added to your Main Application's build target in the "Target Membership" pane.

Make sure HyprMediate.framework and libxml2.tbd are both listed in linked frameworks for your target.

Replace each ad provider you removed with the latest version from our downloads page.

App Transport Security

Ensure that your ATS (App Transport Security) settings are as described in the ATS section below (these have not changed from 2.2).

Privacy Controls

  • Add the privacy plist key 'Privacy - Photo Library Additions Usage Description' (NSPhotoLibraryAddUsageDescription) to your info.plist file.
  • Add or confirm that info.plist contains the privacy plist keys 'Privacy - Photo Library Usage Description' (NSPhotoLibraryUsageDescription) and 'Privacy - Calendars Usage Description' (NSCalendarsUsageDescription). For more information, see the Privacy Controls section below.

That's it! You're up and running with the latest version of the HyprMediate SDK.



Installation

  • Drag and drop the HyprMediate.framework (available in the SDK disk image) file into your Xcode project, making sure that the files are copied and not just referenced.  

  • Verify Target Membership

     

    1. Select HyprMediate.framework in the Project Navigation tab.

    2. From the File inspector tab, ensure that it has been added to your Main Application's build target in the "Target Membership" pane.

     



  • Visit your project's Build Phases, open "Link Binary with Libraries" and add libxml2.tbd
  • Make sure that HyprMediate.framework is listed.
  • Find the key "Other Linker Flags" in the "Linking" section of your project's build settings. For that key, add the value -ObjC. Make sure not to select just "Debug" or "Release" within "Other Linker Flags," but rather the general line above those. 

App Transport Security

Apple has put on hold their efforts to enforce ATS (App Transport Security) settings, so many developers are simply turning it off. In order to do so, add the App Transport Security dictionary key below to your Info.plist.

	<key>NSAppTransportSecurity</key>
	<dict>
		<key>NSAllowsArbitraryLoads</key>
		<true/>
	</dict>

Your Info.plist will look like this after adding these lines: 

If you prefer to enable ATS, you must add the three App Transport Security dictionary keys below to your Info.plist to ensure HyprMediate operates properly.

	<key>NSAppTransportSecurity</key>
	<dict>
		<key>NSAllowsArbitraryLoads</key>
		<true/>
	    <key>NSAllowsArbitraryLoadsInWebContent</key>
	    <true/>       
	    <key>NSAllowsArbitraryLoadsForMedia</key>
	    <true/>       
	</dict>

Your Info.plist will look like this after adding these lines:

Privacy Controls

iOS requires that the use of a user's camera, calendar, photo library, etc. be declared by advertisers in the plist. In order to maximize fill rate, please add all of the following entries to your app's plist.

<key>NSCalendarsUsageDescription</key>
<string>${PRODUCT_NAME} requests access to the Calendar</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>${PRODUCT_NAME} requests access to the Photo Library</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>${PRODUCT_NAME} requests write access to the Photo Library</string>

Configuration

Import HyprMediate into the file(s) you wish to use it in by including the following statement:

 #import <HyprMediate/HyprMediate.h>

To initialize HyprMediate, use the following code snippet. If you're in AppDelegate.m, we recommend placing it in the didFinishLaunchingWithOptions: method, since that method is called when your app starts.

[HYPRMediate initialize: hyprAPIToken userId: hyprUserId];

Please initialize HyprMediate as soon as possible (i.e. when your application is loading) so preloading will start immediately. We recommend initializing in the AppDelegate.m file.


Your app's API token can be found in App Configuration settings on the HyprMediate Waterfall page. Replace hyprAPIToken with an NSString of that token. 

  

Replace the hyprUserId parameter with any identifier that is static for each user. The hyprUserId is a unique identifier supplied by your application and should be static for each user across sessions. Your hyprUserId should not contain any personally identifiable information such as an email address, screen name, or Apple's Advertising Identifier (IDFA). If you don't have a static identifier, you can use the code snippet below for generating a unique hyprUserId using NSUUID.

NSString *userIdStorageKey = @"hyprMediateUserId";
NSString *userId = [[NSUserDefaults standardUserDefaults] objectForKey:userIdStorageKey];
if (!userId) {
    userId = [[NSUUID UUID] UUIDString];
    [[NSUserDefaults standardUserDefaults] setObject:userId forKey:userIdStorageKey];
    [[NSUserDefaults standardUserDefaults] synchronize];
}
// initialize HYPRMediate with `userId`

You will need to implement HyprMediateDelegate.  

@interface YourHyprMediateDelegateImplementation : NSObject <HyprMediateDelegate>

The required delegate methods are listed in the following sections.

Set your delegate to get callbacks from HyprMediate:

YourHyprMediateDelegateImplementation *delegate = [[YourHyprMediateDelegateImplementation alloc] init];
[HYPRMediate setDelegate: delegate];

Important: The HyprMediate SDK keeps a strong reference to the HyprMediateDelegate you set.  If you implement the HyprMediateDelegate interface with a UIViewController, be sure to set the delegate to nil in the parent UIViewController that is dismissing the delegate, before dismissViewController: is called.

 

Check For Ads, Show Ads

After initializing, HyprMediate will be ready to check if ads are available. This is done before attempting to show an ad.  

// Check if ads are available. HyprMediate will call back your delegate's hyprMediateCanShowAd method when it has an answer for you.
[HYPRMediate checkInventory];

Once you know an ad is available and the user taps on the UI element, you can show the ad.

// Place this method in the event handler used for presenting ads. HyprMediate will call back the delegate methods implemented below.
[HYPRMediate showAd];

Both checkInventory and showAd will call back your HyprMediateDelegate. Implement the following methods on your delegate.

- (void)hyprMediateCanShowAd:(BOOL)adCanBeDisplayed {
    if (adCanBeDisplayed) {
		NSLog(@"HYPRMediate can show an ad.");
    } else {
		NSLog(@"HYPRMediate does not have an ad to show.");
    }
}
- (void)hyprMediateAdStarted {
	// HyprMediate started displaying an ad.
	// This is the appropriate time to pause any background music or game animations.
}

- (void)hyprMediateAdFinished {
	// HyprMediate finished displaying an ad.
	// This is the appropriate time to resume music and animations.
}
 
- (void)hyprMediateRewardDelivered:(HYPRMediateReward *)reward {
	// The user earned a reward. You may deliver it here.
	// If you are using server to server callbacks, this may be a useful time to check in with your servers.
	NSLog(@"User earned %qi %@", reward.virtualCurrencyAmount, reward.virtualCurrencyName);
}

- (void)hyprMediateErrorOccurred:(HYPRMediateError *)error {
	// Something went wrong with the ad display. Look at the error object for more information.
	// See the HYPRMediateErrorType for more information about types of errors.
    NSLog(@"%@", [error description]);
}

NOTE: Using alert views inside of callbacks may cause UI issues with some ad providers. For this reason, we recommend you don't use UIAlertViews in HyprMediate callbacks.

 

Initialization Callbacks (Optional)

If you would like to receive a callback after HyprMediate completes initialization, implement the following method.

- (void)hyprMediateInitializationComplete {
    // HyprMediate has finished initializing
 	// It is now safe to check for ad inventory	
}

That's it! You're up and running with HyprMediate. To add more ad providers, click here.

  • No labels