Angular 5 与原生 IOS/Android 通信 [英] Angular 5 and native IOS/Android communication

查看:26
本文介绍了Angular 5 与原生 IOS/Android 通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在构建一个 angular 应用程序,我们将其作为 webview 嵌入到现有的 IOS 和 android 应用程序中.我想在 Angular 应用程序和本机应用程序之间创建通信.

we are building an angular application, which we will embed in an existing IOS and android application as a webview. I want to create a communication between angular application and native application.

例如:在某些事件(如下载)中,angular UI 应该向本机应用发送一些数据以使用这样的默认应用行为..

Eg: On certain events like download, angular UI should send some data to native apps to use default app behavior like that ..

从基本搜索中我发现它可以通过使用 javascript 来完成.

From the basic search i found that it can be done by using javascript.

我想知道执行此操作的最佳方法(架构级别),即 Angular UI 和本机应用程序之间的通信.

I want to know the best approach to do this(Architecture level), ie communication between angular UI and Native apps.

推荐答案

如果您已经有一个原生 iOS/Android 应用程序,并且就像您将 Angular 响应式 Web 应用程序嵌入其中一样,您可以使用 JavaScript 接口进行通信.

If you already have an native iOS / Android app and just like you embed your Angular responsive web app inside, you can communicate using JavaScript Interfaces.

但如果您有兴趣提供完整的原生性能,请查看 &感觉你的 Angular 应用程序,选择可能是 NativeScript.您将不得不使用 NativeScript 框架自带的跨平台布局/组件重写 HTML 组件,但您仍然可以重用 Angular 控制器、模型、服务等,

But if you are interested in giving a complete native performance, look & feel for your Angular app, the choice could be NativeScript. You will have to rewrite your HTML components using the cross platform layouts / components that comes out of the box with NativeScript framework, but still you can reuse your Angular Controllers, Models, Services etc.,

文档:

https://docs.nativescript.org/code-sharing/intro

https://docs.nativescript.org/angular/start/introduction

这篇关于Angular 5 与原生 IOS/Android 通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