Skip to content

Instantly share code, notes, and snippets.

View nickreffitt's full-sized avatar

Nick Reffitt nickreffitt

View GitHub Profile
@nickreffitt
nickreffitt / CryptoUtil.java
Created December 4, 2017 14:07
A utility class to verify signatures on a publisher's backend when using Tapdaq's Server-Side Rewarded Callbacks
import com.google.common.base.Strings;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.binary.Hex;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.io.IOException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

Setting the config is now slightly different.

2.5.4 and before:

//Create List of creative types to display
CreativeType[] types = {CreativeType.INTERSTITIAL_PORTRAIT};

//Initialise Tapdaq SDK
Tapdaq.tapdaq().initializeWithConfiguration()
        .withTestAdvertsEnabled(false) //Optional
(TDInterstitialAdvert) =>
(NSString) applicationId
(NSString) targetingId
(NSString) subscriptionId // (optional)
(TDCreative) creative =>
(NSString) identifier
(TDOrientation) orientation // Can be either `TDOrientationPortrait` or `TDOrientationLandscape
(TDResolution) resolution // Can be `TDResolution1x`, `TDResolution2x` or `TDResolution3x`
(TDAspectRatio) aspectRatio =>
(int) width
(TDNativeAdvert) =>
(NSString) applicationId
(NSString) targetingId
(NSString) subscriptionId // (optional)
(NSString) title
(NSString) appName
(NSString) appDescription
(NSString) buttonText
(NSString) developerName
(NSString) ageRating
// example function where arguments 2 and 3 are optional
function example( err, optionalA, optionalB, callback ) {
// retrieve arguments as array
var args = [].slice.call(arguments);
// first argument is the error object
// shift() removes the first item from the
// array and returns it
err = args.shift();