I have a phonegap app and I want to execute Javascript code in a background task. When the application enters background I start executing a javascript function which takes data out of a web database and sends some values to a web service, the returning data may toggle a push-notification to the user.
I found either how to call javascript from Objective-C here on Stackoverflow and how to implement Long-Running Background Tasks in the iOS SDK Documentation pages, but I haven't found anything in combining both (what I think is e.g.: When I invoke javascript code via a webview, does this View even exist when the App is in background?) so I want to ask some more experienced iOS Developers if this is even possible.
I don't think its really possible. Javascript requires a UIwebview to run (in realtime) and must be visible to the user. When an app is put in background only a small amount of tasks are allowed to run- webview not one of them.
Your better off sending your data to a web server that runs a cron-job or similar to send out a push notification via apples push notification server - You can also bypass this and use a service like http://urbanairship.com/
I experimented with this on iOS 5+ and it's possible. I created a small PhoneGap plugin that demonstrates how this works. Check it out, and see the README for most of the info.
https://github.com/jocull/phonegap-backgroundjs
Related
My app has an UNNotificationServiceExtension object that exists in a separate project, which handles the receipt and processing of notifications.
I'd like to be able to trigger an event in the main app under certain circumstances, whether the app is active or not. Is this possible? If so, what mechanism would I use to achieve this?
If not, I'm worried that I'll have to use the main app to poll a shared data source when it's activated and respond to the data it reads.
Hmm.. after a bit of googling I found this:
Using URL Schemes to Communicate with Apps
This will allow me to communicate between apps.
How can you trigger touch and type events outside of your app. I already have created a service that can collect certain data but I can't trigger clicks.
P. S. My requirement is to have a device cloud hosted on the internet and allow people to access them remotely
This is not possible. Apple would never allow such a huge security risk.
You misunderstand how Seetest works. Seetest requires access to your App's binary code, which it instruments:
https://docs.experitest.com/display/public/UFT/iOS+Applications
It then simulates user events by calling event handling methods, e.g. #IBAction handlers. It does not go to the low level that you want, because nothing can unless you violate Apple's usage rules.
EDIT
I was assuming you wanted to write an iOS App that could generate events outside of its sandbox. Instead I think you're referring to Instruments which is controlled by a host.
Because this is a general question, see if this gets you in the right direction:
https://developer.apple.com/library/ios/documentation/DeveloperTools/Conceptual/InstrumentsUserGuide/UsingtheAutomationInstrument/UsingtheAutomationInstrument.html
I have managed to do this using Appium java API. First launch a dummy app, then call driver.back() and from there, you will have full control
I can not use
UIApplication.sharedApplication().beginIgnoringInteractionEvents()
in WatchKit Extension, I have error:
'sharedApplication()' is unavailable: Use view controller based solutions where appropriate instead.
Is there some alternative ?
The short answer is: No there isn't.
The long answer:
Please keep in mind that the extension is not executed on the watch but on your phone. So if you would call UIApplication.sharedApplication() it would return you the application of the extension on your phone, anyway! Everything you do inside your extension is stuff that manipulates the extension on your phone. The only exception from this are the WatchKit methods. And even they are basically calls that are converted into instructions that are send over bluetooth to tell the watch what to do. At no time you can write code that executes on the watch!
You have no control what so ever about what the watch does with the instructions you send to it. You are basically acting as a server talking to a client and you have no control over the client. You should send as little instructions as possible and once you send them, your task is done, the rest is up to the watch.
That being said, you should carefully plan your UI in a way that you do not need any calls that manipulate the event delivery. You should focus on simple 'if user taps x I do y' interaction.
Another thing to keep in mind is, that your extension can not communicate with your main iOS app. You can create a shared app group between your iOS app and your watch extension to share data between them, however you can not directly communicate with your app. If you want to use parts of your apps logic, extract the module in question into a framework (this has become very easy with Xcode 6) and use the framework in both, your app and your extension.
I was wondering how it works to make changes to an app without re-uploading the binary and go through the whole process again. I have got an example for it:
The developer of Whatsapp made changes to his app twice already, just today for the second time. This "update" included the blue indicators which show wether the chat-partner read your message or not. The 1st time I noticed changes to the app without an update was when he introduced voice messages.
Does anyone have an idea how this works?
You can use Google Tag Manager to make simple tweaks to your app without having to update the entire app. Here is an overview of how it can work (I've used this on Android apps)
Suppose your app's interface is supplied in whole or in part from a server - i.e., it's really a web view showing HTML that you are serving. Then you can just change the code on the server.
I have been asked to develop an app that will record and later "play back" touches and gestures onto another app running in the foreground.
From my experience and knowledge, this is not possible unless both apps are setup to send/receive data between them through notifications or other methods. Also, it would be a huge risk for apps and their data to be exposed to anybody.
I am 99% sure this is not possible, but was just curious if anyone else has come across something similar (or documentation that specifically states this is forbidden).
Nope not possible, no way no how, dont even try.
Expanded answer, if this runs on a jailbroken phone.......
Yes.... but good luck,
check Saurik's Veency code for this sort of functionality, it would have to be refactored signifcantly but basically it allows for virtualization of taps.
https://github.com/iceNuts/TouchTest
http://gitweb.saurik.com/veency.git
if you want to access another application in your iPhone ,you can set the url scheme parameter and so on.You can add callback in your url,then you can return back your application.
It's actually possible with facebook's idb:
https://github.com/facebook/idb/
As it stated:
Remote Automation. idb has a “companion” that runs on macOS and a python client and cli that runs anywhere. This enables scenarios such as a “Device Lab” within a Data Center or fanning out commands to large numbers of iOS Simulators.
As facebook stop support on WebDriverAgent, it's the best option we have right now