Discussion Forums  >  WebViews and HTML for Mobile

Replies: 8    Views: 114

perrytheweaver
Apple Fan
Profile
Posts: 51
Reg: Jun 14, 2011
Rowlett, TX
3,460
02/10/13 07:26 PM (11 years ago)

Reload custom URL when app comes to front

I need my app to reload its custom URL home page whenever the app is focused or brought to the front (an instance of it may already be running in the background, so it's not a matter of restarting the app). It is not a matter of NOT caching the custom URL; I need to force a reload of the page when the app is brought to the front. So, how to do that? Thanks!
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/10/13 07:53 PM (11 years ago)
I'm not sure 'exactly' how to do that, but it sounds like you'll need to edit the code for that kind of enablement. And that would need to happen on each platform you're creating for. Although, I suppose you could 'cheat' and put a Refresh HTML Tag in the document, and let it refresh itself every so often... If you want every 15 seconds... <meta http-equiv="REFRESH" content="15;url=http://www.thispage.com"> Cheers! -- Smug
 
theMonster
Code is Art
Profile
Posts: 435
Reg: Oct 18, 2011
US
8,050
like
02/10/13 07:54 PM (11 years ago)
Should probably specify which platform your talking about. That or just use @Smug's answer. -tM http://thecodemonsters.com/
 
perrytheweaver
Apple Fan
Profile
Posts: 51
Reg: Jun 14, 2011
Rowlett, TX
3,460
like
02/10/13 07:59 PM (11 years ago)
Both platforms, iOS and Android. The meta refresh option probably would refresh at odd times, not just at refocus on app. But I'll keep digging... Thanks!
 
Outbreak
buzztouch Evangelist
Profile
Posts: 452
Reg: May 30, 2011
Colorado
14,620
like
02/11/13 07:37 AM (11 years ago)
What if you use the native app plugin. It should open a new page in the browser every time when starting that page. It isn't inside your app, but at least you you might get your startpoint right.
 
perrytheweaver
Apple Fan
Profile
Posts: 51
Reg: Jun 14, 2011
Rowlett, TX
3,460
like
02/11/13 09:03 AM (11 years ago)
I need the custom url page to reload in the app, not a native browser. My current thoughts are to just supply a "refresh" button in the app to reload the page at the user's request.
 
perrytheweaver
Apple Fan
Profile
Posts: 51
Reg: Jun 14, 2011
Rowlett, TX
3,460
like
02/11/13 04:36 PM (11 years ago)
Ok, think I figured this out for iOS, at least. In yourprogramapp_appDelegate.m, around line 706 you'll see function: applicationWillEnterForeground //applicationWillEnterForeground... -(void)applicationWillEnterForeground:(UIApplication *)application{ [BT_debugger showIt:self:[NSString stringWithFormat:@"applicationWillEnterForeground%@", @""]]; //set ui as visible... [self setUiIsVisible:TRUE]; } Modify it like this: //applicationWillEnterForeground... -(void)applicationWillEnterForeground:(UIApplication *)application{ [BT_debugger showIt:self:[NSString stringWithFormat:@"applicationWillEnterForeground%@", @""]]; //set ui as visible... [self setUiIsVisible:TRUE]; //load the applications data [self loadAppData]; } This seems to force a reload of the app data when the app becomes "active" after being in the background, and in my situation that forces a reload of the custom URL, which is EXACTLY what I needed.
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/11/13 06:11 PM (11 years ago)
Nice find! Is reloading the entire app going to work for you? Or is the custom URL the 'main' app? Cheers! -- Smug
 
perrytheweaver
Apple Fan
Profile
Posts: 51
Reg: Jun 14, 2011
Rowlett, TX
3,460
like
02/12/13 07:29 AM (11 years ago)
@Smug, correct, the custom URL is the main page of the app. And that is the reason I want to reload when the app comes to the foreground. Otherwise I probably would not have to do this.
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.