日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

ios html5上架,iOS原生集成H5+详细流程

發(fā)布時間:2023/12/10 编程问答 45 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ios html5上架,iOS原生集成H5+详细流程 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

iOS原生集成H5+

集成方式

獨(dú)立應(yīng)用方式集成

Widget方式集成

WebView方式集成

可以打開官方鏈接: 選擇 5+SDK -> 5+SDK集成 -> 平臺 下查看集成方式

獨(dú)立應(yīng)用方式: 官方Demo中的實(shí)現(xiàn), 獨(dú)立的App, 感覺上和直接在HBuilder創(chuàng)建App相同, 可以方便證書導(dǎo)入這些步驟吧

Widget方式: 模塊部分的擴(kuò)展使用

WebView方式: 單獨(dú)界面的擴(kuò)展使用

白皮書原話: 在使用中,如果需要顯示多個H5頁面,建議使用Widget集成方式,如果只有一個H5頁面,建議使用WebView集成方式

集成過程

導(dǎo)入SDK相關(guān)文件

Snip20170507_10.png

Snip20170507_6.png

導(dǎo)入Pandora相關(guān)文件

Snip20170507_13.png

Snip20170507_14.png

修改編譯配置

配置Build Setting

搜索 Other Linker Flags , 配置下拉列表中添加-ObjC

搜索 Enable Bitcode, 配置為 NO

配置info.plist, target -> Info

添加NSAppTransportSecurity字段 -> NSAllowsArbitraryLoads為YES

URL Types -> + -> URL Schemes框配置為 * hbuilder*

寫調(diào)用SDK代碼編譯, 報錯按照錯誤提示導(dǎo)入庫, 直到編譯成功

/// AppDelegate

#import "PDRCore.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

/// 指定5+SDK的模式

return [PDRCore initEngineWihtOptions:launchOptions withRunMode:PDRCoreRunModeNormal];

}

- (void)applicationWillTerminate:(UIApplication *)application {

[PDRCore destoryEngine];

}

@end

#import "PDRCore.h"

@implementation ViewController

- (void)viewDidLoad {

[super viewDidLoad];

// 獨(dú)立應(yīng)用方式加載

// [self start5pAsNormal];

}

/// 滿足一些條件調(diào)用

- (void)doSomething {

// Widget方式加載

// [self start5pAsWidget];

// WebView方式加載

// [self start5pAsWebView];

}

- (void)start5pAsNormal {

PDRCore *core = [PDRCore Instance];

if (!core) return;

[core setContainerView:self.view];

[core start];

}

- (void)start5pAsWidget {

PDRCore *core = [PDRCore Instance];

if (!core) return;

// 設(shè)置WebApp所在的目錄,該目錄下必須有mainfest.json

NSString* pWWWPath = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"Pandora/apps/H5Demo/www"];

// 設(shè)置5+SDK運(yùn)行的View

[core setContainerView:self.view];

// 傳入?yún)?shù)可以在頁面中通過plus.runtime.arguments參數(shù)獲取

NSString* pArgus = @"id=plus.runtime.arguments";

// 啟動該應(yīng)用

_coreApp = [[core appManager] openAppAtLocation:pWWWPath withIndexPath:@"index.html" withArgs:pArgus withDelegate:nil];

// 如果應(yīng)用可能會重復(fù)打開的話建議使用restart方法

// [[core appManager] restart:_coreApp];

}

- (void)start5pAsWebView {

PDRCore *core = [PDRCore Instance];

if (!core) return;

// 單頁面集成時可以設(shè)置打開的頁面是本地文件或者是網(wǎng)絡(luò)路徑

NSString* pFilePath = [NSString stringWithFormat:@"file://%@/%@", [NSBundle mainBundle].bundlePath, @"Pandora/apps/H5Dome/www/index.html"];

_appFrame = [[PDRCoreAppFrame alloc] initWithName:@"WebViewID1" loadURL:pFilePath frame:CGRectOffset(self.view.frame, 0, 20)];

// 單頁面運(yùn)行時設(shè)置Document目錄

NSString* pStringDocumentpath = [NSString stringWithFormat:@"%@/Pandora/apps/H5Dome/www/", [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) objectAtIndex:0]];

[core.appManager.activeApp.appInfo setWwwPath:pStringDocumentpath];

[core.appManager.activeApp.appWindow registerFrame:_appFrame];

[self.view addSubview:_appFrame];

}

@end

匹配 模式(PDRCoreRunMode) 與 啟動該模式(how start) 的代碼, 否則很容易掉坑里

Demo中其他處理, AppDelegate / ViewController 都可以參照

解決Undefined symbols for architecture xxx: “xxx”, referenced from: 的錯誤提示

屏幕快照 2017-05-06 23.14.25.png

首先使用官方文檔

屏幕快照 2017-05-06 23.14.57.png

導(dǎo)入對應(yīng)庫

Snip20170506_1.png

還有無法匹配的錯誤, 自行g(shù)oogle / baidu

實(shí)驗結(jié)果總結(jié)

獨(dú)立應(yīng)用方式與Widget方式確實(shí)相似, 區(qū)別部分

/// AppDelegate中

/// 獨(dú)立應(yīng)用方式: 配置為 PDRCoreRunModeNormal

/// Widget方式: 配置為 PDRCoreRunModeAppClient

[PDRCore initEngineWihtOptions:launchOptions withRunMode:PDRCoreRunMode];

/// 配置并啟動5+SDK環(huán)境

/// 獨(dú)立應(yīng)用方式: 直接在啟動后的根控制器中設(shè)置即可

/// Widget方式: 在需要用啟動的位置設(shè)置即可

PDRCore *core = [PDRCore Instance];

if (!core) return;

[core setContainerView:self.view];

[core showLoadingPage]; // 展示啟動頁(讀取頁)

dispatch_async(dispatch_get_main_queue(), ^(void) {

/// 獨(dú)立應(yīng)用方式: 下面?zhèn)z種都可以開啟

/// Widget方式: 必須使用第二種開啟

[core start];

// [[core appManager] openAppAtLocation:[[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"Pandora/apps/HelloH5/www"] withIndexPath:@"index.html" withArgs:@"id=plus.runtime.arguments" withDelegate:nil];

});

相關(guān)資源鏈接

總結(jié)

以上是生活随笔為你收集整理的ios html5上架,iOS原生集成H5+详细流程的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。