Listen for TileOpened event in background task? - microsoft-band

How do I go about triggering a background task to occur when a user opens the tile on the band while the phone app is suspended?
Alternatively, how would I make my background task constantly listen for the TileOpened event?

On Windows (Phone) 8.1, background tasks cannot be triggered by ad-hoc input from a Band. To receive events the application must be running, either in the foreground or background, with an active connection to a Band, and with a subscription to a Tile event.
Background tasks on Windows (Phone) can only be triggered at most every 15 or 30 minutes, which means that they are not generally suitable for polling for Tile events as it's unlikely they will be running at the time the user opens a Tile.

Related

BLE app is suspended when running in Background on iOS 12

Background
I have an iOS app which scans for BLE devices in the Background. It worked well until I updated to iOS12. This is what I have:
App is configured to run in Background (e.g. location & bluetooth-central keys in .plist)
App is supposed to run continuously in Background, scanning for Peripherals. This is not to be confused with Background Fetch, which is a different use case.
App does not connect to Peripherals. It only reads the advertisement packets.
App gets suspended after running for a few hours in the Background.
App resumes normal operation when brought to the Foreground
App operated properly in iOS 11. Problems started after updating to iOS 12.x
I placed log messages in the App Delegate methods. This last thing I see is the app entering Background State. I never see a call to applicationWillTerminate(), as it is only called when the app is in the Foreground.
I have seen other posts (e.g. iOS 12 terminates apps in the background for no reason) for similar behavior with the Location stack. Using the test app written by the author of the post, I verified the problem has been fixed in iOS 12 for Location Services. But the BLE problems persist.
Has anyone found a workaround for this problem?
thanks in advance.

HKWorkoutSession not resuming custom workout app if screen gets locked or active app changed

I have a watchOS 2 app that displays health data during a run. I start a workout using HKWorkoutSession as follows:
self.workoutSession = HKWorkoutSession(activityType: .Running, locationType: .Outdoor)
self.workoutSession!.delegate = self;
self.healthStore.startWorkoutSession(self.workoutSession!)
This keeps my app in the foreground when the screen shuts off for a while and the user looks at it again later.
Now lets say during the workout the user switches to a different app OR the watch screen locks (due to the watch not being secured tight enough) and then the user re-launches my running app by double clicking the digital crown. The app resumes where it left off and continues to get health data as expected, but my app won't stay in the foreground anymore. The workout is still in progress because on the watch face I can still see the workout icon at the top, and the heart rate monitor continues to collect heart rate data, but the app refuses to stay in the foreground.
Does anyone have any idea on how to have a workout app resume to the foreground during a workout even if the screen locks or a user switches to a different app?
I contacted Apple using one of my 2 yearly technical support requests. According to the representative I talked to, he believes this is a bug in watchOS. I had submitted this as a bug report way back in October, but the ticket has gotten no response so I thought I was perhaps missing something. I guess we are stuck with how this works for the time being.

Can I use blocking API on WinRT?

We are planning to use sqlite pcl library for WinRT store app using this project: https://sqlitepcl.codeplex.com/ . All the api is blocking. Will there be a problem during app store review by Microsoft, if we use it?
Of course the api will be wrapped in Task.Run, somethin glike:
public Task InsertTestSetForUser(TestItem testItem, long userid)
{
return Task.Run(() => InsertTestSetForUserInternal(testItem, userid));
}
I knwo that there is an impl of sqlite with async API, but that would not be portable out of the box for Xamarin, which we use for porting to iOS and Android.
There are a few requirements your app has to meet. The three most important ones regarding your question (imho) are these:
Your app has 5 seconds to start on the splash screen. If your database setup takes longer, consider using an extended splash screen or a background task.
The app must render the first screen or a splash screen within 5
seconds after launch.
Your app must be responsive within 20 seconds (which is basically 5 + 15 seconds).
Within 20 seconds after launch, the app must be responsive to user
input.
If there is an operation on the UI that takes more than 3 seconds to process, you have to use some kind of status indicator (e.g.: an indeterminate progress bar).
If an app performs an operation that causes the device to appear to be
unresponsive for more than three seconds, such as downloading data
over a network connection or transitioning between a screen or page,
the app must display a visual progress or busy indicator.
So you see: There is no definition what blocking really means in the certification process. Just be sure to use Tasks for long operations that are triggered from the UI and display some kind of process / status to the user when the operation takes longer than expected. As long as your app stays responsive it will not fail certification (passing the WACK test is important, though).
For more information see: http://msdn.microsoft.com/en-us/library/windows/apps/hh184840(v=vs.105).aspx

Detecting browser window close event in flex?

Is it possible to detect in Flex application browser window close event so that an action can be
started when user closes Flex application, does anyone know how to do that if it's possible in the
first place? The reason why i am asking this is because i have a multiuser Flex application where
every user has it's own directory on a server side. Application has logout button which triggers
cleanup of user's directory but what if the user just closes the window? I would like to be able
to lunch that same cleanup upon browser close window
In the page hosting your app, write a Javascript function triggered by window.onbeforeunload, and this function can call a function inside your Flex application.
Note that the onbeforeunload function is not guaranteed to work for all browsers.
I would not recommend that approach because the closing action fails too often, meaning worthless. My browser freezes and force-quitted several times a day. My computer sometimes freezes. My internet connection sometimes dies. I think, some browsers even do not guarantee those kinds of actions executed every time.
So, the session timeout might be one safe way in most cases.
You can also try having a socket connection, so that your server can ping if a user is alive and also can detect if socket is closed. Even socket, however, can be unresponsive or can be disconnected sometimes while user is still using the application.
You might want to be strategic.

IBM Worklight - How to use Worklight in a background process

I have an application that should run continuously even after the user presses the back button.
It has to send some data using POST method to my database in a remote server for every half an hour. This should happen even after the user has pressed the back button and the app should only stop when the mobile is switched off.
While I have set up the HTTP Adapter to send POST data and also an HTML file to call the adapter procedures on launch, I dont know how to make it background or which code to run to keep sending the POST data every half an hour.
It sounds like you are running on Android.
The expected behavior in Android is that pressing the Back button QUITS the application.
Moving to the background is performed by pressing the Home button.
So, I don't think you should do this when pressing the Back button... or maybe you should at least present the user the choice of either quitting or moving to the background (you can override the Back button by using WL.App.overrideBackButton).
That said, I am not familiar with a programmatic method to move to the background instead of quitting (maybe there is an existing Cordova plug-in or another way that does this).
The other way to accomplish this is by using an Android Background Service, however, Worklight does not have support in its Native API to do this.
As for what happens when the Worklight application is in the background, I have never tried it myself, so I cannot be certain at all, but try using WL.Client.setHeartBeatInterval to keep alive the connection to the Worklight Server and write some logic that sends the adapter requests. See if that would work for you...
I have found this:
How to create plugin in phonegap to run the application in background?
Maybe you'll be able to massage it into your Worklight project (in case the heartbeat approach above does not work).
More information on running in the background:
Android:
http://developer.android.com/training/basics/activity-lifecycle/index.html
http://developer.android.com/reference/android/app/Activity.html
iOS:
http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html
Override the Back button by using WL.App.overrideBackButton.,
remove the exit function in that method and leave it blank (if you want the background process not to exit when clicked)

Resources