在C2DM电子邮件 [英] Emails in C2DM

查看:237
本文介绍了在C2DM电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用C2DM开发的推送通知系统在Android中,它工作正常,但我有一个问题,我-E的正常工作与一个电子邮件只。

I have developed push notification system in android using c2dm,Its working fine but I having one problem i-e its works fine with one email only.

等待你的答复
阿尔塔夫

Waiting for your reply Altaf

推荐答案

看来你是错的IM pression这其中创建,以确定使用C2DM服务的应用程序中的角色电子邮件帐户应该改变下登记意向。

It seems that you are under the wrong impression that the Role Email account which is created to identify the application using the C2DM service should be changed in the registration intent.

您必须拥有该角色电子邮件一样的服务器上一个,否则谷歌将无法识别您的应用程序,因为这C2DM消息的发送/接收器。
样品登记意图:

You must have that role email the same as the one on the server otherwise Google will not be able to identify your application as sender/receiver of this c2dm message. Sample Registration Intent:

    Intent registrationIntent = new Intent(
            C2DMessaging.REQUEST_REGISTRATION_INTENT);
    registrationIntent.setPackage(C2DMessaging.GSF_PACKAGE);
    registrationIntent.putExtra(
            C2DMessaging.EXTRA_APPLICATION_PENDING_INTENT,
            PendingIntent.getBroadcast(context, 0, new Intent(), 0));
    registrationIntent.putExtra(C2DMessaging.EXTRA_SENDER, senderId);
    context.startService(registrationIntent);

变量senderId这里应该持有的角色帐户创建并在谷歌的 C2DM注册页面

此相同的电子邮件被用来从它用于稍后发送C2DM的消息谷歌的服务器获取身份验证令牌

This same email is used to obtain the Authentication token from google servers which is used to send C2DM messages later

样的服务器code获得一个认证密钥:

Sample server code to get an authentication key:

        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
        nameValuePairs.add(new BasicNameValuePair("Email",
                senderId));
        nameValuePairs.add(new BasicNameValuePair("Passwd", "testpassword"));
        nameValuePairs.add(new BasicNameValuePair("accountType", "GOOGLE"));
        nameValuePairs.add(new BasicNameValuePair("source",
                "Fleet Tracker Pro"));
        nameValuePairs.add(new BasicNameValuePair("service", "ac2dm"));
        post.setEntity(new UrlEncodedFormEntity(nameValuePairs));
        HttpResponse response = client.execute(post);
        BufferedReader rd = new BufferedReader(new InputStreamReader(
                response.getEntity().getContent()));

        String line = "";
        while ((line = rd.readLine()) != null) {
            if (line.startsWith("Auth=")) {
                String auth = line.substring(5);
                System.out.println("Auth token = " + auth);
                return auth;
            }
        }

注意变量senderId这也应该持有的角色帐户创建并在谷歌的 C2DM注册网页
任何其他电子邮件可以改变任何你喜欢的,但这些以电子邮件必须保持一致。

notice the variable senderId this should also hold the role account you created and signed up for C2DM on the google C2DM signup Page any other email can be changed to whatever you like, but these to emails have to remain identical

下面是从谷歌C2DM 页面在谷歌$ C的定义$ C:

here is the definition from google C2DM page at google code:

发件人ID与应用程序的关联的电子邮件帐户
  开发商。发件人ID是在注册过程中所使用
  确定被允许的邮件发送到Android应用程序
  装置。这个ID是典型而不是基于角色的
  个人account--例如,my-app@gmail.com。

Sender ID An email account associated with the application's developer. The sender ID is used in the registration process to identify a Android application that is permitted to send messages to the device. This ID is typically role-based rather than being a personal account—- for example, my-app@gmail.com.

我希望我帮助有一个愉快的一天。

I hope i helped have a nice day.

本来不错。

这篇关于在C2DM电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