Migrate from v3 to v4 of the Mac SDK

v4.0, the newest Mac SDK release, supports all the most common use cases from v3 but isn’t a drop in replacement as we’ve refined our concepts and abstraction to make it more clear and flexible.

Triggering the SDK on App Launch and letting it handle trial, purchase and activations autonomously


v3

The most common v3 SDK use case is where Sellers initialise the SDK and then present our “Product Access” UI:

sdkProductAccess

The implementations typically look something like:


#import <Paddle/Paddle.h>
	
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
  	// Configure the SDK Instance with Seller details:
    Paddle *paddle = [Paddle sharedInstance];
    [paddle setProductId:@"12345"];
    [paddle setVendorId:@"56791"];
    [paddle setApiKey:@"abc123def345hij678"];
    
  	// Populate a local dictionary in case we're unable to retrieve data
  	// from the Vendor Dashboard: 
    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];
	
   // Launch the "Product Info" gatekeeper UI with buy, activate, etc:
   [[Paddle sharedInstance] startLicensing:productInfo timeTrial:YES withWindow:self.window];

import Paddle

    func applicationDidFinishLaunching(_ aNotification: Notification) {
        // Configure the SDK Instance with Seller details:
        let paddle = Paddle.sharedInstance()
        paddle.setProductId("12345")
        paddle.setVendorId("56791")
        paddle.setApiKey("abc123def345hij678")

        // Populate a local dictionary in case we're unable to retrieve data
        // from the Vendor Dashboard:
        let productInfo = [
            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",
        ]

        // Launch the "Product Info" gatekeeper UI with buy, activate, etc:
        Paddle.sharedInstance().startLicensing(productInfo, timeTrial: true, with: NSApplication.shared.windows.first!)
    }

v4

In v4, this is achieved fairly similarly and looks mostly the same:

darkmode-productAccess


#import <Paddle/Paddle.h>
	
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {

	// Your Paddle SDK Config from the Vendor Dashboard:
	NSString* myPaddleProductID = @"12345";
	NSString *myPaddleVendorID = @"56791";
	NSString* myPaddleAPIKey = @"abc123def345hij678";

	// Populate a local object in case we're unable to retrieve data
  	// from the Vendor Dashboard:
	PADProductConfiguration *defaultProductConfig = [[PADProductConfiguration alloc] init];
	defaultProductConfig.productName = @"My v4 Product";
	defaultProductConfig.vendorName = @"My Company";

	// Initialize the SDK Instance with Seller details:
	Paddle *paddle = [Paddle sharedInstanceWithVendorID:myPaddleVendorID
												 apiKey:myPaddleAPIKey
											  productID:myPaddleProductID
										  configuration:defaultProductConfig];
							
	// Initialize the Product you'd like to work with:	  
	PADProduct *paddleProduct = [[PADProduct alloc] initWithProductID:myPaddleProductID productType:PADProductTypeSDKProduct configuration:nil];

	// Ask the Product to get it's latest state and info from the Paddle Platform:
	[paddleProduct refresh:^(NSDictionary * _Nullable productDelta, NSError * _Nullable error) {
		   // Launch the "Product Info" gatekeeper UI with buy, activate, etc:
		[paddle showProductAccessDialogWithProduct:paddleProduct completion:nil;
	}];

}

import Paddle

    func applicationDidFinishLaunching(_ aNotification: Notification) {

        // Your Paddle SDK Config from the Vendor Dashboard:
        let productID = "12345"
        let vendorID = "56791"
        let apiKey = "abc123def345hij678"

        // Populate a local object in case we're unable to retrieve data
        // from the Vendor Dashboard:
        let defaultProductConfig = PADProductConfiguration()
        defaultProductConfig.productName = "My v4 Product"
        defaultProductConfig.vendorName = "My Company"

        // Initialize the SDK Instance with Seller details:
        let paddle = Paddle.sharedInstance(withVendorID: vendorID,
                                           apiKey: apiKey,
                                           productID: productID,
                                           configuration: defaultProductConfig)!

        // Initialize the Product you'd like to work with:
        let paddleProduct = PADProduct(productID: productID, productType: PADProductType.sdkProduct, configuration: defaultProductConfig)!

        // Ask the Product to get its latest state and info from the Paddle Platform:
        paddleProduct.refresh { (productDelta : [AnyHashable : Any]?, err: Error?) in
            // Launch the "Product Info" gatekeeper UI with buy, activate, etc:
            paddle.showProductAccessDialog(with: paddleProduct)
        }
    }

Questions about Paddle?

If you need any help regarding your Paddle integration, please get in touch with our Customer Success team using the form below.