Unreal iOS
在使用 Hive SDK Unreal iOS 完成應用程式開發後,您需要在構建應用程式時配置以下項目。
- 在 Unreal Editor 菜單中,點擊編輯 > 專案設定。專案設定窗口將顯示在螢幕上。
- 在專案設定窗口中,選擇左側面板中平台標題下的 iOS 菜單。iOS 設定屏幕將顯示。根據每個組的指導設置項目。
按組設定¶
以下是逐組設定的指示。
-
捆綁資訊組:在捆綁識別符欄位中輸入您的遊戲 AppID。
-
作業系統資訊群組:從 Unreal Engine 4.25 開始,支援的作業系統版本已更改為 11.0 或更高。將最小 OSVersion 欄位值設置為 11.0。
-
建立群組:在附加非運送鏈接器標誌欄位和附加運送鏈接器標誌欄位中輸入 -ObjC。
額外的 Plist 數據組設置¶
根據下面列出的設置項目,在附加 PList 數據字段中輸入代碼行。所有代碼必須在一行中輸入。
訪問權限請求設置¶
要設置訪問權限請求,請將以下代碼添加到附加 PList 數據字段中。
<key>NSCameraUsageDescription</key>
<string>Approval required to take pictures.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Approval required to upload image files.</string>
<key>NSUserTrackingUsageDescription</key>
<string>We need your permission to use the Advertising Identifiers (IDFA) for promotion targeting and tracking analysis.</string>
認證:Facebook、QQ VK、微信、Line 設定¶
如果您使用 Facebook、QQ、VK、WeChat 或 Line 认证,请将以下代码添加到附加 PList 数据字段中以设置服务器白名单。
<key>LSApplicationQueriesSchemes</key>
<array>
<string>weixin</string>
<string>vk-share</string>
<string>vkauthorize</string>
<string>vk</string>
<string>weixinULAPI</string>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
<string>mqqOpensdkSSoLogin</string>
<string>mqqopensdkapiV2</string>
<string>lineauth2</string>
<string>mqqopensdkapiV3</string>
<string>wtloginmqq2</string>
<string>mqq</string>
<string>mqqapi</string>
</array>
使用 Facebook 时,请使用以下代码添加 Facebook AppID 和 ClientToken。确保为您的游戏输入 Facebook AppID 和 ClientToken 值。
<key>FacebookAppID</key><string>926000000000000</string>
<key>FacebookClientToken</key><string>d123783h7sdfyh8031h23unf81h3</string>
為每個 IdP 設定 URL 構架。
<key>CFBundleURLTypes</key>
<array>
<!--For Facebook usage. Please insert your app's Facebook App ID value-->
<dict><key>CFBundleTypeRole</key><string>Editor</string><key>CFBundleURLSchemes</key><array><string>fb926000000000000</string></array></dict>
<!--For using deep links on the Hive platform. Please insert your AppID value-->
<dict><key>CFBundleTypeRole</key><string>Editor</string><key>CFBundleURLSchemes</key><array><string>com.com2us.misample.normal.freefull.apple.global.ios.universal</string></array></dict>
<!--For Google Sign-in. Please insert the Google Sign-in key value of your app-->
<dict><key>CFBundleTypeRole</key><string>Editor</string><key>CFBundleURLSchemes</key><array><string>com.googleusercontent.apps.270000000000-0m7r8tb2co1q00000000000000000000</string></array></dict>
<!--For QQ Sign-in. Please insert the QQ key value of your app-->
<dict><key>CFBundleTypeRole</key><string>Editor</string><key>CFBundleURLName</key><string>tencent</string>
<key>CFBundleURLSchemes</key><array><string>tencent1106227203</string></array></dict>
<!--For Wechat Sign-in. Please insert the Wechat key value of your app-->
<dict><key>CFBundleTypeRole</key><string>Editor</string><key>CFBundleURLName</key><string>weixin</string><key>CFBundleURLSchemes</key><array><string>wx78176cf0c698c0f9</string></array></dict>
<!--For VK Sign-in. Please insert the VK key value of your app-->
<dict><key>CFBundleTypeRole</key><string>Editor</string><key>CFBundleURLName</key><string>vk6270065</string><key>CFBundleURLSchemes</key><array><string>vk6270065</string></array></dict>
<!--For Line Sign-in-->
<dict><key>CFBundleTypeRole</key><string>Editor</string>
<key>CFBundleURLSchemes</key><array><string>line3rdp.$(PRODUCT_BUNDLE_IDENTIFIER)</string></array></dict>
</array>
以下是上述值插入到附加 PList 数据字段中的示例。
<key>NSCameraUsageDescription</key>
<string>Approval required to take pictures.</string>
<key>NSContactsUsageDescription</key>
<string>You must agree to add friends from your Contacts.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Approval required to upload image files.</string>
<key>NSUserTrackingUsageDescription</key>
<string>We need your permission to use the Advertising Identifiers (IDFA) for promotion targeting and tracking analysis.</string>
<key>FacebookAppID</key>
<string>1809615065921877</string>
<key>FacebookClientToken</key>
<string>c41e47ba5512ea3fb5bfb29d5cfeb244</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>line3rdp.$(PRODUCT_BUNDLE_IDENTIFIER)</string>
</array>
</dict>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>fb926000000000000</string>
</array>
</dict>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>com.com2us.hivesdk.normal.freefull.apple.global.ios.universal</string>
</array>
</dict>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>com.googleusercontent.apps.331526026701-s41n272jsv6c0f72kt5o7of0jns350gl</string>
</array>
</dict>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>tencent</string>
<key>CFBundleURLSchemes</key>
<array>
<string>tencent1106227203</string>
</array>
</dict>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>weixin</string>
<key>CFBundleURLSchemes</key>
<array>
<string>wx78176cf0c698c0f9</string>
</array>
</dict>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>vk6270065</string>
<key>CFBundleURLSchemes</key>
<array>
<string>vk6270065</string>
</array>
</dict>
</array>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>weixin</string>
<string>vk-share</string>
<string>vkauthorize</string>
<string>vk</string>
<string>weixinULAPI</string>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
<string>mqqOpensdkSSoLogin</string>
<string>mqqopensdkapiV2</string>
<string>lineauth2</string>
<string>mqqopensdkapiV3</string>
<string>wtloginmqq2</string>
<string>mqq</string>
<string>mqqapi</string>
</array>
蘋果登入設定¶
要支持 Apple SignIn,请将以下代码添加到项目文件夹 > 配置 > DefaultEngine.ini 文件中。
多語言設定¶
要為您的應用程式提供多語言服務,您需要添加多語言設置文件。下載multilingual setting file,解壓縮,並將localize文件夾的內容複製到/Plugins/HIVESDK/Source/HIVESDK/ThirdParty/iOS/resource。
應用 HIVEAppDelegate¶
對於 iOS 構建,您需要修改 AppDelegate 方法。在 Unreal Engine 的情況下,使用 Swizzling 來訪問 AppDelegate。在應用程序啟動時的初始化階段添加以下代碼。
// Add IOSAppDelegate.h
#if PLATFORM_IOS
#include "Runtime/ApplicationCore/Public/iOS/IOSAppDelegate.h"
#endif
// Add AppDelegate
#if PLATFORM_IOS
UIApplication * dummyApplication = [UIApplication sharedApplication];
Class clzHIVEAppDelegate = NSClassFromString(@"HIVEAppDelegate");
SEL selApplicationDidFinishLaunchingWithOptions = NSSelectorFromString(@"application:didFinishLaunchingWithOptions:");
if( clzHIVEAppDelegate != nil && [clzHIVEAppDelegate respondsToSelector:selApplicationDidFinishLaunchingWithOptions] ) {
NSMethodSignature *method = [clzHIVEAppDelegate methodSignatureForSelector:selApplicationDidFinishLaunchingWithOptions];
if (method != nil) {
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:method];
[invocation setSelector:selApplicationDidFinishLaunchingWithOptions];
[invocation setTarget:clzHIVEAppDelegate];
[invocation setArgument:(void*)&dummyApplication atIndex:2];
NSDictionary *localLaunchOptions = [IOSAppDelegate GetDelegate].launchOptions;
if( localLaunchOptions != nil ) {
[invocation setArgument:(void*)&localLaunchOptions atIndex:3];
}
[invocation invoke];
}
}
#endif
iOS FMallocAnsi 設定¶
為了使Unreal Engine iOS環境和C++標準模板庫能夠正確兼容,需要以下FMallocAnsi設置。將以下代碼添加到您的應用項目的{YourProject}.Target.cs
文件中。