Adcash SDK for iOS mobile devices
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
AdcashNativeExample
AdcashSDKiOS
AdcashSDKiOS.zip
LICENSE.md
README.md

README.md

Adcash iOS SDK v2.4

Prerequisites

Integration with CocoaPods :

Integration with Cocoapods will be added

Manual Integration :

  1. Download the Adcash iOS SDK and unzip it.
  2. Right click on your project in the Project Navigator menu and select Add Files to "name-of-your-project": Alt text
  3. Select the AdcashSDK folder you just unzipped and press Add. Make sure you choose Copy items if needed. Alt text
  4. Add the -ObjC linker flag to your project by going to Build Settings > Other Linker Flags : Alt text
  5. Build and Run. Your project should start without any errors.

Banners

Here is how you can integrate a banner into your app just in few steps :

  1. Import AdcashSDK.h header file in your view controller's file;
#import<AdcashSDK.h>
  1. Set your view controller to conform to ADCBannerViewDelegate protocol;
   @interface ViewController () <ADCBannerViewDelegate>
   ...
	@end
  1. Add the following code to viewDidLoad: method of your view controllers .m file;
   //Initialize the banner
   ADCBannerView *bannerView = [[ADCBannerView alloc] initWithZoneID:@“<YOUR_ZONE_ID>”
                                                    onViewController:self];

	//Do not translate autoresizing mask into constraints
	bannerView.translatesAutoresizingMaskIntoConstraints = NO;

	//Add your banner as a subview to your view
	[self.view addSubview:bannerView];

	//Add constraints to the banner
	NSDictionary *views = NSDictionaryOfVariableBindings(bannerView);

	//Set banner to take the width of it’s parent view
	[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@“H: | [bannerView] | ”
	                                                                 options:0
	                                                                 metrics:nil
	                                                                 views:views]];


//Set banner to stick to the bottom of it’s parent
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@“V: [bannerView] | ”
                                                                  options:0
                                                                  metrics:nil
                                                                  views:views]];

//Set the banner’s delegate to be your view controller
bannerView.delegate = self;

//Show the banner
[bannerView load];
  1. (Optional) You can catch status updates from your banner by implementing the optional methods in ADCBannerViewDelegate protocol:
    -(void) bannerViewDidReceiveAd: (ADCBannerView *)bannerView;
    -(void) bannerView: (ADCBannerView *)bannerView didFailToReceiveAdWithError:(NSError *)error;
    -(void) bannerViewWillPresentScreen: (ADCBannerView *) bannerView;
    -(void) bannerViewWillLeaveApplication:(ADCBannerView *) bannerView;
    -(void) bannerViewWillDismissScreen: (ADCBannerView *) bannerView;

Interstitials

Here is how you can integrate an interstitial into your app just in few steps :

  1. Import AdcashSDK.h header file in your view controller's file;
#import<AdcashSDK.h>
  1. Declare an interstitial property in your file and make your view controller conform to the ADCInterstitialDelegate protocol. Your interface should look like this;
@interface ViewController : UIViewController <ADCInterstitialDelegate>
@property (nonatomic,strong) ADCInterstitial *interstitial;
@end
  1. Add the following code to the viewDidLoad: method;
//Assign an ADCInterstitial instance to your property.
self.interstitial = [[ADCInterstitial alloc] initWithZoneID:@“<YOUR_ZONE_ID>”];

//Make your view controller a delegate to the interstitial.
self.interstitial.delegate = self;

//Load the interstitial.
[self.interstitial load];
  1. When the interstitial is loaded successfully, you can catch the status update and present to the screen like the following;
-(void) interstitialDidReceiveAd:(ADCInterstitial *)interstitial
{
[interstitial presentFromRootViewController:self];
}
  1. (Optional) You can catch other status updates of your interstitial by implementing the optional methods in ADCInterstitialDelegate protocol;
   -(void) interstitialDidReceiveAd: (ADCInterstitial *)interstitial;
   -(void) interstitial: (ADCInterstitial *)interstitial didFailToReceiveAdWithError:(NSError *)error;
   -(void) interstitialWillPresentScreen: (ADCInterstitial *)interstitial;
   -(void) interstitialWillDismissScreen: (ADCInterstitial *)interstitial;
   -(void) interstitialWillLeaveApplication: (ACInterstitial *)interstitial;

Rewarded Videos

Here is how you can integrate a rewarded video into your app just in few steps :

  1. Import AdcashSDK.h header file into your view controllers file;
#import<AdcashSDK.h>
  1. Declare a rewarded video property in your header file and make your view controller conform to the AdcashRewardedVideoDelegate protocol. Your interface should look like this;
@interface ViewController : UIViewController<AdcashRewardedVideoDelegate>
@property (nonatomic,strong) AdcashRewardedVideo *video;
@end
  1. To load the rewarded video, add the following code to viewDidLoad: method;
//Assign AdcashRewardedVideo instance to your property.
self.video = [[AdcashRewardedVideo alloc] initRewardedVideoWithZoneID:@“<YOUR_ZONE_ID>”];
self.video.delegate = self;
  1. To play the video, call:
[self.video playRewardedVideoFrom:self];

