处理FCM通知单击

时间:2017-11-15 13:26:33

标签: android firebase firebase-cloud-messaging

是否有可能处理点击由android创建的FCM通知(当应用程序在后台接收推送时发生)。我看到了one of possible way solve this problementer image description heredocumentation我发现了一个有趣的时刻(见图)。那么,我怎么能做到呢?

1 个答案:

答案 0 :(得分:0)

我们可以做一个黑客。我不知道这是一个正确的方法。但它的工作原理!!

在通知点击打开的活动上的onCreate方法内进行以下检查。

protected void onCreate(@Nullable Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
if(java.lang.Integer.toHexString(getIntent().getFlags()).equals("14000000")) 
{
  //Activity is launched from the notification created by android
}
}

对于在FirebaseMessagingService类中创建通知的其他情况。您可以传递一个额外的intent并检查它是否存在于onCreate Method

活动中
相关问题