2

I have iOS and android application already developed. I just want to add offline support on both platforms but I want to write business logic at once for both platform weather it will be written in NodeJs, Js or any other language that communicates with the local database as well.

Is that possible to implement such functionality? if possible then how? which language is most preferable for such situation?

Any tutorial, reference link will be appreciate.

Thanks

Kunal Yadav
  • 139
  • 10
Jatin Patel - JP
  • 3,725
  • 2
  • 21
  • 43

6 Answers6

3

In iOS and android you can run javascript without webview. It can be a way to mutualise some business logic. Never used it thought, but I talked with people who did, and are happy with it.

iOS : http://nshipster.com/javascriptcore/

Android : Use V8 JavaScript engine to execute JS lib without webview

Community
  • 1
  • 1
Boris Charpentier
  • 3,515
  • 25
  • 28
2

Yes, there are 3 ways to do it.

1). Cordova + Ionic. You may write your JS / Angular code, then you just add target platforms using next command:

 cordova run <platform name>

Platform name can be Android or iOS. You code will run in WebView and will behave equally on iOS and Android

2). React native. To be honest, I don't familiar with it, but guys from facebook says, that you can write your code once, for example for web application, and then reuse this code in mobile apps. Facebook app written in ReactNative.

3). https://github.com/google/j2objc In my opinion this is the best way. You write your code in Java, and then generate same code for Obj-C

Aleksandr
  • 4,906
  • 4
  • 32
  • 47
  • Is it possible your suggested way directly interect with SQlite database? if i write code in JS/Angular JS then how it will interect with our local database? is there Cordova provide way to interect? – Jatin Patel - JP Aug 24 '16 at 10:26
  • Cordova has https://cordova.apache.org/docs/en/latest/cordova/storage/storage.html#localstorage https://cordova.apache.org/docs/en/latest/cordova/storage/storage.html#websql https://cordova.apache.org/docs/en/latest/cordova/storage/storage.html#indexeddb Or you may use plugins for SQLite, like https://github.com/litehelpers/Cordova-sqlite-storage If you use j2objc , you have to wrap your DB storing logic under `interface`, and your business logic should get certain implementation in constructor param – Aleksandr Aug 24 '16 at 10:31
  • `interface` in Java = `delegate` in objC – Aleksandr Aug 24 '16 at 10:34
  • My application is already developed. So can you please suggest me which one is most preferable to extend support Cordova or reactNet? – Jatin Patel - JP Aug 24 '16 at 10:59
  • I'm not familiar with react native, that's why I can't compare them. If this problem was actual for me, I would choose cordova + ionic – Aleksandr Aug 24 '16 at 11:50
0

You can use ReactNative or Cordova plugin. With it you can write cross platform logic on JavaScript language. For more details see this tutorial http://www.tutorialspoint.com/cordova/

Alex Shutov
  • 3,217
  • 2
  • 13
  • 11
0

You can use Ionic framework to develop cross platform apps that will work on both iOS and Android.With Ionic framework you can develop app using web development skills like HTML,AngularJS,NodeJs/PHP for server side etc. Cordova has a large libraries of plugins that will help you in access various hardware of the device and make it look more like native.

0

If you have your apps already developed, then best solution for you is something like C++ frameworks. You can compile them for both platforms iOS and Android, and keep business logic in 1 place. All other solutions like ReactNative, Cordova, Xamarin etc, are too expensive for already built apps.

Pavel Gatilov
  • 2,570
  • 2
  • 18
  • 31
0

C++ can be used as common code to run on both the platforms. Meta (FB) is already doing it.

https://engineering.fb.com/2015/06/15/android/under-the-hood-building-moments/

infiniteLoop
  • 2,135
  • 1
  • 25
  • 29