PlatformBridge.ts 908 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import { sys } from 'cc';
  2. export enum PlatformType {
  3. Unknown = 'unknown',
  4. H5 = 'h5',
  5. Android = 'android',
  6. IOS = 'ios',
  7. }
  8. export abstract class PlatformBridge {
  9. readonly type: PlatformType = PlatformType.Unknown;
  10. readonly isNative = sys.isNative;
  11. readonly os = sys.os;
  12. openExternalUrl(url: string): void {
  13. sys.openURL(url);
  14. }
  15. /**
  16. * 获取Url 或者 启动参数
  17. * @param _name
  18. * @returns
  19. */
  20. abstract getUrlParam(_name: string): string | null;
  21. /** 获取设备ID */
  22. abstract getDeviceID(): string | null;
  23. /** 客户端唯一标识 */
  24. getUUID(): string | null {
  25. /// 优化使用广告ID、设备ID
  26. const adID = this.getAdID();
  27. if (!!adID) return adID;
  28. return this.getDeviceID();
  29. }
  30. /** 获取AdJust AdID */
  31. getAdID(): string | null {
  32. return ''
  33. }
  34. async getFinger2DeviceId(): Promise<string | null> {
  35. return null;
  36. }
  37. }