Silent Licensing

Silent Licensing allows you to use the functionality of the Paddle SDK with your own UI

Getting Started

To start using silent licensing you should follow the normal steps in Trials, Licensing & Checkout, but instead of calling the standard startLicensing method you should instead use startLicensingSilently. This will internally begin the licensing process and allow you to use activate, purchase and trial methods without the need to present the Paddle SDK UI. For example:


- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
	    NSDictionary *productInfo = [NSDictionary dictionaryWithObjectsAndKeys:
	         @"10.00", kPADCurrentPrice,
	         @"Test Developer", kPADDevName,
	         @"USD", kPADCurrency,
	         @"http://www.macupdate.com/util/iconlg/17227.png", kPADImage,
	         @"Test Product 2", kPADProductName,
	         @"7", kPADTrialDuration,
	         @"Thanks for downloading a trial of our product", kPADTrialText,
	         @"paddleicon.png", kPADProductImage, //Image file in your project
	         nil];
	
	    [[Paddle sharedInstance] startLicensingSilently:productInfo timeTrial:YES];
}

func applicationDidFinishLaunching(aNotification: NSNotification) {
	    let productInfo:NSDictionary = [
	        kPADCurrentPrice: "10.00",
	        kPADDevName: "Test Developer",
	        kPADCurrency: "USD",
	        kPADImage: "http://www.macupdate.com/util/iconlg/17227.png",
	        kPADProductName: "Test Product 2",
	        kPADTrialDuration: "7",
	        kPADTrialText: "Thanks for downloading a trial of our product",
	        kPADProductImage: "paddleicon.png" //Image file in your project
	    ]
	    
	    Paddle.sharedInstance().paddle.startLicensingSilently(productInfo as [NSObject : AnyObject], timeTrial: true)
}

Once you have started the silent licensing process you can use other methods, such as productActivated or daysRemainingOnTrial as usual.

Activating a License

To activate a license without presenting the Paddle SDK UI you can use the activateLicence withCompletionBlock: method, passing in the entered license code and customers emails address. For example:


[[Paddle sharedInstance] activateLicence:@"abc123" email:@"test@example.com" withCompletionBlock:^(BOOL activated, NSError *error) {
        if (activated) {
            NSLog(@"Product Activated");
        } else {
            NSLog(@"Product Not Activated: %@", [error localizedDescription]);
        }
    }];

Paddle.sharedInstance().activateLicence("123abc", email: "test@example.com") { (activated, error) -> Void in
            if activated {
                print("Product Activated")
            } else {
                print("Product Not Activated")
            }
        }

Purchasing a License

You can also launch a purchase window for your customer to purchase a license for your app. This will launch the purchase window from the SDK but will not present any other windows. You can do this using the startPurchaseWithWindow: completionBlock: method. This will accept a window parameter if you wish the window to be presented as a sheet attached to your window, and will return both a licenceCode and an email parameter. It will also return a activate parameter, which informs you if you should present an activate license window or not. For example:


[[Paddle sharedInstance] startPurchaseWithWindow:nil completionBlock:^(NSString *email, NSString *licenceCode, BOOL activate) {
        if (activate && licenceCode) {
            //Auto activate returned license
            
        } else if (activate) {
            //Show activate license UI
            
        } else {
            //No license and user has not clicked enter license (Cancelled)
            
        }
    }];

Paddle.sharedInstance().startPurchaseWithWindow(nil) { (email, licenceCode, activate) -> Void in
            if (activate && licenceCode != nil) {
                //Auto activate license
                
            } else if activate {
                //Show activate license UI
                
            } else {
                //User clicked Cancel
                
            }
        }

Deactivating a License

Deactivating a license is as simple as using the deactivateLicenceWithCompletionBlock: method. If successful it will return a deactivated BOOL value to indicate this. For example:


[[Paddle sharedInstance] deactivateLicenceWithCompletionBlock:^(BOOL deactivated, NSString *deactivateMessage) {
        if (deactivated) {
            NSLog(@"Product Deactivated");
        } else {
            NSLog(@"Product Not Deactivated");
        }
    }];

Paddle.sharedInstance().deactivateLicenceWithCompletionBlock { (deactivated, deactivateMessage) -> Void in
            if deactivated {
                print("License Deactivated")
            } else {
                print("License Not Deactivated")
            }
        }
Was this page helpful?