EMAS は、WindVane および uni-app ミニプログラムコンテナのネイティブアプリへの統合をサポートしています。ビジネスニーズに合わせてミニプログラムコンテナのタイプを選択してください。このトピックでは、iOS にミニプログラムコンテナを統合する方法について説明します。
前提条件
ネイティブアプリの AccessKey、SecretKey、App Code を取得します。詳細については、「ユーザーガイド」 > 「オープンアプリプラットフォーム」(プラットフォームオペレーター) > 「アプリの設定」セクションをご参照ください。
オープンアプリプラットフォームの環境ドメイン名を取得します。トライアル環境のドメイン名は
emas-publish-intl.emas-poc.comです。
ステップ 1:依存関係の追加
次の CocoaPods リポジトリを追加します。
pod repo add superapp-intl-emas-ios-emas-specs https://gitlab-console.superapp-intl.com/emas-ios/emas-specs.git pod repo add superapp-intl-emas-ios-emas-specs-thirdpart https://gitlab-console.superapp-intl.com/emas-ios/emas-specs-thirdpart.gitプロジェクトのルートディレクトリにある
Podfileで、CocoaPods リポジトリを構成します。ミニプログラムコンテナの SDK は、これらの CocoaPods リポジトリに公開されます。アカウントの認証情報を取得するには、運用エンジニアにお問い合わせください。
source 'https://gitlab-console.superapp-intl.com/emas-ios/emas-specs.git' source 'https://gitlab-console.superapp-intl.com/emas-ios/emas-specs-thirdpart.git'ミニプログラムコンテナの次の依存関係を
Podfileに追加します。use_frameworks! // ミニプログラムコンテナのベース SDK。これは必須の依存関係です。 pod 'EMASServiceManager' pod 'EMASMiniAppAdapter' // WindVane ミニプログラムコンテナ。WindVane ミニプログラムを使用する場合に必要です。 pod 'EMASWindVaneMiniApp' // uni-app ミニプログラムコンテナ。uni-app ミニプログラムを使用する場合に必要です。 pod 'EMASUniappMiniApp'
ステップ 2:コンテナの初期化
コンテナを使用する前に、初期化する必要があります。
// SDK の初期化
EMASMiniAppInitConfig *miniAppInitConfig = [EMASMiniAppInitConfig new];
miniAppInitConfig.useUniApp = YES;
miniAppInitConfig.useWindVane = YES;
miniAppInitConfig.accessKey = @"ZXZ8****";// オープンアプリプラットフォームから取得します。
miniAppInitConfig.secretKey = @"3PNJxKtf7/eqUohlG3bI****";// オープンアプリプラットフォームから取得します。
miniAppInitConfig.host = @"emas.example.com";// ご利用の環境ドメイン名を設定します。これは一例です。トライアル環境のドメイン名は emas-publish-intl.emas-poc.com です。
miniAppInitConfig.appCode = @"161160615860445224****";// オープンアプリプラットフォームから取得します。
EMASMiniAppServiceImpl *miniAppService = [EMASMiniAppServiceImpl new];
[miniAppService initialize:miniAppInitConfig];
[[EMASServiceManager sharedInstance] registerServiceProtocol:@"EMASMiniAppService" IMPClass:@"EMASMiniAppServiceImpl" target:miniAppService];
// 以下は、WindVane ミニプログラムコンテナの追加構成です。これらの機能を使用する場合は、対応するクラスを実装する必要があります。
//[[EMASServiceManager sharedInstance] registerServiceProtocol:@"EMASMiniAppFavoriteService" IMPClass:@"EMASMiniAppFavoriteServiceImpl" target:[EMASMiniAppFavoriteService new]];// お気に入り機能用
//[[EMASServiceManager sharedInstance] registerServiceProtocol:@"EMASUserInfoService" IMPClass:@"EMASUserInfoServiceImpl" target:[EMASUserInfoServiceImpl new]];// ユーザー関連付け機能用
//[[EMASServiceManager sharedInstance] registerServiceProtocol:@"EMASMiniAppURLService" IMPClass:@"EMASMiniAppURLServiceImpl" target:[EMASMiniAppURLServiceImpl new]];// URL 傍受機能用注意事項
Apple シリコン (M シリーズ) チップを搭載した Mac のシミュレーターでアプリを実行する場合、Rosetta を使用して実行するシミュレーターを選択する必要があります。
Rosetta をインストールするには、ターミナルで次のコマンドを実行します。
sudo softwareupdate --install-rosetta --agree-to-licenseRosetta なしでアプリを実行すると、Building for 'iOS-simulator', but linking in object file エラーが発生する場合があります。この問題を解決するには、 [ビルド設定] > [Excluded Architectures] に移動し、[Any iOS Simulator SDK] を追加して、その値を arm64 に設定します。サードパーティライブラリが原因で x86_64 Undefined symbol:_OBJC_CLASS_$_ エラーが発生した場合は、プロジェクトの [ビルド設定] の [Other Linker Flags] に -ld64 を追加します。最後に、[Product] > [Destination] で Rosetta を使用するシミュレーターを選択して、プロジェクトを実行します。
Xcode 15 では、新しい設定 ENABLE_USER_SCRIPT_SANDBOXING が導入されました。Sandbox: rsync.samba deny エラーが発生した場合は、[ビルド設定] で [User Script Sandboxing] を [No] に変更します。
API リファレンス
API の詳細については、「API リファレンス」をご参照ください。