Getting started

Here is how you can start using our API in 5 minutes.

  • Sign up as a publisher

    http://manager.moonkey.net/signup.html

    sign up moonkey
  • Create a new app

    Fill in your Apple Store URL at My Apps

    new app moonkey
  • Create a new content for your app

    Fill in your content parameters at Contents

    new content moonkey
  • Download iOSMoonkit SDK

    Click on corresponding to your content

    add iOS moonkit
  • Add iOSMoonkit SDK

    Drag & Drop the iOSMoonkit SDK to your app

    Unlock

    Choose the right options

    Unlock

    Link binary

    Unlock
    Add iOSMoonkit to embedded binaries, then let only one in the linked frameworks
  • Add the code to your content

    Moonkey code example below

    
    import iOSMoonkit
    
    /* ... */
    
    class ViewController: UIViewController {
    
    	@IBOutlet var myButton: UIButton!
    
    	override func viewDidLoad() {
    
    		super.viewDidLoad()
    
    		/* ... */
    
    		let moonkeyContent = MoonkeyContent()
    		moonkeyContent.connect(self, parameters: [
    			"clientId" : "1811141408",
    			"contentIdentifier" : "3226246716",
    			"sId" : "22",
    		], onSuccess: callSuccess, onCancel: callCancel, onAccess: callAccess)
    		
    		let moonkeyButton = MoonkeyButton(button: myButton)
    		moonkeyButton.setContent(moonkeyContent)
    	}
    }
    
    func callAccess () {
    	//Your callAccess function
    }
    
    func callSuccess (transactionId:String, accessToken:String) {
    	//Your callSuccess function
    }
    
    func callCancel () {
    	//Your callCancel function
    }
    
    
    

My Button

Here you can choose which can of Moonkey button you want on you app.

