How do i handle MessageBoxes with Expensify WP7? - windows-phone-7.1

I have a Windows phone 7.1 App, and I'm trying to implement som UI tests using Expensify's WP7Test framework and SpecFlow's Gherkin-feature.
I'm having real trouble testing whether my application is started correctly when run for the first time, because i prompt the user with MessageBox'es about access for GPS and Internet before the main screen is shown.
Firstly this code was (rather crudely) in the "App" Class constructor - i tried moving it to the "OnNavigatedTo" method of the MainPage, same result.
Trace:->Command timed out waiting for send
Trace:->Command timed out waiting for send
Trace:->Command timed out waiting for send
Trace:->Command timed out waiting for send
Trace:->Command timed out waiting for send
Trace:->Command timed out waiting for send
Trace:->Command timed out waiting for send
-> error: App is not yet alive
It work's perfectly when i comment the messagebox'es out, but i really want to test them as well - my MainPage renders accordingly to the answers of those prompts!
I have tried a lot of diffrent Steps in the Scenario for starting the application:
Given my app is clean installed and running /
Given my app is running within 20 seconds /
Then my app is running /

Because the test framework interacts with ui elements it has to use the ui thread - so I guess you messagebox is somehow blocking the ui message pump here.
Perhaps this case is caused here because this is your first page... but I'd need to do some testing to check.
One simple workaround could be to use the asynchronous message box methods for your functionality - but this would require you to reorganise your page init functionality a little.
If this is a serious issue for you, please do log an issue and a sample test in github.

Related

NodeMCU resest with mqtt.client:close()), or mqtt.client:connect()

I have an application that uses mqtt for communication between modules and with a mobile terminal.
In some situations when the messages do not arrive, the node performs a self test of MQTT (sending a msg to itself), and when the selftest fails, tries to reconnect to the broker (mqtt offline not always arrives). And then two problems may arise:
If I perform a mqtt.client:close() to assure that the client is closed (to avoid the second problem) and the client is already closed, the node resets.
If I perform a mqtt.client:connect() and the client is still connected, an exception and a restet occurs.
is there a way to know if the mqtt client is connected or not?
Thanks for your comment. I am going to describe what I am doing, to see if you can help me:
I have two independent system, a master and a slave. The master publish a test message every 10 minutes. If there is no answer from the slave. it publish a test message to itself. If this self test does not arrive, a disconnection from the broker is assumed, and a reconnection is initiated.
And here is where the problem comes, sometimes the client is disconnected and everything go well, but sometimes it is still connected but unresponsive, and the node resets with an exception "already connected".
Performing a mqtt:close() previously to the reconnection, should be safe, but if I send it and the client is truly disconnected, the node resets without any reason (known to me).
All this is happening without receiving any offline message.
Instead of waiting for messages manually sent by the master client (which could fail to send for various reasons, leading a listening device to the wrong conclusion about the state of its connection to the broker), I recommend using MQTT's built-in connection management.
First, you can make sure that each client's initial connection has succeeded by including an error handler in :connect(). If the client really opens, nothing in the NodeMCU documentation indicates that it will close itself; it may go offline.
Once connected, the client only knows that something is wrong when it sends a message and does not receive a response. It sounds like you are not calling :publish() much (which would otherwise let you know by returning false), so pinging may be best. If you expect to receive a message from the broker every n seconds, set a keepalive time slightly higher than that on the client.
Then, failure to get a response to those messages should trigger an event that you can respond to. That might be something like the following (not tested, may work better called outside the callback):
m:on("offline", function(client) m:close() end)

iOS App - how do people handle Internet connection downtime to provide the best UX?

I'm about to begin building my 2nd React Native app and I'd like a friendlier way to handle any Internet connection downtime should it suddenly drop out. Currently I check for a connection when executing any Fetch call and then use try/catch to display a retry component if it failed. This renders a button which re-calls the function on-press. I'm Just curious to see how other people handle this and whether I can improve my users experience!
I would have it retry 3 times automatically. If your app can partially function offline, then you can just show that part as offline and continue to try and update every second or so.

iOS application quit due to slow net connection

I am working on iOS application in swift. I need to parse two web api(XML) at application launch time and during this period, I need to show launch screen. So I sent a synchronous request to parse the data from server.
If net connection is good then application working fine but due to slow net connection or it takes more then 20 seconds to load data from server it can quit automatic.
How to fix this issue. Please suggest it.
You should never send synchronous requests in main thread!
Add new VC on load. There you can load your data async. When data is ready, pass it the next VC.

iOS. Measure time in setKeepAliveTimeout:handler: while waiting for server response

I am developing a VoIP app. When my app is in background I need to check if the server is still there. So I am trying to use setKeepAliveTimeout:handler: to make polls to server while app is in background.
The question is: how to ensure that I receive response or timeout within 5 seconds after I have sent poll message to server? If I don't receive response/timeout within 5 seconds the next opportunity to know that server is dead is only after keepAliveTimeout time which is not that good.
As I understand I can't setup NSTimer in setKeepAliveTimeout:handler: since we are in background (and NSTimer relies on run loop).
I see other possibility which is: make while loop and check for the current time in it. Although I would like to avoid making busy loops.
Could you please suggest me how can I achieve needed behaviour?

iPhone network requests are not working sometimes

In my app I'm using MKNetworkKit to make requests to my server and also make direct calls to Facebook using Facebook SDK. Sometimes (once in a few days) I get an odd issue: all network requests from my app stop working (both to my server and Facebook). I can't figure out what steps exactly cause this. When I have the issue I check other apps / Safari from my phone and internet connection is OK. If I close my app, wait for a couple of minutes and open it again then everything goes back to normal. I'm using WiFi for testing. What can cause this?
It seems to be exactly like in this question: iPhone app gets into a state where network requests never complete , although I don't use MonoTouch.
UPDATE:
I do receive callbacks from MKNetworkKit saying "Request timeout" (I have 10 seconds request timeout in MKNetworkKit settings). And I don't receive callbacks from Facebook.

Resources