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

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.

  • 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 "build" or "release" within "Other Linker Flags," but rather the general line above those. 



  • By default, HyprMediate is built to deploy on iOS 8 and above. This allows it to automatically import the Apple frameworks it links with. If your app deploys to iOS 7, manually link WebKit as Optional.

App Transport Security

The HyprMediate SDK requires that you add two App Transport Security dictionary keys to your Info.plist. NSAllowsArbitraryLoads is required for iOS 9 backwards compatibility. 

Open Info.plist, and add the following lines:

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

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


Configuration

Import HyprMediate into your file by including the following statement:

 #import <HyprMediate/HyprMediate.h>

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.

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];

 

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. If you don't have a static identifier, and your app uses Game Center, you can retrieve the user's unique player ID:

	NSString *hyprUserId = [GKLocalPlayer localPlayer].playerID;

You will need to implement HyprMediateDelegate.  

@interface YourHyprMediateDelegateImplementation : NSObject <HyprMediateDelegate>

The required delegate methods are listed below.

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.

 

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

  • No labels