Discussion Forums  >  Uncategorized

Replies: 15    Views: 254

TechJeeper
Android Fan
Profile
Posts: 24
Reg: Dec 16, 2011
Lansing, MI
240
12/20/11 11:22 AM (12 years ago)

Refresh Content on First Load

Hello! I am scratching my head on this one... the issue I have is that when users first download the App from the Market, until they Refresh, they have the original content. Is there a way to either: A. Refresh upon install or B. Refresh every time they open the app My data is changing daily, and I have instructed users to refresh the app but some are still not listening. Thanks! TechJeeper
 
TechJeeper
Android Fan
Profile
Posts: 24
Reg: Dec 16, 2011
Lansing, MI
240
like
12/20/11 11:25 AM (12 years ago)
Oh yea, I am running BT-Server 2.0 and Android
 
Fred@mySkylla com
Android Fan
Profile
Posts: 5259
Reg: Oct 03, 2011
location unknow...
62,560
like
12/20/11 12:27 PM (12 years ago)
Does this help? About version about code & version name. http:// developer.android.com/ guide/publishing/ versioning.html
 
TechJeeper
Android Fan
Profile
Posts: 24
Reg: Dec 16, 2011
Lansing, MI
240
like
12/20/11 12:37 PM (12 years ago)
I was able to get version right, the thing that throws me off is without having to resubmit my app every time I change the content, say a user downloads the app right now, he/she would get the data from the content from the upload yesterday, even though I have made numerous updates to the content throughout today, that is until they push the Refresh button, then they get the latest. I am playing with ways to execute the refreshAppData(); function once either when the app first loads or every time the app is loaded. I tried it in the onCreate module but it makes the app loop, as I expected.
 
Fred@mySkylla com
Android Fan
Profile
Posts: 5259
Reg: Oct 03, 2011
location unknow...
62,560
like
12/20/11 01:06 PM (12 years ago)
My app update when I reopen, after I make a change. Those updates don't undo. Is that what's happening?
 
TechJeeper
Android Fan
Profile
Posts: 24
Reg: Dec 16, 2011
Lansing, MI
240
like
12/20/11 01:16 PM (12 years ago)
Yea mind dosnt seem to for some reason...
 
Fred@mySkylla com
Android Fan
Profile
Posts: 5259
Reg: Oct 03, 2011
location unknow...
62,560
like
12/20/11 01:26 PM (12 years ago)
Is this particular to this app, or other similar apps.
 
TechJeeper
Android Fan
Profile
Posts: 24
Reg: Dec 16, 2011
Lansing, MI
240
like
12/20/11 01:39 PM (12 years ago)
Ummm it's with the app I created with BT-Server 2.0...
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
12/20/11 01:59 PM (12 years ago)
Did you remove the Configuration URL from your app? That's what tells the app where to go for updates. It should point somewhere on your BT server. If you removed that URL, then you've effectively taken the app offline. If the URL is there, then there might be a bug here. Remember...BT-Server is beta software! Not a good idea to base production apps off it quite yet! Mark
 
