适用于移动数据而非 Wi-Fi 的 Azure 通知

Azure notifications working on mobile data and not on Wi-Fi

我正在使用 Azure 通知中心 在我的 android 应用程序中实现推送通知功能。一切似乎都很好;我只有一个问题。

只有当我使用移动数据连接到互联网时,我才能在我的设备上收到推送通知;关闭移动数据并通过 Wi-Fi 连接后,我无法收到任何推送通知消息。

我正在缩小我的搜索范围,因为第一次注册存在一些问题。它只允许该模式(在我的例子中是移动数据)接收任何推送消息。

我使用以下代码进行注册:

    NotificationsManager.handleNotifications(this, SENDER_ID, NotificationsReceiver.class);
    gcm = GoogleCloudMessaging.getInstance(this);
    hub = new NotificationHub(HubName, HubListenConnectionString, this);
    registerWithNotificationHubs();
.
.
.
private void registerWithNotificationHubs() {
        new AsyncTask() {
            @Override
            protected Object doInBackground(Object... params) {
                try {
                    String regid = gcm.register(SENDER_ID);
                    DialogNotify("Registered Successfully", "RegId : " +
                            hub.register(regid).getRegistrationId());
                } catch (Exception e) {
                    DialogNotify("Exception", e.getMessage());
                    return e;
                }
                return null;
            }
        }.execute(null, null, null);
    }

尤里卡...!!!! :) 这是 Google Play 服务的问题。 打开移动数据时正在连接,但未连接到 Wi-Fi。 罪魁祸首是 IPv6。 只需 禁用 IPv6 一切都会正常运行。

检查Google Play服务是否正常工作;从 phone 的拨号器中拨打此代码:* # * # 426 # * # * 并验证它是否已连接。

注意:您可以在 Play 商店中获取许多应用程序以在 Wi-Fi 连接时禁用 IPv6。我正在使用 IPv6 工具 应用来禁用 IPv6。