Discussion Forums  >  Uncategorized

Replies: 3    Views: 223

SgtWombat
Code is Art
Profile
Posts: 3
Reg: Aug 27, 2011
Athens
30
08/29/11 01:18 PM (14 years ago)

variable storage

Sorry if this has been answered elsewhere, but I haven't found it :P I have a couple of questions. I want to have a variable (or more) which all phones with my app access...I imagine it would be located on the buzztouch server. For instance, if it were a boolean, it would be true or false for all instances of the app, and I can manually change it. Second, I would like to save a value locally on the phone, which won't disappear when the app is closed. For instance, if a user has already completed a quiz, a boolean located on the phone might change to true. I am not asking for a detailed answer, I would just like to know if these things are possible with buzztouch, or they must be accomplished outside of buzztouch. Or course, any additional helpful suggestions are appreciated ;)
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
08/30/11 01:11 AM (14 years ago)
Athens Greece or Athens Georgia? Either way...welcome aboard. The best way to save small bits of data is to use the device itself. There isn't an easy way in your online control panel to setup anything like this so the phone will be the best option. Assuming your working with v.15 for iOS, you can use a simple built in buzztouch method to do exactly this. One method SETS a simple value, one GETS a simple value. For simplicity, all values using these methods are Strings. So, to save a boolean, you would save '1' for true or '0' for false. The methods are Class Methods and they are in the BT_strings class. One is called getPrefString and one is called setPrefString. Class methods do not need a new BT_string object to be instantiated before you can use them - just use them directly. Example... To 'remember' that a user finished a quiz, you could do [BT_strings setPrefString:@'finishedQuiz':@'1'] finishedQuiz is the name of variable (preference) and 1 is the value. To 'get' this later, anywhere in your app, in any file: NSString *myValue = [BT_strings getPrefString:@'finishedQuiz']; This will return the value or an empty string if it's not been set yet.
 
SgtWombat
Code is Art
Profile
Posts: 3
Reg: Aug 27, 2011
Athens
30
like
08/30/11 04:57 AM (14 years ago)
Actually...it's Athens, Ohio! Thank you very much for your response. That seems pretty straight forward and should work fine for what I am doing. I am working with v 1.5 for Android, so I am patiently waiting til the 15th, and in the meantime I am learning to work with buzztouch :) Will the code you have provided work with Android SDK once I am able to download the source code and try it out? Also, you did say the best way to save few bits of info is on the phone itself...but there are still a couple of things I'd like to save on the server for all phones to use. For example, I want to allow a quiz to be available to take only at certain times, whenever I decide. So, usually a certain boolean is false. But, if at 3:00 pm I change it to true, when all instances of my app check the variable when the user attempts to take the quiz, the app will allow them to take the quiz since it is set to true. Would this best be accomplished by a script located on a server which simply has a few variables declared?
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
08/31/11 12:48 AM (14 years ago)
a) A similiar method will be available in the Android version. b) If you want to send things to a server you'll need to setup a method to make a backend request to your website. There are tons of ways to do this. Most folks use the reportToCloud URL to append a variable of some sort (like the device id) then save that on their backend. When that device launches the app they do a query on their backend to determine what they need, like 'last launch' or something. It's a matter of figuring out what you want to track and how you plan to store it, like mySQL, text files, whatever. All about the backend ;-)
 

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.