Enterprise Mobile Application Studio(EMAS)を使用すると、WindVane または uni-app ミニアプリ コンテナーをネイティブ アプリに統合できます。このトピックでは、ミニアプリ コンテナーを iOS アプリに統合する方法について説明します。
前提条件
ネイティブ アプリの AccessKey、SecretKey、およびアプリ コードを取得します。詳細については、「ユーザー ガイド」の「Application Open Platform(プラットフォーム オペレーター向け)」にある「アプリを構成する」のトピックをご参照ください。
Application Open Platform のドメイン名を取得します。デモ環境のドメイン名は
poc.superapp-intl.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 リポジトリで入手できます。アカウントとパスワードについては、O&M エンジニアにお問い合わせください。
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。この依存関係は、WindVane と uni-app の両方で必要です。 pod 'EMASServiceManager' pod 'EMASMiniAppAdapter' // WindVane ミニアプリ コンテナーの SDK。WindVane ミニアプリ コンテナーをアプリに統合する場合、この依存関係を含めます。 pod 'EMASWindVaneMiniApp' // uni-app ミニアプリ コンテナーの SDK。uni-app ミニアプリ コンテナーをアプリに統合する場合、この依存関係を含めます。 pod 'EMASUniappMiniApp'
手順 2: コンテナーを初期化する
ミニアプリ コンテナーを使用する前に、初期化する必要があります。
// ミニアプリ コンテナーの初期化に使用する SDK。
EMASMiniAppInitConfig *miniAppInitConfig = [EMASMiniAppInitConfig new];
miniAppInitConfig.useUniApp = YES;
miniAppInitConfig.useWindVane = YES;
miniAppInitConfig.accessKey = @"ZXZ8****";// Application Open Platform から AccessKey を取得します。
miniAppInitConfig.secretKey = @"3PNJxKtf7/eqUohlG3bI****";// Application Open Platform から SecretKey を取得します。
miniAppInitConfig.host = @"emas.example.com";// Application Open Platform のドメイン名を指定します。このサンプル コードの値は参照用です。デモ環境のドメイン名は emas-publish-intl.emas-poc.com です。
miniAppInitConfig.appCode = @"161160615860445224****";// Application Open Platform からアプリ コードを取得します。
EMASMiniAppServiceImpl *miniAppService = [EMASMiniAppServiceImpl new];
[miniAppService initialize:miniAppInitConfig];
[[EMASServiceManager sharedInstance] registerServiceProtocol:@"EMASMiniAppService" IMPClass:@"EMASMiniAppServiceImpl" target:miniAppService];
// 次のコードは、WindVane ミニアプリ コンテナーのオプションの初期化構成の例を示しています。お気に入りまたは関連付けられたユーザーを使用する場合、URL をインターセプトする場合、または画像をアップロードする場合は、対応するクラスを実装してください。
//[[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 なしで実行すると、「'iOS-simulator' 用にビルドしていますが、オブジェクトファイルにリンクしています」 というエラーが発生します。ビルド設定 -> 除外アーキテクチャで変更する必要があります。任意の iOS シミュレーター SDK arm64 を追加します。サードパーティの .framework または .a エラー x86_64 未定義シンボル:_OBJC_CLASS_$_ は、プロジェクトのビルド設定 -> その他のリンカー フラグ -ld64 に追加する必要があります。次に、製品 -> デスティネーションで Rosetta のマークが付いたシミュレーターを選択して、プロジェクトを実行します。
Xcode 15 で ENABLE_USER_SCRIPT_SANDBOXING が追加されました。"サンドボックス: rsync.samba 拒否" というエラーが発生した場合は、ビルド設定 -> ユーザー スクリプト サンドボックスをいいなりに設定します。
API リファレンス
詳細については、「API リファレンス」をご参照ください。