菜鸟教程小白 发表于 2022-12-13 11:19:41

ios - phonegap 推送插件不会在 iOS 上引发注册事件


                                            <p><p>我正在使用 <a href="https://github.com/phonegap/phonegap-plugin-push" rel="noreferrer noopener nofollow">phonegap-plugin-push</a>让我的 ionic 应用程序注册和接收通知。
它在 Android 上完美运行,但在 iOS 上不会引发注册事件。</p>

<p>问题是我可以看到设备正在注册推送通知:</p>

<pre><code>00:00 4/Notify: Push Plugin register called
00:00 4/Notify: Push Plugin register success: &lt;d4fab0e8 85074aa2 f3a33a85 d32a373f f3b5e4f6 bb94aecb 9fe3732d 77eb5c14&gt;
</code></pre>

<p>但我的应用中从未调用过“注册”事件。</p>

<pre><code>      // Initialize push notifications for iOs and Android
      var pushObj = PushNotification.init({
          &#34;android&#34;: {&#34;senderID&#34;: Constants.ANDROIDSENDERID},
          &#34;ios&#34;: {&#34;alert&#34;: &#34;true&#34;, &#34;badge&#34;: &#34;true&#34;, &#34;sound&#34;: &#34;true&#34;}, &#34;windows&#34;: {}
      });

      console.log(&#39;add listener push registration&#39;);

      // handle push notifications
      pushObj.on(&#39;registration&#39;, function (data) {
          console.log(&#39;registration successful&#39;);
      }
</code></pre>

<p>“注册成功”日志消息是在 Android 上编写的,而不是在 iOS 上编写的。
我已经被这个问题困扰了一天多。
有谁知道这个问题的解决方案(或可能解决方案的方向)?</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>我也遇到了同样的问题,这是位于 </p> 的源文件中的错误

<pre><code>/src/ios/PushPlugin.m
</code></pre>

<p>它已修复并已提出拉取请求。可以通过@<a href="https://github.com/phonegap-build/PushPlugin/pull/646" rel="noreferrer noopener nofollow">#646</a> 跟踪该问题。 </p>

<p>如果您可以使用非官方插件,请将此插件导入您的项目</p>

<pre><code>phonegap plugin add https://github.com/pauljacobv/PushPlugin.git
</code></pre>

<p>它可以解决这个问题。</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - phonegap 推送插件不会在 iOS 上引发注册事件,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/33093926/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/33093926/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - phonegap 推送插件不会在 iOS 上引发注册事件