Windows Phone 8.1 : UDP packets stop being transmitted when phone app is in background - windows-phone

Background Info
I downloaded the Thread Pool Sample for Windows Phone 8.1 (C++) and modified it so that the periodic timer sends UDP packets to a remote IP on a regular interval.
Problem
I noticed the following:
The UDP packets are sent out regularly when the app is launched from MSVS 2013 regardless of what you do on the phone
The UDP packets stop being sent out when the app is launched from the phone's program list when the app is put in background.
Question
How do you create a periodic task on Windows Phone 8.1 which runs every 10 seconds? The periodic task must send out a UDP packet to a pre-defined IP:PORT address regardless of what the user is doing on the phone.
I had a look at this one:
http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh977059.aspx
but I don't see the possibility of having the timed task run every 10 seconds.
How to reproduce the problem
Link To Test Project
The test project includes instructions on how to reproduce the problem that I've described.

Unfortunately, what you're after is not possible on Windows Phone. Once the application is no longer active on the phone, it is tombstoned and no longer runs.
You can achieve something similar with Background Agents, but they are restricted in what they can do and they only run every 30 minutes.
There are other background agents that respond to different phone events, including location changes, network availability changes and geofencing triggers.
There's a slightly hacky method available to force a background tasks, and that's to impersonate an audio player task. It's not a great solution though.

Related

How does apps like Whatsapp or telegram listen to the incoming call/message events on Android?

I built a VoIP calling app which maintains a persistent connection with the server to listen to any incoming calls. I implemented a background service to do this.
But since Oreo, this running code is now broken because of the introduction of Background Execution Limits
After looking into forums, I found that some people are suggesting
Convert Service to JobService and let android schedule it
Doing so, my app won't be able to receive calls when it is stopped
Run your operations in foreground services
It is annoying for some users to see a constant notification in the notification bar. So these above-mentioned options aren't working for me to fix my code for Oreo.
How does WhatsApp get the incoming (VOIP) call in Android (Oreo onwards) working around the Background Execution Limits?
(Sticky) foreground services are not affected by the restrictions. So you could use one those as replacement for background services on Oreo.
But foreground services have two disadvantages: They are less likely killed by the system in order to reclaim resources compared to background services, and hence affects the Android system's self-healing capability. And they require you to display a permanent notification. But Users are able to suppress the notification, somewhat mitigating this disadvantage.
I am assuming that you are using SIP to establish the connection and initiate calls. Without a service constantly re-sending REGISTERs, the app doesn't receive INVITEs when the server sends them.
A workaround for this problem is what is called the "push notification strategy". It works as follows, when the server sends a INVITE, it also sends an FCM notification to your app, This wakes up your app which then sends a REGISTER to your server, which in return forks the call to your app. Here is a video that better explains this strategy
There are two options:
use platform push services (APNS or FCM)
maintain persistent socket connection and exclude application from battery optimisations.

ios 7 fetch offline message from xmpp server

I am developing chat application using XMPP protocol.
My development target is iOS 7.0
Every think is working fine user can able to communicate only when they are online.
But I want to notify user message has come when they are offline.
I have tried iphone XMPP App run background
But it doesn’t work for me.
First think it is possible or not?
Using what VIOP, background fetch or some other way?
If yes please let me know. how?.
The thread you are referring mention declaring that your app is a VoIP app to be allowed to constantly run in background.
It is technically possible but has two drawbacks:
If your application does not do voip, Apple will reject it (as misleading).
Battery consumption will be excessive as you will stay connected.
The state of the art is to fallback to Apple push notification service when the TCP connection between the client and the server is not established. This is battery efficient and provide a very good way to notify the user of new messages.

Check if process is running with VB.NET (Compact Framework 2.0)

I am working on an (console) application, which should be executed on startup and keeps running all the time in the background (executing something every 30 minutes).
How can I, in another (device) application, check if my console application is running (and start it if its not)?I am using VB.NET CF 2.0 and everything is being deployed on a device running WM 6.5
All the code examples I found where only available on the "standard" .NET.
There are several ways your "monitoring" app could work (and certainly more than I list here).
Use a named mutex (you'll have to P/Invoke it). The monitored app would create and hold it, and the monitoring app would periodically check to make sure it's held. If it's not held, the monitored app is no longer running.
Use the Toolhelp APIs. Have the monitoring app use the Toolhelp APIs to periodically enumerate the running processes. If the monitored app is not in the process list, it is not running.
Use a named event. The monitored app would have a background thread that periodically sets a named (watchdog) event. The monitoring app would wait on that event and if it fails to get the event in a certain time bound, the other app is either not running or has locked up.
Use a socket. Have the monitored app open a socket and listen on it. The monitor app would send a "ping" periodically to the monitored app. The monitored app would respond to the ping with an ack. If the monitoring app doesn't get an ack, the monitored app is either not running or is locked up
Use a window handle. The monitor app periodically P/Invokes GetWindow of FindWindow to find an always-present window in the monitored app - often by Form text. If the monitoring app can't find the Window, the monitored app is not running.

Monitor Windows 8 App Connections

Case: I have got a windows 8 tablet and have an app running on it. What I was looking for is a program or a mechanism through which I can be able to monitor all the incoming and outgoing http/https connections that are made by the app which I am monitoring. I am able to do it on the android and ios tablets, but not sure how to do it on a windows 8 tablet.
Is there anything (like an app or a logging program) that I can install on the tablet to monitor connections? Thanks.
You can use Wireshark or NetMon to see the traffic on the network. Neither will run directly on Windows RT, but that's not necessary. As long as you are running on the same network with the tablet you are trying to monitor, you can capture all the traffic you want.

Can iPhone app which runs in background send data over network to a remote server?

This application is location awareness app. It uses GPS details so it can be run in background. But is it possible to send the collected data to a remote server while the app is in background? or maybe when the screen is locked?
For Required background modes add App registers for location updates in plist, this will make application work in background and you can send location updates to server.
Here consider that your location services are not continuously on, else it will drain complete battery of device.
Hope this help you..