I've got a webapp running in fullscreen that interacts with a database via ajax.
Is there a way i can get a "signature" or "id" of a device to store for each device???
Basically I've got a "saved items" option, and they will be saved to a unique id. I cant use IP Address coz of multiple devices or if you use the 3G service. Any other ideas? (dont want user authentication).
Could I save an array in the manifest file and access that?
Thanks
I solved this issue by using html5's local storage.
i used
var salt=Math.floor(Math.random()*10000); //makes random salt
var randomId=Math.floor(Math.random()*20000); //makes another random number
randomId = salt+(salt*randomId); //makes the id even more random to avoid dupes
localStorange.setItem('deviceId',randomId); //sets a local variable that can be accessed by localStorage.getItem('deviceId'); and cross-refrenced with a $.get from a database to load the saves.
$.post("saveDeviceId.php?id="+randomId); //saves the new id to the database
this is how i resolved it anyway, unless anybody has a more efficient way?
Related
I am trying to figure out a way to get a list of each unique child in my Firebase Database & get a count of each unique child.
So for example if somebody entered Amazon 5 times an Hulu 2 times. I want to be able to know that. However, I don't want the user to know this.
I had a few ideas on how to do this.
Idea 1
Use Firebase's:
Answers.logCustomEvent...
However, I see two flaws with this idea.
Flaw 1: This wouldn't be useful for data that has already been entered.
Flaw 2: A user could enter Amason on accident and then changes it later to be the correct Amazon. I would get the incorrect entry..I could log changes but then I'd get bad data...or at least confusing data.
Idea 2
I could write a function inside of the app that could do this, but like I said. I don't need this functionality in the app for the user. I want it so I can know which sites I need to add functionality for first over ones that are seldom entered.
However, is it possible to have 2 apps that use the same database? So the main app is able to read and write data. While I could create a simple app that I wouldn't publish, only really use for myself that could Read the data but not write to it...
I tried to make my Database flat as I knew how..
When a user adds a service it doesn't go under the user node, I have a child called "services" and I just reference that service child in the "user" child.
So my database looks like this
cards
card uid 1
cardname: ""
services
service uid 1: true
services
service uid 1
serviceName: Amazon
serviceUrl: ""
service uid 2
serviceName: Amazon
users
... reference the card this user has access to
So to repeat the question.
I want to be able to know each unique serviceName and if there are duplicates of the same one..how many there are..
I don't need to know who created it or when..
you may have another table where you have objects with only 2 fields: serviceName and count.
So, everytime you have a new instance, you check if it already persists in your table and increment the count value, otherwise create a new row.
Users will not see that info.
And, yes, you can access one database from several apps. Just get clientID, trackingID, etc...
I am converting 2 custom lists into a json string and storing it the NSUserDefaults. Something like so:-
NSUserDefaults.StandardUserDefaults.SetString(JsonConvert.SerializeObject(stationList.Take(50)), "StationList1");
NSUserDefaults.StandardUserDefaults.SetString(JsonConvert.SerializeObject(stationList.Skip(50).Take(50)), "StationList2");
If I try and retrieve them immediately after saving them like below I get the saved values:-
savedStationList1 = NSUserDefaults.StandardUserDefaults.StringForKey("StationList1");
savedStationList2 = NSUserDefaults.StandardUserDefaults.StringForKey("StationList2");
But the issue is if I restart the app, and try to get the above values in another part of the code, I only get the value for:-
savedStationList2 = NSUserDefaults.StandardUserDefaults.StringForKey("StationList2");
and the value for below is always null :-
savedStationList1 = NSUserDefaults.StandardUserDefaults.StringForKey("StationList1");
I do not override these values anywhere within the app. Is there a way I can solve this?
Any help is appreciated
Although natively the iOS system does store data added through 'userdefaults' it may not do this instantly. I would suggest adding the following line:
NSUserDefaults.StandardUserDefaults.Synchronise();
After you store data to standard user defaults run the synchronise and test that you can extract the data, you should find that this will now work correctly for you.
I'm having an issue with importing cached data. I have a very simple page right now to use as a proof of concept. There is a single table in the back end. I have all CRUD functionality working. When the user makes a change to the local data, I update a record in local storage.
var bundle = em.exportEntities(em.getChanges());
window.localStorage.setItem("waterLevelChanges", bundle);
after the page is loaded I import the entities
var bundle = window.localStorage.getItem("waterLevelChanges");
if (bundle)
em.importEntities(bundle);
This works perfectly if I'm editing an existing record. However, any records that I have added, but not saved to the database won't populate. In the bundle they have an EntityState of "Added". I read that there is an issue if you don't use the temp keys, but I'm letting Breeze use the temp keys and manage them as it likes. I have verified the data is stored in the local cache by looking in the developer tools. I can also see it in the bundle when I debug.
Our tests show that your stated scenario should work fine.
See this DocCode:export/importTests.js test where a new Order is exported, saved to browser storage, and reimported; it's "Added" state is confirmed. The Order type has server-generated, temporary keys.
I think you'll have to create a repro of your failing scenario to convince me that it doesn't work. Perhaps you might start by forking this Todos plunker and modifying it to make your point; a TodoItem also has has server-generated, temporary keys.
So for my windows phone 7 app, I am trying to save the user input after they 'tombstone' my app when I first debugged the app I got a KeyNotFoundException, but after I entered some data into my textbox and tombstoned my app the I didn't get a KeyNotFoundException. Can someone please help me with this problem?
KeyNotFoundException means that you are trying to get some data from data collection by key, and that key/value pair does not exist:
http://msdn.microsoft.com/en-us/library/system.collections.generic.keynotfoundexception.aspx
Before trying to access the date using key, first check if that key even exists using ContainsKey method:
http://msdn.microsoft.com/en-us/library/kw5aaea4
In my iOS application, I want to store some messages that I obtain from my remote server. However, instead of storing these messages forever, I want to purge, once I have a N number of messages; i.e., if my N is configured to be 10, I want to store 10 messages and on the arrival of the 11th message, I want to delete the 1st message.
Is there a standard way to do this in iOS ? I am yet to write the code to saving the messages, so choosing any method of saving is fine for me.
Store your messages in a file. After you get the message read your file's messages to an NSMutableArray, replace the most old message with new one and overwrite your file with new array data.
I dont think there is a straight fwd way.
The way I would do is have a table using SQLLite. Have 2 columns id(int, autoincrement), value(String). When inserting, if max(id) >=10 delete row with min(id) and insert the new value.
Ofcourse, this woud fail after it reached MAX_INT_VALUE. So if you thing you would never get to this value you are good.