iPhone - 使用phonegap检测首次发布

Zod*_*ron 5 iphone cordova

我正在尝试检测第一次启动新安装的应用程序并显示该应用程序的许可协议.用户必须接受lincense或离开应用程序..

有谁知道我怎么能用Phonegap做到这一点?我搜索过这些主题,但我似乎无法在任何地方找到它.

谢谢

Man*_*mar 18

您可以使用本地存储来跟踪应用启动计数.

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
}
Run Code Online (Sandbox Code Playgroud)