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 IntegrationGo 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.
Navigate to PROJECT overview and select your TARGET.
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.
#
Integration via CocoapodsCreate 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 ManagerIn order to initialize appmate via Swift Package Manager, you simply need to choose "File > Swift Packages > Add Package Dependency" in Xcode.
Then, copy and paste the link below and click Next.
https://github.com/huawei-appmate/appmate.git
Set the rules as shown below and click Next.
Click Finish and now your project is integrated with appmate.
#
RequirementsMinimum target: iOS 11.0+
#
Initialization of appmateOnce 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.
- Swift
- Objective-C
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { PurchaseClient.shared.setApiKey("apiKey") //PurchaseClient.shared.setUserId("userId") //PurchaseClient.shared.setSandboxActive(true) return true}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [[PurchaseClient shared] setApiKey:@"apiKey"]; //[[PurchaseClient shared] setUserId:@"userId"]; //[[PurchaseClient shared] setSandboxActive:true]; return YES;}
Also you can retrieve userId from appmate SDK regardless of you set a userId or a random userId is created.
- Swift
- Objective-C
let userId = PurchaseClient.shared.getUserId()
NSString *userId = [[PurchaseClient shared] getUserId];