2

无法弄清楚如何获得启动选项(如果可能的话)。想了解如何弄清楚应用启动机制——也就是说应用是由用户直接启动的,还是因为一个通知而启动的。在使用新的 Safari 智能应用程序横幅时,它甚至会很有帮助。

有类似问题的人吗?对此有任何解决方法或解决方案吗?

干杯!

4

2 回答 2

5

我使用此代码来确定我的 Trigger.io 应用程序是否由 Parse 推送通知打开:

var appLastResumed = new Date();

window.forge.event.appResumed.addListener(function() {
  window.appLastResumed = new Date();
  // additional code that runs when the app is resumed
});

window.forge.event.messagePushed.addListener(function() {
  // this event fires every time a user clicks on a push notification 
  // no matter whether the app is already opened or not
  // so we need to detect whether this happened right after an appResumed event

  setTimeout( function() { // make sure the appResumed event is fired first
    if (new Date().getTime() - window.appLastResumed.getTime() < 1000) {
      // app was opened by a push notification
      // insert your code here
    }
  }, 50);
});
于 2012-12-04T07:14:30.730 回答
3

您可以通过推送通知或使用自定义 URL 检测应用程序何时打开。

1) 推送通知 - 结合我们与 Parse 的集成使用我们的事件模块来编写在应用程序打开时收到推送通知时运行的代码,或者当它被推送打开时运行:

http://docs.trigger.io/en/v1.4/modules/event.html#messagepushed-addlistener

2) 自定义 url - 使用我们的 urlhandler 模块分配一个监听器:

http://docs.trigger.io/en/v1.4/modules/urlhandler.html

于 2012-12-04T00:52:37.763 回答