PhoneGap application requires native iOS code for background service? - ios

I have a PhoneGap app and it checks your location every 5 minutes and reports it back etc.. to do this When the app needs to run in put at the background .
For Android I have written native code but for iOS will this work?
I'm not even sure how you would implement native objective c into PhoneGap as they are very different compilers etcthe it pause.
Any advice would be appreciatedWhen it come back to front, it will resume all remaining operation.

You need to write a Plugin to do this. A plugin will allow you to write Objective-C code and link it back to a JS function. Here are a few tutorials:
From Apache
From Adobe
Another
Here is also a big list of Plugins people have already created: iOS Plugins

Related

Is their an equivalent of react natives "Hot Reloading" for native iOS Simulator development?

I'm wondering if there is a way to see UI changes in an iOS application without having to restart the device or simulator. I know in react native since they use Javascript you're able to make a change to the background colour of a view and the background would reflect that change without having to restart the simulator. So I'm thinking since react native just converts javascript into native app code this might be possible in Native Development? Yes no maybe?
Doing normal native iOS development in the typical way -- no.
But, if you reproduce what ReactNative is doing (defining a data format for UI, loading it, and then wiring it up dynamically), then you can re-create it.
You might want to look into SwiftUI, which gives you a way to preview in Xcode without running the entire app.
Without that, if you use modules for all your UI code, you could incorporate a playground and see live changes as you code as well.

How can I call with native Swift methods from Electron app using javascript?

I am looking to add in-app subscriptions to the mac desktop app so I can submit to app store.
I have the code written for iOS using the cordova plugin: https://github.com/AlexDisler/cordova-plugin-inapppurchase
But for electron there exists no such plugin.
So I can use the native swift code from the plugin, but need a way to write a custom plugin so I can call swift methods from javascript running the Electron app.
Please let me know how to approach this, or point me to the correct resources.
Thanks You

Is it possible to create a IOS app that can download plugins and extension later?

we have a ios app that provides the platform for many similar games. When you install this app. This app already contains binaries of x number of games.
Now we are having size issue. So just wanted to know is it possible to create a ios app that can get installed and after that as per user selection can download the games binaries separately and then run. Like a app that can download games as plugins or extensions.
I work on game side part so i dont know anything about ios apps. but so far my understanding is -> when you create the ios executable then while compiling you should have all the code present (app + all the games it will run).
It is not possible to download a native executable and run it -- that is not a capability provided by app extensions.
One loophole you might consider: it is perfectly permissible to download and run javascript, or anything else that runs in a UIWebView or WKWebView, which are both sandboxed from your iOS App's process, and have access to OpenGLES 2.0 in the form of WebGL. There are also apps which have been accepted in the App Store which can run code in interpreted languages like Python.

Porting native apps to Phonegap?

I have a native app for iOS and am being tasked to create a new app that includes portions/sections of that original native app within this new project. The caveat being that the app I am now tasked to develop must be done with Phonegap/Cordova.
My question is, what options do I have for utilizing the native code within the Phonegap project, or does the same functionality all need to be rewritten in HTML5/JS? I'm new to Phonegap so I don't fully know it's capabilities.
Generally phonegap apps are coded in javascript, css, html and where ever they need access to the native layer, they use phonegap plugins to access the native functionality. If you want use your existing code for integration into a phonegap app, you can do it by wrapping your code using phonegap plugin architecture and create plugins for the functionality from the code that you wish to reuse. Then you call those plugins where ever required in your application.
The below link is good starting point for creating plugins.
http://docs.phonegap.com/en/3.4.0/guide_hybrid_plugins_index.md.html#Plugin%20Development%20Guide

Since iOS does not allow you to run JS in the background, is it possible to keep your app (alive/running) in the foregound?

My phonegap app tracks a users location via watchPosition() and it is important for the app to continuously run.
iOS provides a service that notifies your app of significant location changes. That's not something you can access directly in JavaScript, but you can create a plugin for PhoneGap (or just modify your app's native code) to register for those notifications and call a routine in JavaScript.
This will do it:
[UIApplication sharedApplication].idleTimerDisabled = YES;
There are limitations to frameworks such as PhoneGap.
If you need to be able to have it running in the background, getting location information, your best bet is to write is a native application, so you can take advantage of what IOS offers.
You may want to read this, to get an understanding of when apps can be running in the background:
https://developer.apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html
You can in theory run a JS app in the background, but you would first need to make a PhoneGap plugin that provides access to iOS background processing.

Resources