runInMillis silently fails when in App's initial Pref page

G'day !

I'm finding that when I put a runInMillis inside an App's initial Pref page, it doesn't run when the app is first loaded and the initial page is shown. I have a need to have something run just before the 2nd page, but slightly after the 1st page is shown... actually I'm finding that the app isn't fully setup/active when the initial Pref page is loaded/shown. Is there some state and object instantiation delays that prevent certain network and timer based tasks from being executed ??

I guess an alternative would be for me to switch between two initial page, refresh the first page, and on the refresh (after 1 second) run the time-delayed task and show the second initial page (which is the essentially the same as the first) and but don't refresh the 2nd page. Overly complex, but I guess it would solve the problem of runIn / scheduled tasks not running on 1st app load.

Not sure if this could explain your problem, but apps are not truly installed until the user hits "Done." Perhaps scheduled jobs are one thing that doesn't work in this case (I know network calls, at least HTTP methods, do work). Some developers detect this and ask the user to hit "Done" and re-open the app; Hubitat also provides installOnOpen: true that you can add to the definition() in your app and have it do this automatically when the app is opened for the first time without the user needing to hit "Done."

So, my suggestion: see if it works after your app is really installed, either hitting "Done" and re-opening it or adding this line and trying again with a new install. (I wouldn't over-use installOnOpen if you don't need it given that it won't abandon and eventually remove the app if the user never completes setup, but it has good uses in some cases.) Again, I'm not sure if this explains the problem, but it should be easy to test.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.