I would like to add a code for a background service which may track all events (names of current View Controller, name of called method when executed, etc...). It is a little bit like analytics api but in some way different.
I have successfully programmed a background service with NSTimer which execute every 5 secondes, but I can't figure out how to detect executed actions on the device (I have tried to see console log, but nothing there !)
Could you please help me.
Thanks in advance
Related
I have some code that needs to get called frequently, such as check what day it is, if it's the next day then move the day strings in the tableView.
Now I thought that the viewDidLoad would get called all the time and so it would be 'fine' to put it in there. However, I've left the simulator overnight, and I've pressed the home button and clicked again, changed VCs etc. and viewDidLoad hasn't been hit.
What are my options for doing sporadic checks such as, is it a new day? As x happened etc.
In this specific case, you can subscribe to NSCalendarDayChangedNotification to be notified when the date changes and respond accordingly in your view controller. In general, didBecomeActive or viewDidAppear would likely work.
What are my options for doing sporadic checks such as, is it a new day
It depends what the meaning of "is" is! In particular, "is" when? You say "sporadic", but that's just fluff. When do you need to know this? To what stimulus do you want to respond? When the user opens your app? Then put it in applicationDidBecomeActive. Every day at noon? Then run an NSTimer. Really, the problem here is that you don't seem to know, yourself, just when you need to perform these checks.
Whilst in your app, its quite easy to continually check for something. You simply create a background thread. However, what you describe is a thread that persists from outside the app's lifecycle.
Have a read on this documentation provided by Apple itself. You have to have good excuse to put a background thread. The scope of such thread is limited to only certain scenarios such as downloading background stuff, playing sounds etc.
For your scenario, I'd look at applicationDidBecomeActive(_:) found in your Application Delegate. There you can mimic such continual check. Beware however, don't put heavy word load on start up or your app might be killed automatically if it fails to become active in reasonable amount of time.
I need to scan a website for changes every few minutes and when difference occurs i need inform user with popout window that contains information about that change.
Problem is i can't find solution to that, i tried putting that code in applicationDidEnterBackground but it didnt work. I'm new to swift and mobile programming at all so please be understanding.
Where should i begin? Little tip maybe.
Thank you!
I have couple method that depend on the network status indicator being hidden or not based on my App. I was wondering if it is possible something outside of your App control is able to turn it off or on. Any clarification will be appreciated. I downloaded an App in background and received an email in the background the indicator didn't show.
If you're referring to the networkActivityIndicatorVisible property of UIApplication, I don't believe any outside application will manipulate that property, since it is specific to the running application.
I assume you're asking because of this question, and I would recommend, like others have, not to use this to determine whether a network call has completed or not. I would put the code you want to execute at completion in a callback or delegate, depending on how the call is made. Attaching it to the networkActivityIndicatorVisible property can lead to problems if you have code in the future that shows and hides this, but you don't want this method to execute anymore.
I am using GWT 2.4.
I am using Scheduler.get().scheduleFixedDelay(new Scheduler.RepeatingCommand() and Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() when needed.
For some reason, when I am debugging the website a timer fired event is being shown frequently even when I am in the login page(where I do nothing besides showing username and password).
Why is this happening? It is because of this, that the scrolling looks unresponsive.
Please note that I am remotely debugging the website by connecting my ipad to macbook.
Attached is a screen grab. Any help will be greatly appreciated.
When you say
a timer fired event is being shown frequently
Do you mean that the RepeatingCommand gets executed over and over ?
As soon as you call scheduleFixedDelay, the scheduler will execute the RepeatingCommand as long as the execute() method returns true.
I am in the login page
How about writing a log to see if the scheduled command you are talking about in the question gets invoked, even if you're not logged in ?
I found the reason for the delay. On each touch start I was getting all the text and applying a property like html.getElement().getStyle().setProperty("webkitUserSelect", "none") as part of my requirement. The data in that html is pretty big and to keep doing it on every touch start was causing a delay. Got rid of it now.
I've made an application that is pretty simple, it just lets the user capture a number and then saves it in a SQLite DB.
Sometimes, not very common thing, when the user is entering the number to save in my app and he receives a call, answers the call, and then finishes it, the application is frozen after the call, can't do anything on it, not even return to the previous screen.
Does anybody have a clue on what can this be?
The code in this application is so simple =/, I have no idea what could it be.
Thanks in advance!!
How is it frozen? Have you attached the debugger and looked at your processes/threads to see what they are doing?
Could it be a painting issue rather than true freezing?
Need more information.