PDRCore.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. //
  2. // PDRCore.h
  3. // Pandora Project
  4. //
  5. // Created by Mac on 12-12-25.
  6. // Copyright (c) 2012年 DCloud. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import "PDRCoreDefs.h"
  10. #import "PDRCoreSettings.h"
  11. //#import "WXSDKInstance.h"
  12. @class PDRCoreWindowManager;
  13. @class PDRCoreAppManager;
  14. @class H5CoreRootViewController;
  15. /// H5+代理类用于和宿主环境沟通
  16. @protocol PDRCoreDelegate <NSObject>
  17. @optional
  18. /// @brief 获取状态栏颜色
  19. -(UIColor*)getStatusBarBackground;
  20. /// @brief 设置状态栏颜色
  21. -(void)setStatusBarBackground:(UIColor*)newColor;
  22. /// @brief 设置状态栏样式
  23. -(void)setStatusBarStyle:(UIStatusBarStyle)statusBarStyle;
  24. -(void)setStatusBarHidden:(BOOL)isHidden;
  25. -(UIStatusBarStyle)getStatusBarStyle;
  26. -(void)wantsFullScreen:(BOOL)fullScreen;
  27. -(BOOL)getStatusBarHidden;
  28. -(BOOL)closeCore;
  29. - (BOOL)canCloseSplash;
  30. - (void)refreshTopWebviewStart;
  31. - (void)refreshTopWebviewEnd;
  32. - (void)getWebviewFavoriteOptions:(NSDictionary*)fav;
  33. //options :@{enableauthority:@(true),enableserver:@(true),geo:(true)}
  34. - (NSString*)getCurrentLocationWithOptions:(NSDictionary*)options
  35. withResult:(void (^)(NSString*address,NSError*error))block1;
  36. - (void)canaleGetCurrentLocationWithId:(NSString*)locationId;
  37. - (BOOL)interruptCloseSplash;
  38. - (void)settingLoadEnd;
  39. - (void)setHomeIndicatorAutoHidden:(BOOL)isHidden;
  40. @end
  41. /// H5+核心类负责H5+runtime的启动关闭
  42. @interface PDRCore : NSObject
  43. @property(nonatomic, readonly)PDRCoreRunMode runMode;
  44. @property(nonatomic, retain)NSData *deviceToken;
  45. /// @brief Runtime应用管理对象
  46. @property(nonatomic, readonly)PDRCoreAppManager *appManager;
  47. /// @brief Runtime设置对象,保存设置信息
  48. @property(nonatomic, readonly)PDRCoreSettings *settings;
  49. @property(nonatomic, readonly)BOOL lockScreen;
  50. /// @brief Runtime代理类
  51. @property(nonatomic, assign)id<PDRCoreDelegate> coreDeleagete;
  52. /// @brief 设置5+Runtime ViewContoller persentViewController 未设置使用rootViewContoller
  53. @property(nonatomic, assign)UIViewController *persentViewController;
  54. @property(nonatomic, assign)BOOL setRenderWithViewController;
  55. @property(nonatomic, retain, readonly)H5CoreRootViewController *rootViewController;
  56. + (void)runInBackgroud:(void (^)(void))block;
  57. + (void)runInBackgroudConcurrent:(void (^)(void))block;
  58. + (void)runInMainThread:(void (^)(void))block1;
  59. /// @brief 获取Core单例对象
  60. + (PDRCore*)Instance;
  61. #pragma mark - life cycle
  62. /// @brief 设置shell启动参数
  63. + (BOOL)initEngineWihtOptions:(NSDictionary *)launchOptions
  64. withRunMode:(PDRCoreRunMode)runMode;
  65. + (BOOL)initEngineWihtOptions:(NSDictionary *)launchOptions
  66. withRunMode:(PDRCoreRunMode)runMode withDelegate:(id<PDRCoreDelegate>)delegate;
  67. /// @brief 关闭runtime
  68. + (BOOL)destoryEngine;
  69. /// @brief 设置runtime根视图的父亲View
  70. - (int)setContainerView:(UIView*)containerView;
  71. /// @brief 通知runtime处理指定的事件
  72. + (id)handleSysEvent:(PDRCoreSysEvent)evt withObject:(id)object;
  73. - (id)handleSysEvent:(PDRCoreSysEvent)evt withObject:(id)object;
  74. /// @brief 获取PandoraApi.bundle的路径
  75. - (NSString*)mainBundlePath;
  76. /// @brief 设置应用运行时目录<br/>
  77. /// 当应用 runmode为liberate时将把资源拷贝到该目录<br/>
  78. /// 应用运行时产生的文件在该目录下生成</br>
  79. /// 默认为Library/Pandora/apps/<br/>
  80. - (int)setAppsRunPath:(NSString*)workPath;
  81. /// @brief 设置runtime应用的安装目录<br/>该地址为安装包中携带的应用资源位置 默认地址为?.app/Pandora/apps/
  82. - (int)setAppsInstallPath:(NSString*)installPath;
  83. /// @brief 设置runtime文档目录.
  84. - (int)setDocumethPath:(NSString*)documentPath;
  85. /// @brief 设置runtime下载目录
  86. - (int)setDownloadPath:(NSString*)downlaodPath;
  87. + (void)setHasBarview:(BOOL)hasBarview;
  88. + (void)setBarviewHeight:(CGFloat)barviewHeight;
  89. + (BOOL)hasBarview;
  90. /**
  91. @brief 设置指定app的文档目录
  92. @param appid 要设置的appid
  93. @param doucmentPath 要设置的路径
  94. @return int 0 成功
  95. */
  96. - (int)setApp:(NSString*)appid documentPath:(NSString*)doucmentPath;
  97. /**
  98. @brief 注册第三方扩展的插件
  99. @param pluginName 插件名称JS文件中定义的名字
  100. @param impClassName 插件对应的实现类名
  101. @param pluginType 插件类型 详情: `PDRExendPluginType`
  102. @see PDRExendPluginType
  103. @param javaScript js实现 为javascript文本
  104. @return int 0 成功
  105. */
  106. - (int)regPluginWithName:(NSString*)pluginName
  107. impClassName:(NSString*)impClassName
  108. type:(PDRExendPluginType)pluginType
  109. javaScript:(NSString*)javaScript;
  110. /**
  111. @brief 注册第三方扩展的插件
  112. @param pluginName 插件名称JS文件中定义的名字
  113. @param impClassName 插件对应的实现类名
  114. @param pluginType 插件类型 详情: `PDRExendPluginType`
  115. @see PDRExendPluginType
  116. @param javaScript js实现 为javascript文件 该文件为同步加载
  117. @return int 0 成功
  118. */
  119. - (int)regPluginWithName:(NSString*)pluginName
  120. impClassName:(NSString*)impClassName
  121. type:(PDRExendPluginType)pluginType
  122. javaScriptPath:(NSString*)javaScript;
  123. #pragma mark - 以下接口PDRCoreRunModeNormal才支持,SDK一般不需要使用
  124. - (int)start;
  125. + (void)startMainApp;
  126. /**
  127. @brief 显示启动图
  128. PDRCoreRunModeNormal 才支持
  129. @see start
  130. @return int
  131. */
  132. - (int)showLoadingPage;
  133. - (int)closeLoadingPage;
  134. - (BOOL)isSplashPageClosed;
  135. /// @brief 设置runtiem启动时自动运行的APP PDRCoreRunModeNormal 才支持
  136. - (int)setAutoStartAppid:(NSString*)appid;
  137. - (void)showChildUIViewController:(UIViewController*)childUIViewController;
  138. - (void)hideChildUIViewController:(UIViewController*)childUIViewController;
  139. //#pragma deprecated
  140. //- (int)load __attribute__((deprecated));
  141. //- (int)unLoad __attribute__((deprecated));
  142. //- (int)startAsWebClient __attribute__((deprecated));
  143. //- (int)startAsAppClient __attribute__((deprecated));
  144. //- (int)end __attribute__((deprecated));
  145. @end