Ionic2 / Angular2:我在哪里可以更新用户的上次访问时间戳?

时间:2017-01-24 14:20:54

标签: angular ionic2

我正在使用Ionic 2 rc4。

我有一个更新用户上次访问时间戳的功能。

每次访问应用程序时我都需要执行此功能。有什么地方可以做这个电话吗?

我考虑过在app.component.ts的{​​{1}}中进行调用,但我认为这只会在应用启动时调用一次,除非应用被杀,否则不会再次调用

由于

1 个答案:

答案 0 :(得分:1)

我认为你需要这个:

platform.ready().then((readySource) => {
  this.platform.pause.subscribe(() => {
    //App paused or closed
  });

  this.platform.resume.subscribe(() => {
    //App resumed or start
  });
});

将此代码放入MyApp构造函数中。