离子第三方库
Ionic third party libraries
经过一番研究,我发现了一些有关如何在 Ionic 框架中添加第三方 android 库的信息。显然我们可以在 Ionic 项目中添加和使用 .aar 文件。我的问题是,如果我包含一个 .aar 文件,项目仍然是跨平台的吗?可以iOS设备运行吗?
根据我的理解,您想使用基本上是用本机编写的库 Android/iOS。
Note: we can not use native code directly into ionic app.
那么下一个问题是如何在Hybrid app中调用原生代码或库?
要从 Javascript 调用本机代码,我们需要 Cordova 插件
它将从混合应用程序 -> 本机代码和本机代码 -> 混合应用程序进行通信。
lets us build our app in a web view, and call native code from
JavaScript
Cordova 提供了许多默认插件,如下所示:
"cordova-android": "~6.3.0",
"cordova-ios": "^4.5.4",
"cordova-plugin-advanced-http": "^1.9.0",
"cordova-plugin-device": "^1.1.7",
"cordova-plugin-file": "^6.0.1",
"cordova-plugin-inappbrowser": "^1.7.2",
"cordova-plugin-ionic-webview": "^1.1.16",
"cordova-plugin-native-spinner": "^1.1.3",
"cordova-plugin-network-information": "^1.3.4",
"cordova-plugin-proguard": "^1.0.0",
"cordova-plugin-splashscreen": "^4.1.0",
"cordova-plugin-whitelist": "^1.3.3",
"cordova-sqlite-storage": "^2.2.0",
所以这些插件主要用于利用原生应用程序框架,如
对于 SQLite 数据库存储,我们使用了 cordova-sqlite-storage
插件
对于启动画面,我们使用了 cordova-plugin-splashscreen
插件等...
所以下一个问题是什么是 Cordova 插件?
Building Cordova plugins means we are writing some JavaScript to call
down to some Native (Obj-c/Swift, Java, etc.) code we also write, and
returning the result to our JavaScript.
To sum it up: we build a Cordova plugin when we want to do something
natively that doesn’t yet have a Web API analog, like accessing
HealthKit data on iOS or using the Fingerprint scanner on Android.
Ref : Max Lynch (Medium Blog)
因此,如果您想使用您的 .aar 文件,您需要构建自定义插件。
此.aar文件将用于Android,对于iOS您需要搜索相关框架。
希望这有助于理解混合应用程序中的所有输入和输出。
有用的链接:
经过一番研究,我发现了一些有关如何在 Ionic 框架中添加第三方 android 库的信息。显然我们可以在 Ionic 项目中添加和使用 .aar 文件。我的问题是,如果我包含一个 .aar 文件,项目仍然是跨平台的吗?可以iOS设备运行吗?
根据我的理解,您想使用基本上是用本机编写的库 Android/iOS。
Note: we can not use native code directly into ionic app.
那么下一个问题是如何在Hybrid app中调用原生代码或库?
要从 Javascript 调用本机代码,我们需要 Cordova 插件 它将从混合应用程序 -> 本机代码和本机代码 -> 混合应用程序进行通信。
lets us build our app in a web view, and call native code from JavaScript
Cordova 提供了许多默认插件,如下所示:
"cordova-android": "~6.3.0",
"cordova-ios": "^4.5.4",
"cordova-plugin-advanced-http": "^1.9.0",
"cordova-plugin-device": "^1.1.7",
"cordova-plugin-file": "^6.0.1",
"cordova-plugin-inappbrowser": "^1.7.2",
"cordova-plugin-ionic-webview": "^1.1.16",
"cordova-plugin-native-spinner": "^1.1.3",
"cordova-plugin-network-information": "^1.3.4",
"cordova-plugin-proguard": "^1.0.0",
"cordova-plugin-splashscreen": "^4.1.0",
"cordova-plugin-whitelist": "^1.3.3",
"cordova-sqlite-storage": "^2.2.0",
所以这些插件主要用于利用原生应用程序框架,如
对于 SQLite 数据库存储,我们使用了 cordova-sqlite-storage
插件
对于启动画面,我们使用了 cordova-plugin-splashscreen
插件等...
所以下一个问题是什么是 Cordova 插件?
Building Cordova plugins means we are writing some JavaScript to call down to some Native (Obj-c/Swift, Java, etc.) code we also write, and returning the result to our JavaScript.
To sum it up: we build a Cordova plugin when we want to do something natively that doesn’t yet have a Web API analog, like accessing HealthKit data on iOS or using the Fingerprint scanner on Android.
Ref : Max Lynch (Medium Blog)
因此,如果您想使用您的 .aar 文件,您需要构建自定义插件。
此.aar文件将用于Android,对于iOS您需要搜索相关框架。
希望这有助于理解混合应用程序中的所有输入和输出。
有用的链接: