Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone - detect first time launch with phonegap

Tags:

iphone

cordova

I am trying to detect the first time launch of a newly installed application and display a license agreement for the application. The user must accept the lincense or leave the application..

Does anyone know how I can do this using Phonegap? I have searched through the topics but I cant seem to find this anywhere.

Thank You

like image 302
ZodTron Avatar asked Feb 20 '13 19:02

ZodTron


People also ask

How can I tell when I first opened my iPhone?

There is no way to determine the "activation date" of any given iPhone. The best you can do is find out if it's still under warranty and when the warranty expires. There is no way to determine the "activation date" of any given iPhone.

What is app made from JavaScript and PhoneGap called?

Hybrid apps are developed using web technologies: HTML5, CSS and JavaScript, then put inside a native container such Adobe PhoneGap. These native containers run the web application code and package it into an app.

Is PhoneGap open source?

PhoneGap is an Open Source framework that helps build hybrid applications which work on most mobile platforms such as Android, iOS, Blackberry, Windows Phone among others.


2 Answers

You can use local storage to keep track of app launch counts.

var applaunchCount = window.localStorage.getItem('launchCount');

//Check if it already exists or not
if(applaunchCount){
   //This is a second time launch, and count = applaunchCount
}else{
  //Local storage is not set, hence first time launch. set the local storage item
  window.localStorage.setItem('launchCount',1);

  //Do the other stuff related to first time launch
}
like image 54
Manish Kumar Avatar answered Sep 19 '22 18:09

Manish Kumar


Now iOS may clear localStorage, so you cannot count on it being persistent.

For truly persistent storage, one option would be the file system plugin

https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-file

Please note that if your APP is uninstalled, your persistent file would most likely be removed also. Which is probably fine for this application.

like image 34
J. McNerney Avatar answered Sep 18 '22 18:09

J. McNerney