| Code: |
| var firstExecutionString = widget.preferenceForKey('first_execution');
// if first execute flag doesn't exist set date if (!firstExecutionString) { var setdate = new Date().toString(); widget.setPreferenceForKey(setdate, 'first_execution') } // else set compare dates else { var firstExecutionDate = new Date(firstExecutionString); // set date offset var offsetDate = new Date(); offsetDate.setDate(firstExecutionDate.getDate()+3); var now = new date() if (now > offsetDate) { var exp = 1 widget.setPreferenceForKey(exp, 'expire') } } // Check for expire flag var exp1 = widget.preferenceForKey('expire') if (exp1 = 1) { alert('The widget has expired. Please download the full version'); setInterval('window.close()', 1000); } |
Just ignore the widget.statements. I am reading and writing data from persistent storage. This is for the WRT platform BTW and aism to expire the app 3 days after it was first run.
