0

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.

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

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

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

georgeawg
  • 48,608
  • 13
  • 72
  • 95
SHANib
  • 708
  • 2
  • 14
  • 44
  • Have answered it here https://stackoverflow.com/a/58801490/4209778 if you are using WKWebView. – SHN Nov 11 '19 at 13:46

1 Answers1

0

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.

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.,

Docs:

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

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

Manoj
  • 21,753
  • 3
  • 20
  • 41
  • "communicate using JavaScript Interfaces" .. could you please elaborate how this can be done effectively in angular architecture ? – SHANib Oct 01 '18 at 13:24
  • This is a quick and simple example of how you can communicate in iOS. https://stackoverflow.com/questions/15537320/invoke-method-in-objective-c-code-from-html-code-using-uiwebview?answertab=active#tab-top Similar options are available with Android too. – Manoj Oct 01 '18 at 13:42
  • In Angular 5 .. we have to write this at any component level or as a common library file ? – SHANib Oct 03 '18 at 07:12
  • If you have a native app, most of the work will be on the native app side. Web app will have to trigger something which the iOS app can understand and operate accordingly - It has nothing to do with Angular. – Manoj Oct 03 '18 at 11:55