Skip to main content

Initialization

If you haven't created your apps at App Store Connect Console yet, please start by following this guide step-by-step.

The first step to integrate with appmate SDK is to add the library to your app and initialize an instance of the appmate. With appmate SDK, you will be able to manage all the processes of Apple's IAP APIs through the single sdk. To integrate the appmate, you can simply drag & drop .xcframefork file to project folder.You can also use CocoaPods or Swift Package Manager alternatively.

Manual Integration#

Go to the address given below and download the file.

http://sdk.appmate.tech/repository/cocoapods-raw/appmate.xcframework.zip

Extract the .xcframework file from the archive and drag & drop it to the project folder. Make sure Copy items if needed checkbox is selected.

img

Navigate to PROJECT overview and select your TARGET.

img

Find Frameworks, Libraries, and Embedded Content under General tab. Select Embed & Sign choice for appmate.xcframework. Now, you are ready to use all the facilities provided by appmate.

img

Integration via Cocoapods#

Create a Podfile (If you don’t have).

$ cd your-project-directory$ pod init

Edit the Podfile to add pod dependencies:

target 'iapexample' do  # Comment the next line if you don't want to use dynamic frameworks  use_frameworks!
  # Pods for iapexample  pod 'appmate'
end

Finally, run the code below:

pod install

When you run pod install code, another file with .xcworkspace extension will be created. Open your project with using .xcworkspace file.

Integration via Swift Package Manager#

In order to initialize appmate via Swift Package Manager, you simply need to choose "File > Swift Packages > Add Package Dependency" in Xcode.

img

Then, copy and paste the link below and click Next.

https://github.com/huawei-appmate/appmate.git

img

Set the rules as shown below and click Next.

img

Click Finish and now your project is integrated with appmate.

img

Requirements#

Minimum target: iOS 11.0+

Initialization of appmate#

Once you've added a dependency on the appmate SDK, you have to set ApiKey initially. And you can set UserId and SandboxActive optionally. appmate is a singleton class that you can create it once in your app and call by appmate instance throughout your app. We recommend you to set initial configurations in the AppDelegate class of your app or within a singleton class. appmate is the main class for communication between the appmate SDK and the rest of your app. You can retrieve apiKey from appmate console.

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {    PurchaseClient.shared.setApiKey("apiKey")    //PurchaseClient.shared.setUserId("userId")    //PurchaseClient.shared.setSandboxActive(true)    return true}

Also you can retrieve userId from appmate SDK regardless of you set a userId or a random userId is created.

let userId = PurchaseClient.shared.getUserId()