【问题标题】:C2DM Messaging works on local server but not in production (Google App Engine)C2DM 消息传递在本地服务器上工作,但在生产中不工作(Google App Engine)
【发布时间】:2011-11-10 23:28:30
【问题描述】:

所以我有一个使用 C2DM 消息传递的应用程序。当它托管在我的计算机上时,它在本地服务器模式下运行良好。但是,当我将应用程序部署到应用程序引擎时,它不再起作用!我一直在拔头发,不知道为什么会这样。

我尝试使用 1.5.2 和 1.5.3 App Engine SDK 并在 Eclipse 上针对 2.3 和 2.4 GWT 插件进行构建。这些似乎都不起作用。我可以很好地注册电话,但似乎没有 C2DM 消息到达电话。

【问题讨论】:

    标签: android google-app-engine gwt google-cloud-datastore android-c2dm


    【解决方案1】:

    好的,所以我研究了一下,发现 Google 提供的代码存在错误。在本地服务器上,它存储全小写的注册数据用户名(MyEmail@bomb.com -> myemail@bomb.com)。在生产服务器上,它不使用全小写来存储电子邮件。以下方法查询数据存储区,以全小写形式提供电子邮件作为参数。

    解决办法,在注册时将电子邮件保存到数据存储区时,注释掉指示的行或找到一种使用全小写的方法。

    /**
     * Helper function - will query all registrations for a user.
     */
    @SuppressWarnings("unchecked")
    public static List<DeviceInfo> getDeviceInfoForUser(String user) {
        PersistenceManager pm = PMF.get().getPersistenceManager();
        try {
            // Canonicalize user name
    ----->  user = user.toLowerCase(Locale.ENGLISH);
            Query query = pm.newQuery(DeviceInfo.class);
            query.setFilter("key >= '" +
                    user + "' && key < '" + user + "$'");
            List<DeviceInfo> qresult = (List<DeviceInfo>) query.execute();
            // Copy to array - we need to close the query
            List<DeviceInfo> result = new ArrayList<DeviceInfo>();
            for (DeviceInfo di : qresult) {
                result.add(di);
            }
            query.closeAll();
            log.info("Return " + result.size() + " devices for user " + user);
            return result;
        } finally {
            pm.close();
        }
    }
    

    【讨论】:

      【解决方案2】:

      在查询前添加user = user.toLowerCase(Locale.ENGLISH);,肯定会起作用。

      【讨论】:

        猜你喜欢
        • 2016-11-05
        • 2021-12-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-11-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多