TechJeeper
Android Fan
Profile
Posts: 24
Reg: Dec 16, 2011
Lansing, MI
240
like
12/20/11 02:03 PM (12 years ago)
Hey Mark, the Config URL is there and the BT_Config is unaltered. When I execute the URL I get {lastModifiedUTC:Tue, 20 Dec 2011 19:30:12 -0800} which was indeed the date of my last update. I know its beta, and the application I am running isn't mission critical, but it is working amazing and the users are loving it! I look forward to submitting issues, possibly such as this, and suggestions for the product to bring it closer to production worthy.
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
12/20/11 02:12 PM (12 years ago)
Excellent! Good catch then...hopefully the BT team will check it out! Mark
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
12/20/11 09:42 PM (12 years ago)
Hi Gang, I've been digging around with this this afternoon / eve. I would so rather be making plugins! LOL. It looks like we all understand how it SHOULD work. We realize what the data URL and the reportToCloud URL do, etc. So, we'll get a little nerdier to see if we can figure it out.. Open the project while you read this if you want. The file that handles all this is the app's delegate file. [yourAppName]_appDelegate.m. I just made a project on a test server running BT server and just donwloaded it. I drug the plugins into the project, then clicked RUN in simulator. I'm doing this while I type to see exactly what's happening. So, the first thing I see is the apps home screen (this is a non-tabbed app without splash page). One screen. Next, I opened the output console to see what's up. All sorts of good info is in here. The line I'm looking for is: myfirstapp_appDelegate: reportToCloud. This is about half way down the output. OK, it's reporting to cloud. The next line shows me the URL it's fetching to get the lastModifiedDate. I copied this URL in my mouse and pasted it in my browser to see what's returned. I get {lastModifiedUTC:Tue, 20 Dec 2011 07:06:09 -0800} OK. at this point, the app saves this as the last updated time. So far so good. A few lines down, it does some comparing now that it's established the 'lastUpdated' time. The first time the app launches, it determines that no updates are needed because a previous lastModified was not found. You and see this where it does: 2011-12-20 20:24:03.107 myfirstapp[4171:17303] myfirstapp_appDelegate: appModified.txt does not exist in the cache. Not checking for updates. Like @TechJeeper points out, just because the appModified.txt files does not exist on the device (that's the name of the file that remembers the last modified time) does not necessarily mean the data on the server (BT_config.txt) is the same as the data compiled in the app. In his case, it clearly does not so the new user of the app would not see the new content unless they refreshed - again like @TechJeeper mentioned. Hmm, I see where this could be confusing and not ideal. However, I think it's also a bad idea to FORCE the user to download data immediately after installing the app. This is true for a few reasons. It's also important that the app 'work' if launched for the first time when no internet is available. Apple does this all the time. They want to make sure that apps work, in some capacity, with no internet. This is one of the reasons it's so important to have a working copy of BT_config.txt included in the project when it's compiled, so it works without having to refresh. And, it's a bit tacky (in my opion) to install an app and have it immediatley prompt for an update. Like buying a new computer and it saying 'you need updates' - geez, really, I just dropped a grand on this thing and it's already out of date! Funny. Not sure what's best here. Maybe a 'force refresh' on launch if and only if a dataURL and a reportToCloudURL are present? Back to the logic: In your delegate.m file, find this method: connectionDidFinishLoading around line 503. This method runs after the reportToCloud method runs. It's purpose is to compare the last saved date with the newly returned date from the server and alert the user if something has changed. Look at line 543, it's saying: 'Yo, if we have a lastModified and a previousModified' then, on the next line, 'if we these don't match' alert the user... This works good on subsequent launches but not on the first launch because we don't have a previously saved lastModified value saved on the phone (this is running for the first time). I guess ultimately this debug session just clarifies how it's working but I'm not convinced the project should work any different. I'm not saying it shouldn't, I'm saying I'm not convinced it should yet. For sure this needs some serious consideration. In the meantime, it's an easy fix to get this to prompt the user on first launch if something has changed. All you need to do is save a 'dummy' or 'pretend' last modified time when the app launches for the first time. Do this in the loadAppData method. After this line: self.configData = @; add this code block. //save a pretend lastModifiedFile if one does not exist yet to force a refresh... if(![BT_fileManager doesLocalFileExist:self.modifiedFileName]){ [BT_fileManager saveTextFileToCacheWithEncoding:@'{\'lastModifiedUTC\':\'Mon, 01 Jan 2000 00:00:00 -0000\'}':self.modifiedFileName:-1]; } We are saying: 'If the last modified file does not exist, the app must be launching for the first time, go ahead and create a pretend lastModified file so the reportToCloud method prompts the user for updates. Naturally, the quotes are removed from the forum (so hate that) so you'll need to add a double quote everywhere I have pasted a single quote. For sure we'll re-visit this and ponder it so we can come up with a long term solutions. That may or may not be the way it works now ;-)
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
12/20/11 09:45 PM (12 years ago)
@ TechJeeper: Just sent you the code block in email, darned forum ruins everything! Good luck.
 
TechJeeper
Android Fan
Profile
Posts: 24
Reg: Dec 16, 2011
Lansing, MI
240
like
12/21/11 05:46 AM (12 years ago)
@David, I replied to your email, I do not see the line self.configData = @; in my _appDelegate file... or anything that resembles it. My loadAppData is in my BT_activity_root file. Thanks for the help! TechJeeper
 
birwin
Lost but trying
Profile
Posts: 93
Reg: Dec 29, 2010
location unknow...
3,080
like
01/09/12 11:25 PM (12 years ago)
Hello, This is a cool hack for BT-server iOS apps! I placed that code snippet below self.configData = @''; around line 185 or so in BT_Config/yourapp_appDelegate.m It would not work with double quotes inside the snippet for me, so I had to escape the quotes in the json container using the example below: http://dl.dropbox.com/u/474217/bt/force_refresh.txt The good news is that it seems to degrade gracefully when no internet connection is present. As long as you have a working config file inside your app, it will at least load. This is a great fix for me since my home screen changes often and I wanted a way for new app users to see the updated info. If they don't have internet, they will just see a default home screen, and get the new stuff when they go online again. I have this working on my app with auto refresh as well, so the user is not prompted for a refresh via a dialog box. I also have a 4 sec splash screen on startup as well, to hide my old content while the update process runs. More info on auto refresh on this post: http://www.buzztouch.com/forum/thread.php?tid=35C9CCA460F85572608CF3B Fantastic stuff!! Thanks again to David and @TechJeeper for the heads up! Brian-
 
birwin
Lost but trying
Profile
Posts: 93
Reg: Dec 29, 2010
location unknow...
3,080
like
01/14/12 04:54 PM (12 years ago)
Hello, I just got this working with Android 1.5. Pretty simple to implement and not very different than the solution for iOS. I looked at David's solution for iOS and tinkered around until I could match one for Android. It seems to degrade gracefully as well, so if there is no internet, the app will just use your existing config file. It is important to note, as David did earlier in this thread, that you don't want to ship your app with no config data. You always want to make sure your app at least opens when there is no internet available. In other words, you should have a healthy, usable BT_Config.txt in your app at first load. Here is a link with the details of this hack: http://dl.dropbox.com/u/474217/bt/android15_refresh.txt I think this works best with auto refresh, I outlined that option in the how-to as well. Best Regards, Brian-
 

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.