Hmmm
buzztouch Evangelist
Profile
Posts: 67
Reg: Sep 17, 2013
location unknow...
6,670
11/20/14 05:21 PM (9 years ago)

iOS Refresh - currentPublishDate and modifiedUTC fields in the bt_applications table

A Cron is configured to fire, which updates the currentPublishDate and modifiedUTC fields in the bt_applications table. When this runs, we want to force the app to refresh, which will display the updated content when a user opens, or reactivates the app. This functions properly on the android app. The Report to Cloud call is made in iOS, however the app does not refresh. A manual refresh does update the content, but does not accomplish what is described above. We've run multiple evolutions trying to resolve with PhP on the self-hosted server. Any suggestions for a solution? Thanks.
 
Calypso Kid
Aspiring developer
Profile
Posts: 780
Reg: Mar 09, 2012
Upstate New Yor...
18,200
like
11/20/14 06:50 PM (9 years ago)
I'm not even close to an expert but from what I know, the app won't self refresh unless there is a change in the config file. Doesn't sound like you're changing the config file for the app. Maybe a screen in the app that is part of the app but not visible to the end user. Change something in the screen and then hit publish in the control panel. This will cause a config file change then refresh the app. Again, what I know about this stuff could fit into a thimble but this is what comes to mind. Dave
 
Calypso Kid
Aspiring developer
Profile
Posts: 780
Reg: Mar 09, 2012
Upstate New Yor...
18,200
like
11/20/14 06:55 PM (9 years ago)
Ok, now that I know what a Cron is, the above probably won't work for you....... Unless you can get a Cron to change your config file to force an app update. Dave
 
Hmmm
buzztouch Evangelist
Profile
Posts: 67
Reg: Sep 17, 2013
location unknow...
6,670
like
11/20/14 08:15 PM (9 years ago)
Thanks for the feedback. We'll just keep pounding on it until it surrenders, and post the solution, if we can get it to work.
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
11/20/14 10:30 PM (9 years ago)
This approach should work just fine, actually. If the report to cloud is different, the app will ask for a refresh - regardless of what's in the BT_config file. At least, that's how it's "supposed" to work. Try this - make a change on your control panel and be sure to publish changes. Then run your app - does it ask for a refresh? If so, then you know the report to cloud is working fine and it must be something wrong with the logic in your Cron job. If not, then there's something wrong with your app. Also, examine your debug output in Xcode. It will tell you what the value of the report to cloud is on the device's cache and what it is on the server. If they're different, it should say it is prompting for a refresh. It will be in the first few dozen lines of output when you run the app.
 
Hmmm
buzztouch Evangelist
Profile
Posts: 67
Reg: Sep 17, 2013
location unknow...
6,670
like
11/21/14 12:14 PM (9 years ago)
Chris: Thanks for your help. We’ve followed the steps you’ve outlined and per the debug have narrowed it down to reportToCloud is not being called on initial app startup. We’ve attempted to solve this by adding [self reportToCloud];, and several other variations into the appDelegate file within the //didFinishLaunchingWithOptions... function [self reportToCloud]; does not throw an error to compile, but this is what’s causing the error when the app launches: BT_fileManager: saveTextFileToCacheWithEncoding: "(null)" encodingFlag: -1 //steps to replicate reportToCloud not running on the initial app startup. 1. Cron fires and the updated app config is loaded. reportToCloud is not being called. 2. Send the app to the background, modify, publish, and bring the app to the foreground. reportToCloud is called, Debug report: "appModified.txt does not exist in the cache. Not checking for updates.", because the initial app run does not reportToCloud, thus not saving the value. 3. Send the app to the background, modify and publish, and bring the app to the foreground. reportToCloud is called, the app refreshes because the reportToCloud was called in step 2. Note: An app modification and publish is required for the refresh in step 3.
 
Hmmm
buzztouch Evangelist
Profile
Posts: 67
Reg: Sep 17, 2013
location unknow...
6,670
like
11/21/14 04:32 PM (9 years ago)
PROBLEM RESOLVED To configure an app refresh every time content is updated and published, requires the following. The app will check and refresh/update on every activation. XXX_appDelegate.m Approximately line 285 //reportToCloud... -(void)reportToCloud{ [BT_debugger showIt:self message:[NSString stringWithFormat:@"reportToCloud%@", @""]]; //if we do not have any reportToCloud results yet, make a fake one... if(![BT_fileManager doesLocalFileExist:[self modifiedFileName]]){ //Replaced with valid json directly below this commented out code //COMMENT OUT THIS CODE //[BT_fileManager saveTextFileToCacheWithEncoding:@"blankLastModified" fileName:self.modifiedFileName encodingFlag:-1]; //ADD THIS CODE [BT_fileManager saveTextFileToCacheWithEncoding:@"{\"lastModifiedUTC\":\"2011-02-22 02:13:25\"}" fileName:self.modifiedFileName encodingFlag:-1]; } ALSO BT_loadConfigDataViewController.m Approximately line 181 Reference this post for the below fix: https://www.buzztouch.com/forum/thread.php?tid=631F9CB2D66EC6846BD3EC5 //ADD THIS CODE //report to cloud (not all apps do this, dataURL and reportToCloudURL required)... if([[appDelegate.rootApp dataURL] length] > 1 && [[appDelegate.rootApp reportToCloudURL] length] > 1){ [appDelegate reportToCloud]; } Anyone with questions post on this thread, or send a private message. Thanks for your help, Chris.
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
11/21/14 07:33 PM (9 years ago)
Good sleuthing! 1. This works in "Live" mode, "Design" mode or both ? 2. Why wouldn't the default behavior of the app be to update on every change of the server configuration? Thanks, -- Niraj
 
Hmmm
buzztouch Evangelist
Profile
Posts: 67
Reg: Sep 17, 2013
location unknow...
6,670
like
11/21/14 08:44 PM (9 years ago)
Niraj: Design mode. We configured as described above because the app we designed for our client will update their content weekly, and also the date of the current issue will update and display as well. When the cron fires it updates the applicable field in the table. The next time the user opens the app after the cron fires it will auto refresh the app content and display the current issue date. If you have a recommendation for a better way to code this, we'd always appreciate the feedback. Thanks.
 

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.