baxi hai 6 días
pai
achega
554eb0eb2d

+ 1 - 1
assets/scripts/app/AppConfig.ts

@@ -16,7 +16,7 @@ const AppConfig = {
      * 非空时使用本地 Manifest 的资源列表与该地址下的远端 Manifest 做检测。
      */
     HotUpdateUrl: "",
-    HotUpdateEnable: true,
+    HotUpdateEnable: false,
 
 
     FBAppID: "1056149470661855",

+ 2 - 2
assets/scripts/platform/Google/GoogleIOSImpl.ts

@@ -2,9 +2,9 @@ import { GoogleImpl, IGoogleLoginRes } from "./GoogleImpl";
 
 export class GoogleIOSImpl extends GoogleImpl {
     init() {
-        throw new Error("[Google IOS] Method not implemented.");
+        console.log("[Google IOS] Method not implemented.");
     }
-    
+
     protected onLogin(): Promise<IGoogleLoginRes> {
         throw new Error("[Google IOS] Method not implemented.");
     }

+ 24 - 2
assets/scripts/platform/IOSPlatformBridge.ts

@@ -1,16 +1,38 @@
+import { native } from 'cc';
 import { PlatformBridge } from './PlatformBridge';
 import { PlatformType } from './PlatformBridge';
 
 export class IOSPlatformBridge extends PlatformBridge {
   readonly type = PlatformType.IOS;
+  private _deviceID: string | null = null;
 
   getUrlParam(_name: string): string | null {
     console.error('[IOS] 获取深度链接参数能力未实现');
     return null;
   }
 
+  /** IDFV:同一开发商范围内的设备标识,不保证卸载重装后保持不变。 */
   getDeviceID(): string | null {
-    console.error('[IOS] 获取设备号的能力未实现');
-    return '';
+    if (this._deviceID) return this._deviceID;
+
+    try {
+      // Creator 3.8 的声明只有 Android 签名;iOS 无参 selector 只传类名和方法名。
+      const iosReflection = native.reflection as unknown as {
+        callStaticMethod(className: string, methodName: string): unknown;
+      };
+      const deviceID = iosReflection.callStaticMethod(
+        'CocosIOSPlatformBridge',
+        'getDeviceID',
+      );
+      if (typeof deviceID === 'string' && deviceID.trim().length > 0) {
+        this._deviceID = deviceID.trim();
+        return this._deviceID;
+      }
+    } catch (error) {
+      console.error('[IOS] 获取 IDFV 失败:', error);
+    }
+
+    // IDFV 在设备重启后首次解锁前可能不可用;不缓存失败,下次调用重试。
+    return null;
   }
 }

+ 2 - 0
native/engine/ios/CMakeLists.txt

@@ -21,6 +21,8 @@ cc_ios_after_target(${EXECUTABLE_NAME})
 
 target_sources(${EXECUTABLE_NAME} PRIVATE ${CC_PROJECT_DIR}/service/FBWrapper.mm)
 set_source_files_properties(${CC_PROJECT_DIR}/service/FBWrapper.mm PROPERTIES COMPILE_FLAGS "-fobjc-arc")
+target_sources(${EXECUTABLE_NAME} PRIVATE ${CC_PROJECT_DIR}/service/CocosIOSPlatformBridge.mm)
+set_source_files_properties(${CC_PROJECT_DIR}/service/CocosIOSPlatformBridge.mm PROPERTIES COMPILE_FLAGS "-fobjc-arc")
 set_target_properties(${EXECUTABLE_NAME} PROPERTIES
     XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET "12.0"
     XCODE_ATTRIBUTE_ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES "YES")

+ 1 - 0
native/engine/ios/Info.plist

@@ -22,6 +22,7 @@
 	<key>LSApplicationQueriesSchemes</key>
 	<array>
 		<string>fbapi</string>
+		<string>fbauth2</string>
 		<string>fb-messenger-share-api</string>
 	</array>
 	<key>UILaunchStoryboardName</key>

+ 10 - 0
native/engine/ios/service/CocosIOSPlatformBridge.h

@@ -0,0 +1,10 @@
+#import <Foundation/Foundation.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface CocosIOSPlatformBridge : NSObject
+// Called synchronously by native.reflection; nil means temporarily unavailable.
++ (nullable NSString *)getDeviceID;
+@end
+
+NS_ASSUME_NONNULL_END

+ 12 - 0
native/engine/ios/service/CocosIOSPlatformBridge.mm

@@ -0,0 +1,12 @@
+#import "CocosIOSPlatformBridge.h"
+#import <UIKit/UIKit.h>
+
+@implementation CocosIOSPlatformBridge
+
++ (nullable NSString *)getDeviceID {
+    // Do not persist IDFV in backed-up storage: a restored backup can belong to
+    // another device. Always obtain this device's identifier from the OS.
+    return UIDevice.currentDevice.identifierForVendor.UUIDString;
+}
+
+@end