UIButton

  • Create your own Moonkey button

    Drag & drop UIButton in your Xcode storyboard

    UIButton
  • Customize it as a call-to-action

    Use the wording "Unlock with Moonkey" (recommended)

    Unlock
    Moonkey button example
  • Link it to your ViewController

    Right click on your button, then drag & drop it to your View Controller
    Give it a name (i.e : myButton)

    
    
    /* ... */
    class ViewController: UIViewController {
    
          @IBOutlet var myButton: UIButton!
    
    /* ... */
    
    
  • Set your button in Moonkey's code

    Use your button's name in the MoonkeyButton function

    
    
    /* ... */	
    let moonkeyButton = MoonkeyButton(button: myButton)
    moonkeyButton.setContent(moonkeyContent)
    
    /* ... */
    
    

UIImageView

  • Choose an image for your button

    Create your own, or use the default Moonkey Button (recommended)

    Moonkey unlock
  • Set an image to create your Moonkey button

    Drag & drop UIImageView in your Xcode storyboard

    UIImageView
  • Add image

    Drag & drop your image in the Assets.xcassets folder
    Assign it to your UIImageView

    Assign Image
  • Link it to your ViewController

    Right click on your button, then drag & drop it to your View Controller
    Give it a name (i.e : myButton)

    
    
    /* ... */
    class ViewController: UIViewController {
    
          @IBOutlet var myButton: UIImageView!
    
    /* ... */
    
    
  • Set your button in Moonkey's code

    Use your button's name in the MoonkeyButton function

    
    
    /* ... */	
    let moonkeyButton = MoonkeyButton(image: myButton)
    moonkeyButton.setContent(moonkeyContent)
    
    /* ... */
    
    

UIWebView

  • Set a webview to make your Moonkey button appears

    Drag & drop UIWebView in your Xcode storyboard

    UIWebView
  • Link it to your ViewController

    Right click on your UIWebView, then drag & drop it to your View Controller
    Give it a name (i.e : myButton)

    
    
    /* ... */
    class ViewController: UIViewController {
    
          @IBOutlet var myButton: UIWebView!
    
    /* ... */
    
    
  • Set your webview in Moonkey's code

    Use your webview's name in the MoonkeyButton function

    
    
    /* ... */	
    let moonkeyButton = MoonkeyButton(frame: myButton)
    moonkeyButton.setContent(moonkeyContent)
    
    /* ... */
    
    

Events

Access

Function : callAccess
Fired when Moonkey button access is granted


func callAccess () {
	//Your callAccess function
}

Success

Function : callSuccess
Fired when a user has unlocked your content.


func callSuccess () {
	//Your callSuccess function
}

Cancel

Function : callCancel
Fired when a user come back from Moonkey platform without unlocking your content


func callCancel () {
	//Your callCancel function
}

Advanced Configuration

All configuration parameters have to be include in the Array like the example below :

/* ... */
/* John Doe's profil */
let userGender = .Male
let components = NSDateComponents()
components.month = 3
components.day = 13
components.year = 1976
var userLocation : [
     "latitude": CGFloat(currentLocation.coordinate.latitude),
     "longitude": CGFloat(currentLocation.coordinate.longitude),
     "accuracy": CGFloat(currentLocation.horizontalAccuracy)
]

/* ... */
moonkeyContent.connect(self, parameters: [
     "clientId" : "1811141408",
     "contentIdentifier" : "3226246716",
     "sId" : "22",
     "gender" : userGender,
     "birthday": NSCalendar.currentCalendar().dateFromComponents(components),
     "childDirectedTreatment" : false,
     "geolocation" : userLocation
], onSuccess: callSuccess, onCancel: callCancel, onAccess: callAccess)

/*...*/


User gender

Key : gender

Type : Enum
Default : Unknown
Values : Male | Female | Unknown

	"gender" : .Female

/* ... */
/* John Doe's profil */
let userGender = .Male

/* ... */
moonkeyContent.connect(self, parameters: [
     "clientId" : "1811141408",
     "contentIdentifier" : "3226246716",
     "sId" : "22",
     "gender" : userGender
], onSuccess: callSuccess, onCancel: callCancel, onAccess: callAccess)

/* ... */

User birthday

Key : birthday

Type : NSDate object

"birthday" : NSDate

/* ... */
/* John Doe's profil */
let components = NSDateComponents()
components.month = 3
components.day = 13
components.year = 1976

/* ... */
moonkeyContent.connect(self, parameters: [
     "clientId" : "1811141408",
     "contentIdentifier" : "3226246716",
     "sId" : "22",
     "birthday": NSCalendar.currentCalendar().dateFromComponents(components)
], onSuccess: callSuccess, onCancel: callCancel, onAccess: callAccess)

/* ... */

Child treatment

Key : childTreatmentDirected
Set to indicate you want Moonkey to treat your content as child-directed

Type : Boolean
Default : false


	"childDirectedTreatment": false



/* ... */
/* John Doe's profil */
let components = NSDateComponents()
components.month = 3
components.day = 13
components.year = 1976

/* ... */
moonkeyContent.connect(self, parameters: [
     "clientId" : "1811141408",
     "contentIdentifier" : "3226246716",
     "sId" : "22",
     "childTreatmentDirected" : false
], onSuccess: callSuccess, onCancel: callCancel, onAccess: callAccess)

/* ... */

User location

Key : geolocation
Set to enable geolocated ads

Type : Array
Parameters : latitude | longitude | accuracy

if let currentLocation = locationManager.location {
     "geolocation": [
          "latitude": CGFloat(currentLocation.coordinate.latitude),
          "longitude": CGFloat(currentLocation.coordinate.longitude),
          "accuracy": CGFloat(currentLocation.horizontalAccuracy)
     ]
}

/* ... */
/* John Doe's profil */
var userLocation : [
     "latitude": CGFloat(currentLocation.coordinate.latitude),
     "longitude": CGFloat(currentLocation.coordinate.longitude),
     "accuracy": CGFloat(currentLocation.horizontalAccuracy)
]

/* ... */
moonkeyContent.connect(self, parameters: [
     "clientId" : "1811141408",
     "contentIdentifier" : "3226246716",
     "sId" : "22",
     "geolocation" : userLocation
], onSuccess: callSuccess, onCancel: callCancel, onAccess: callAccess)

/*...*/