Example below

    -(void)rewardedVideoDidReceiveAd:(AdcashRewardedVideo *)rewardedVideo
    {
        [self.video playRewardedVideoFrom:self];
    }
  1. To use ad events:

(Required)

    -(void)rewardedVideoDidComplete:(AdcashRewardedVideo *)rewardedVideo withReward:(int)reward;
> This method is called when user completed watching rewarded video and it's time to reward the user.
Example below
    -(void)rewardedVideoDidComplete:(AdcashRewardedVideo *)rewardedVideo withReward:(int)reward
    {
        user.coins += reward;
        //or you can disregard "reward" value and use your own, if you have other algorithms
        //to reward the user.
    }

(Optional) You can catch status updates from your video by implementing the optional methods in AdcashRewardedVideoDelegate protocol:

   -(void) RewardedVideoDidReceiveAd: (AdcashRewardedVideo *)video;
   -(void) RewardedVideoDidFailToReceiveAd:(AdcashRewardedVideo *)video withError:(NSError *)error;
   -(void) RewardedVideoWillPresentScreen:(AdcashRewardedVideo *)video;
   -(void) RewardedVideoWillDismissScreen:(AdcashRewardedVideo *)video;
   -(void) RewardedVideoDidDismissScreen:(AdcashRewardedVideo *)video;
   -(void) RewardedVideoWillLeaveApplication:(AdcashRewardedVideo *)video;

Native Advertisements

Native is an ad format that is rendered by the publisher, allowing them to give users a unique experience with finely tuned look and design.

Here is how you can integrate a native ad into your app just in few steps :

  1. Import AdcashSDK.h header file into your view controllers file;
#import<AdcashSDK.h>
  1. Declare a native ad property in your header file and make your view controller conform to the AdcashNativeDelegate protocol. Your interface should look like this;
@interface ViewController : UIViewController<AdcashNativeDelegate>
@property (nonatomic,strong) AdcashNative *native;
@end
  1. To load the native ad, call;
self.native = [[AdcashNative alloc] initAdcashNativeWithZoneID:@“<YOUR_ZONE_ID>”];
self.native.delegate = self;
  1. After loading, if response is successful, native instance is filled with information about the ad, that contains:
>Title

>Description

>Rating

>Icon

>Image

>Action button text

to get these values, you should use the provided functions below:

-(NSString *)getAdTitle;
-(NSString *)getAdDescription;
-(NSString *)getAdRating;
-(NSURL *)getAdIcon;
-(NSURL *)getAdImage;
-(NSString *)getAdButtonText;
  1. To use ad events:
-(void)AdcashNativeAdReceived:(AdcashNative *)native;
-(void)AdcashNativeFailedToReceiveAd:(AdcashNative *)native withError:(NSError *)error;
  1. You should also handle clicks and impressions so monetization won't get affected.

Call the function below, when ad is visible on the screen ;

-(void)trackImpression;

To handle clicks call;

-(void)openClick;

For detailed implementation and examples, check our Example Project.

App Transport Security

With the release of iOS 9, Apple introduced a new default setting, called App Transport Security(ATS). ATS requires apps to make network connection only over SSL. It also allows specific encryption ciphers,SSL version and key length to be used when creating HTTPS connections.

Therefore, all iOS 9 devices running apps built with Xcode 7 that doesn’t disable ATS will be affected by this change. When a non-ATS compliant app attempts to serve an ad via HTTP on iOS 9, the following message appears:

App Transport Security has blocked a cleartext HTTP(http://) resource load since it is insecure. Temporary exceptions can be configured via your app’s Info.plist file.

While Adcash acknowledges the need for secure connections, our ad network is not ready yet with the compliance of the requirements. Therefore, Adcash iOS SDK will work only by disabling App Transport Security in your Info.plist. You can do so by using one of the following two ways depending on your preference:

1.Disable ATS for all domains

This is the easiest solution. Right click on your Info.plist and select Open As > Source Code, then paste the snippet below at the end of the code.

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

It should look like this; Alt text

2.Disable ATS for all domains, with some exceptions

You may only want ATS to work on domains you specifically know can support it. For example, if you knew that your server supports ATS and you would want things like login calls, and other requests to your server to use ATS, but ad requests to Adcash to bypass ATS requirements.

In this case you should set NSAllowsArbitraryLoads to true, then define the URLs that you want to be secure in your NSExceptionDomains dictionary. Each domain you wish to be secure should have its own dictionary, and the NSExceptionAllowsInsecureHTTPLoads for that dictionary should be set to false.

  <key>NSAppTransportSecurity</key>
  <dict>
     <key>NSAllowsArbitraryLoads</key>
     <true/>
     <key>NSExceptionDomains</key>
     <dict>
        <key>secure.yourdomain.com</key>
        <dict>
           <key>NSExceptionAllowsInsecureHTTPLoads</key>
           <false/>
        </dict>
     </dict>
  </dict>

It should look like this; Alt text

If you do not follow the above instructions for apps built on Xcode 7, monetisation will be severely impacted as some connections might fail resulting in the ads not rendering.

License

License

Support

If you need any support or assistance you can contact us by sending email to mobile@adcash.com.