<bdo id='SXSnd'></bdo><ul id='SXSnd'></ul>
    <legend id='SXSnd'><style id='SXSnd'><dir id='SXSnd'><q id='SXSnd'></q></dir></style></legend>
  1. <i id='SXSnd'><tr id='SXSnd'><dt id='SXSnd'><q id='SXSnd'><span id='SXSnd'><b id='SXSnd'><form id='SXSnd'><ins id='SXSnd'></ins><ul id='SXSnd'></ul><sub id='SXSnd'></sub></form><legend id='SXSnd'></legend><bdo id='SXSnd'><pre id='SXSnd'><center id='SXSnd'></center></pre></bdo></b><th id='SXSnd'></th></span></q></dt></tr></i><div id='SXSnd'><tfoot id='SXSnd'></tfoot><dl id='SXSnd'><fieldset id='SXSnd'></fieldset></dl></div>

    <small id='SXSnd'></small><noframes id='SXSnd'>

      <tfoot id='SXSnd'></tfoot>
    1. Firebase Cloud Messaging (FCM) - 当用户点击带有附加功能的通知时启动活动

      时间:2023-07-31

          <bdo id='TbXZv'></bdo><ul id='TbXZv'></ul>
          <tfoot id='TbXZv'></tfoot>

          <small id='TbXZv'></small><noframes id='TbXZv'>

        • <legend id='TbXZv'><style id='TbXZv'><dir id='TbXZv'><q id='TbXZv'></q></dir></style></legend>
              <i id='TbXZv'><tr id='TbXZv'><dt id='TbXZv'><q id='TbXZv'><span id='TbXZv'><b id='TbXZv'><form id='TbXZv'><ins id='TbXZv'></ins><ul id='TbXZv'></ul><sub id='TbXZv'></sub></form><legend id='TbXZv'></legend><bdo id='TbXZv'><pre id='TbXZv'><center id='TbXZv'></center></pre></bdo></b><th id='TbXZv'></th></span></q></dt></tr></i><div id='TbXZv'><tfoot id='TbXZv'></tfoot><dl id='TbXZv'><fieldset id='TbXZv'></fieldset></dl></div>

                  <tbody id='TbXZv'></tbody>
                本文介绍了Firebase Cloud Messaging (FCM) - 当用户点击带有附加功能的通知时启动活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我试图在用户单击通知时打开特定活动,当应用程序在后台时,使用一些额外的参数.我正在使用 click_action 并且它工作正常,应用程序会打开所需的 Activity.

                I'm trying to open a specific activity when the user clicks the notification, when the app is in the background, with some extra parameters. I'm using the click_action and it's working fine, the app opens the desired Activity.

                现在我需要服务器向此 Activity 传递一个额外的参数,即 id,以便我可以显示与通知相关联的所需详细信息.就像电子邮件应用程序一样,当我们点击通知时,会打开该特定电子邮件的详细信息.

                Now I need the server to pass an extra parameter, an id, to this Activity so I can present the desired details associated with the notification. Like an e-mail application, that when we click on the notification opens the details of that specif email.

                我该怎么做?

                推荐答案

                好的,我找到了解决方案.

                Ok, I have found the solution.

                这是我从服务器发送到应用程序的 json

                This is the json that I'm sending from the server to the app

                {
                  "registration_ids": [
                    "XXX",
                    ...
                  ],
                  "data": {
                    "id_offer": "41"
                  },
                  "notification": {
                    "title": "This is the Title",
                    "text": "Hello I'm a notification",
                    "icon": "ic_push",
                    "click_action": "ACTIVITY_XPTO"
                  }
                }
                

                在 AndroidManifest.xml 中

                At the AndroidManifest.xml

                <activity
                    android:name=".ActivityXPTO"
                    android:screenOrientation="sensor"
                    android:windowSoftInputMode="stateHidden">
                    <intent-filter>
                        <action android:name="ACTIVITY_XPTO" />        
                        <category android:name="android.intent.category.DEFAULT" />
                    </intent-filter>
                </activity>
                

                当应用程序关闭或在后台并且用户单击通知时,它会打开我的 ActivityXPTO,检索 id_offer 我只需要这样做

                When the app is closed or in background and the user clicks on the notification it opens my ActivityXPTO, to retrieve the id_offer I only need to do

                public class ActivityXPTO extends AppCompatActivity {
                    @Override
                    protected void onCreate(Bundle savedInstanceState) {
                        super.onCreate(savedInstanceState);
                
                        ...
                
                        String idOffer = "";
                
                        Intent startingIntent = getIntent();
                        if (startingIntent != null) {
                            idOffer = startingIntent.getStringExtra("id_offer"); // Retrieve the id
                        }
                
                        getOfferDetails(idOffer);
                    }
                
                    ...
                }
                

                就是这样……

                这篇关于Firebase Cloud Messaging (FCM) - 当用户点击带有附加功能的通知时启动活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:在库中实现 Firebase 下一篇:FCM 令牌何时到期?

                相关文章

                <tfoot id='CfDeT'></tfoot>
                <i id='CfDeT'><tr id='CfDeT'><dt id='CfDeT'><q id='CfDeT'><span id='CfDeT'><b id='CfDeT'><form id='CfDeT'><ins id='CfDeT'></ins><ul id='CfDeT'></ul><sub id='CfDeT'></sub></form><legend id='CfDeT'></legend><bdo id='CfDeT'><pre id='CfDeT'><center id='CfDeT'></center></pre></bdo></b><th id='CfDeT'></th></span></q></dt></tr></i><div id='CfDeT'><tfoot id='CfDeT'></tfoot><dl id='CfDeT'><fieldset id='CfDeT'></fieldset></dl></div>

                <small id='CfDeT'></small><noframes id='CfDeT'>

                  <legend id='CfDeT'><style id='CfDeT'><dir id='CfDeT'><q id='CfDeT'></q></dir></style></legend>

                    <bdo id='CfDeT'></bdo><ul id='CfDeT'></ul>