1. <small id='M2eMe'></small><noframes id='M2eMe'>

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

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

      <legend id='M2eMe'><style id='M2eMe'><dir id='M2eMe'><q id='M2eMe'></q></dir></style></legend>
    3. <tfoot id='M2eMe'></tfoot>

      使用 PHP 在 Firebase 上创建主题

      Create a TOPIC on firebase using PHP(使用 PHP 在 Firebase 上创建主题)
    4. <small id='0oFjH'></small><noframes id='0oFjH'>

    5. <legend id='0oFjH'><style id='0oFjH'><dir id='0oFjH'><q id='0oFjH'></q></dir></style></legend>
      <tfoot id='0oFjH'></tfoot>

        <bdo id='0oFjH'></bdo><ul id='0oFjH'></ul>

                <tbody id='0oFjH'></tbody>
              1. <i id='0oFjH'><tr id='0oFjH'><dt id='0oFjH'><q id='0oFjH'><span id='0oFjH'><b id='0oFjH'><form id='0oFjH'><ins id='0oFjH'></ins><ul id='0oFjH'></ul><sub id='0oFjH'></sub></form><legend id='0oFjH'></legend><bdo id='0oFjH'><pre id='0oFjH'><center id='0oFjH'></center></pre></bdo></b><th id='0oFjH'></th></span></q></dt></tr></i><div id='0oFjH'><tfoot id='0oFjH'></tfoot><dl id='0oFjH'><fieldset id='0oFjH'></fieldset></dl></div>
              2. 本文介绍了使用 PHP 在 Firebase 上创建主题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                I want to create topics on firebase on runtime. As soon as admin creates a certain record in my database, I will create the respective topic so that users associated with that topic may receive notifications using firebase.

                In case of fixed topic, I am able to send the notations successfully like this:

                public static function SendFireBaseBroadCast($topicName, $title, $body) {
                
                
                        #API access key from Google API's Console
                        define('API_ACCESS_KEY', 'API_KEY');
                        $msg = array
                            (
                            'body' => $body,
                            'title' => $title,
                            'icon' => 'myicon', /* Default Icon */
                            'sound' => 'mySound'/* Default sound */
                        );
                        $fields = array
                            (
                            'to' => "/topics/" . $topicName,
                            'notification' => $msg
                        );
                
                
                        $headers = array
                            (
                            'Authorization: key=' . API_ACCESS_KEY,
                            'Content-Type: application/json'
                        );
                
                        $ch = curl_init();
                        curl_setopt($ch, CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send');
                        curl_setopt($ch, CURLOPT_POST, true);
                        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
                        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
                        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
                        $result = curl_exec($ch);
                        curl_close($ch);
                
                    }
                

                How can I create topics though on runtime on firebase?

                解决方案

                Firebase message topics cannot be created on their own - they start to exist as soon as one device is subscribed to them and stop to exist when no device is subscribed.

                From a server perspective, you can send a message to any topic of your choice (as long as the name by itself is valid). Firebase will accept the message in any case and deliver it to all subscribed devices (0 if no device is subscribed).

                If you want to publish the available topics provided by your application to all the clients of your application, you need to do this separately from Firebase (e.g. with an API endpoint).

                If you rename a topic in your application, you will need to re-subscribe the clients to the new topic (and preferably unsubscribe them from the old one). You can do this with the Instance ID API (https://developers.google.com/instance-id/reference/server) per instance. Please note that it‘s currently not possible to retrieve a list of all devices subscribed to a topic. It‘s also not possible to rename a topic and move all subscribed devices from one topic to another. This is business logic that you would have to implement on your application‘s level.

                The Firebase Admin SDKs provide methods to manage topic subscriptions, see https://firebase.google.com/docs/admin/setup for a list of official SDKs.

                If you need/want to stick to PHP, there‘s an unofficial Admin SDK at https://github.com/kreait/firebase-php (Disclaimer: I‘m the maintainer)

                这篇关于使用 PHP 在 Firebase 上创建主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

              3. <small id='2iXGA'></small><noframes id='2iXGA'>

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

                        <legend id='2iXGA'><style id='2iXGA'><dir id='2iXGA'><q id='2iXGA'></q></dir></style></legend>

                          <bdo id='2iXGA'></bdo><ul id='2iXGA'></ul>