Meteor - 如何检测应用程序是否已打开?

Meteor - How can I detect if an app has been opened?

我是 运行 IOS 上的 Meteor 应用程序,我想在应用程序打开时将徽章编号重置为 0。我的逻辑是在应用程序打开时将徽章设置为零,然后递增直到再次打开。如何查看某个应用是否为 pressed/opened? Meteor.startup 好像不行。打开应用程序时是否调用了某种方法?

https://github.com/raix/push

在你的AppDelegate.m中:

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    // set badge to 0

您可以将脚本放在模板 onCreated 部分,例如

Template.example.onCreated(function(){
    //run your function here
});

如果您依赖反应式数据,或者将它放在模板助手中。

这似乎晚了,但供将来参考: 您不需要手动 increment/decrement 徽章计数。 只需在 客户端 添加属性 badgeclearBadge 将配置推送到 Meteor.startup,如下所示:

Meteor.startup(() => {
    Push.Configure({
      ios: {
        alert: true,
        badge: true,
        sound: true,
        clearBadge: true
      }
    })
});

一旦通知到达,这将增加您的 badgeCount,并在用户打开应用程序时将计数设置为 0。

更多详细信息,请关注这里 https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/API.md