Can wifi / geo triggers be invoked even if the Worklight app is not running, including not in the background? - ibm-mobilefirst

In Android, an app which is not currently running can be notified when certain event happens (like wifi scan results available, boot process completed) through Broadcast Receivers mechanism. Is this possible in anyway so that the wifi/geo triggers can be invoked even if the Worklight app is not running, including not running in the background?

Regarding wifi/connectivity changes notifying your app, that looks possible since it is a standard system event. It would likely take custom native code since you'd need to implement a broadcast receiver. And you'd need to register your receiver in your app's AndroidManifest.xml file. Take a look at http://developer.android.com/reference/android/net/ConnectivityManager.html and http://www.grokkingandroid.com/android-getting-notified-of-connectivity-changes/
Regarding geolocation triggers, it is unclear what sort of triggers you are looking for. This is all I see in the Android docs: http://developer.android.com/reference/android/location/GpsStatus.html and the standard broadcast actions at http://developer.android.com/reference/android/content/Intent.html#constants
If you are looking for something like geofencing, it would take application logic to determine when to fire events, so that means an app or service needs to be running. So although your broadcast receiver's onReceive() method can get called upon a geo event, who is going to fire that event?

Having the triggers activate when the application is not running at all (not even in background) isn't supported through the Worklight APIs.
You could try and use Worklight Android Native SDK together with cmarcelk's suggestions. Or you could use the Worklight Android triggers within a native service, together with the Broadcast Receivers mechanism so that it will run automatically on boot. You could then use an Intent to open the application from the trigger callback.

Related

Showing shell Toast notification on receiving message

I am trying to make a chat app using XMPP protocol. The app is working fine except it doesn't show message notification when the app is in background. In Android I have used a Service for this purpose, however in Windows Phone I couldn't find anything similar to this.
I am trying Background Tasks for this, but as far as I have understood, they're made to run on prespecified trigger and I cannot add any custom trigger to it. In Android I have put my socket connection and parsing message calls in the service itself so that they can run on background too and the socket doesn't get closed even when the app is stopped.
So my question is, is there any similar way to do it in Windows Phone 8.1 (WinRT, not silverlight) or if Background Task is the only option, can you suggest a way to implement the notification functionality. I don't need the exact code, I just need a push to the right direction.
First: You cannot run a network connection in background.
Suggested way is using PushNotifications:
Either directly with a Toast Notification
Or with a PushTrigger to handle a Raw Notification, work out what to do
with it (who was it from, prepare data, etc.) and then create a ShellToast from it. Adds flexibility and improves user experience, but is quite complex.
Known downside: You have to use a server.
Only workarounds: Background-Tasks that checks for new messages about every 30 Minutes.

Sending Push notification from client - Worklight

I know that push notifications are being sent from a backend server. Is it possible to send notification from client itself? My application goes like this: It acquires its position using Location services API. once it enters a specific circle, the trigger calls a callback function. What i want to do is to use the callback function to push a notification to the device. Is there any way to do this?
Thank you very much in advance!
If you just want a notification when the app is active in the background, you can use local notifications: https://github.com/katzer/cordova-plugin-local-notifications. The plug-in Javascript has to be modified somewhat to work with a Worklight app, but with some simple modifications it works great, and allows your app running in the background to raise a notification without going through the server side round trip involved when using push.
That said, I implemented an app that did exactly what you are looking for (in my case, I needed some server side processing to figure out what the text of the push message should be) The geo-fence callback called an adapter, providing it with event details and the device ID. The adapter determined what message to send, and used unicast push to send it back to the device.
You can invoke a procedure in the client side. I tried to invoke in the client side with httpAdapter and its working.
If the notification doesn't need to come from the server, you can also create a service that will run in the background and show a dialogbox once it enters the geofence.

iOS Running a timer within your code in the background

So I've read that in iOS, all timers will pause when your app is running in the background. I've also read that you can run tasks in the bg using beginBackgroundTaskWithExpirationHandler (like so).
What I am trying to achieve is to call a method once every 3 minutes, and another method a fixed-amount of time before the first one. I have managed to do this within one NSTimer which repeats in a way that lets me do this. It works fine but is obviously disabled (or paused) when the app is in the background - I can only assume because of the reason described above.
Does anyone know if there's a way to run a timer or at least call something after a specific amount of time so I can do this?
Basically if you want to continue running active in the background you have to meet one of the following requirements. From the Apple docs:
Implementing Long-Running Background Tasks
For tasks that require more execution time to implement, you must
request specific permissions to run them in the background without
their being suspended. In iOS, only specific app types are allowed to
run in the background:
Apps that play audible content to the user while in the background, such as a music player app
Apps that keep users informed of their location at all times, such as a navigation app
Apps that support Voice over Internet Protocol (VoIP)
Newsstand apps that need to download and process new content
Apps that receive regular updates from external accessories
Apps that implement these services must declare the services they
support and use system frameworks to implement the relevant aspects of
those services. Declaring the services lets the system know which
services you use, but in some cases it is the system frameworks that
actually prevent your application from being suspended.
http://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html#//apple_ref/doc/uid/TP40007072-CH4-SW24

Windows8: why use local notifications

I started off on the Win8 metro app (javascript) development recently. For notifications, it is clear how the WNS notifications will be useful for creating live tiles.
However the use case for local notifications is not clear to me. I have these two questions:
is it correct to assume local notifications make sense only for apps that would run in the background e.g. when other apps are running or when the system is locked?
if the above is not true, then kindly suggest some examples of when local notifications will be useful.
regards
CGere
Local notifications are useful to update your tile on the start screen that persist after your app was closed/suspended. For example you might want to update the tile when your app closes with some context, perhaps an image from the last level of the game they were on or such.
When your app goes to the background it has a short period of time to suspend after which your app will no longer be running and thus unable o update the tile. You can however create a background task to run on an event/timer to do some work (such as update your tile).

How to get notification for any application launched

i am working on an application for windows mobile 6.5, which need to know whenever any application is launched.
Is there any way to get notified when any application is launched?
Can we do something like this?
ManagementEventWatcher
I don't think there is a way to get an event when a new process is created. However, you can get a list of processes using the ToolHelp API, so it should be possible to get the necessary information, but you need to continuously poll in order to detect when a process is started.
Access to the ToolHelp API is not provided in compact framework but you can use the native API instead. An example can be found here: http://msdn.microsoft.com/en-us/library/aa446560.aspx
I think you're going to have to poll for the available processes using Allan's suggestion. I've worked on custom Windows CE shells, and they use the RegisterTaskBar(HWND) to receive notification when windows are created, raised, and destroyed. But that doesn't means every process has a window.