Huawei Mobile Services
Step 1. Huawei Mobile Services project setup
Create an AppGallery Connect project. Go to Develop and Services → Add project:
Add a new app to the project:
Provide your app information:
Download the agconnect-services.plist file:
In the left sidebar, under Grow, select Push Kit:
Click Enable → Select data storage location:
Then go to Push Kit → Settings → App → iOS configuration → Enable. In the opened iOS configuration, specify:
 - **APNs Authentication Key** — the contents of the private .p8 key file opened in a text editor;
 - **Key ID** — the `keyID` of the private .p8 key file (usually matches the file name — the value after `AuthKey_`);
 - **Developer ID** — the `teamID` from Apple Developer.
Step 2. Altcraft resource configuration
In the Altcraft platform, create a resource or add a new communication channel — Push — to an existing resource. Then, in the resource settings, select the iOS platform and activate the Huawei Mobile Services switch:
Scroll down to Huawei settings and enter the App ID, OAuth 2.0 client ID, and OAuth 2.0 client secret:
Note that the App ID is the Client ID from the App information section.
After making changes, don’t forget to save the resource.
Step 3. Integrating Huawei Push Kit into the app project
Move the downloaded agconnect-services.plist file to the root directory of the app module (app). Then add the HmsPushSDK pod.
Configure the app target:
- General — Frameworks, Libraries, and Embedded Content
 
Make sure the required frameworks are added and set to Do Not Embed:
AGConnectCore.xcframeworkAGConnectCredential.xcframeworkHiAnalytics.xcframeworkHMFoundation.xcframework
- Signing & Capabilities
 
Add Push Notifications.
Step 4. Obtaining the HMS token
Get the HMS token using the HmsInstanceId.getInstance().getToken(apnsToken) function, passing the APNs token as a parameter:
Example of obtaining and deleting an HMS token in an SDK interface implementation
import Foundation
// Be sure to import HmsPushSdk in the files where you use HMS functions
import HmsPushSdk
import Altcraft
class HMSProvider: HMSInterface {
    /// Retrieves the current HMS token using the APNs token
    func getToken(completion: @escaping (String?) -> Void) {
        guard let apnsToken = getAPNsTokenFromUserDefault() else {
            completion(nil)
            return
        }
        let token = HmsInstanceId.getInstance().getToken(apnsToken)
        completion(token)
    }
    
    
    func deleteToken(completion: @escaping (Bool) -> Void) {
        HmsInstanceId.getInstance().deleteToken()
        completion(true)
    }
}