C2DM返回应用程序ID为空 [英] c2dm returns Application Id as null

查看:111
本文介绍了C2DM返回应用程序ID为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的机器人,我在执行推送通知有问题。

作为一个教程中,我读出声明,我注册的C2DM并获得身份验证令牌,然后在UrbanAirShip注册,具有包​​XXXX,得到了应用程序键和秘密。

我的项目团队使用API​​ 2.1开始,当时我得到的AppId通过氦运输,无论是在设备和仿真器。

然后,我们改变了API为2.2,在那个时候我又在C2DM注册与另一发件人ID,得到了验证令牌,也再次UrbanAirShip注册新帐号, 拿到钥匙和密码。

有关通过C2DM联运先行试了几次,我得到的AppId,然后我只拿到了空,无论是在设备和仿真器错误,显示如下,

我不知道是什么出了问题,是否改变API层,或多个发送者ID注册的C2DM或多个登记UrbanAirShip为同一个软件包名称或如此多的卸载。     我已经加入清单文件和应用程序的onCreate方法,请指引我找回的AppId。

 < XML版本=1.0编码=UTF-8&GT?;
<舱单的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    包=XXXX
    安卓版code =1
    机器人:VERSIONNAME =1.0>

    <使用-权限的Andr​​oid:名称=android.permission.INTERNET对/>
    <使用-权限的Andr​​oid:名称=android.permission.ACCESS_NETWORK_STATE/>
    <使用-权限的Andr​​oid:名称=android.permission.WRITE_EXTERNAL_STORAG​​E/>
    <使用-权限的Andr​​oid:名称=android.permission.ACCESS_FINE_LOCATION/>
    <使用-权限的Andr​​oid:名称=android.permission.ACCESS_MOCK_LOCATION/>
    <使用-权限的Andr​​oid:名称=android.permission.CAMERA/>
    <使用-权限的Andr​​oid:名称=android.permission.UPDATE_DEVICE_STATS/>
    <使用-权限的Andr​​oid:名称=android.permission.READ_PHONE_STATE>
    < /使用-许可>
    <使用-权限的Andr​​oid:名称=com.android.vending.BILLING/>
    <使用特征的android:NAME =android.hardware.camera/>
    <使用特征的android:NAME =android.hardware.camera.autofocus/>
    <使用-权限的Andr​​oid:名称=android.permission.RECORD_AUDIO/>
    <使用-权限的Andr​​oid:名称=android.permission.RECORD_VIDEO/>
    <使用-权限的Andr​​oid:名称=android.permission.ACCESS_COARSE_LOCATION/>
    <使用-权限的Andr​​oid:名称=android.permission.SEND_SMS/>
    <使用-权限的Andr​​oid:名称=android.permission.RECEIVE_BOOT_COMPLETED/>
    <使用-权限的Andr​​oid:名称=android.permission.VIBRATE/>

     <! - 所需的C2DM  - >
    <! - 只有这个应用程序能够接收消息并注册结果 - >
    <允许机器人:名称=XXXX安卓的ProtectionLevel =签名/>
    <使用-权限的Andr​​oid:名称=xxxx.permission.C2D_MESSAGE/>
    <  - !此应用程序有权限注册和接收消息 - >
    <使用-权限的Andr​​oid:名称=com.google.android.c2dm.permission.RECEIVE/>

    <支持屏
        机器人:anyDensity =真
        机器人:largeScreens =真
        机器人:normalScreens =真
        机器人:smallScreens =真/>

    <用途-SDK
        安卓的minSdkVersion =4
        机器人:targetSdkVersion =10/>

    <应用
        机器人:图标=@可绘制/标志
        机器人:标签=@字符串/ APP_NAME
        机器人:名称=XX
        机器人:可调试=真
        机器人:allowClearUserData =真
        机器人:启用=真正的>

        <活动
            机器人:标签=@字符串/ APP_NAME
            机器人:名称=。activities.SplashActivity
            机器人:screenOrientation =画像>
            <意向滤光器>
                <作用机器人:名称=android.intent.action.MAIN/>

                <类机器人:名称=android.intent.category.LAUNCHER/>
            &所述; /意图滤光器>
        < /活性GT;
....
<! -  REQUIRED  - >
        <接收器的Andr​​oid版本:NAME =com.urbanairship.CoreReceiver>
            <! -  REQUIRED的IntentFilter  - 氦和混合 - >
            <意向滤光器>
              <作用机器人:名称=android.intent.action.BOOT_COMPLETED/>
              <作用机器人:名称=android.intent.action.ACTION_SHUTDOWN/>
            &所述; /意图滤光器>
        < /接收器>

        <! - 所需的C2DM和混合 - >
        <接收器的Andr​​oid版本:NAME =com.urbanairship.push.c2dm.C2DMPushReceiver
                机器人:权限=com.google.android.c2dm.permission.SEND>
          <! - 收到实际的消息 - >
          <意向滤光器>
              <作用机器人:名称=com.google.android.c2dm.intent.RECEIVE/>
              <类机器人:名称=XXXX/>
          &所述; /意图滤光器>
          <! - 收到的注册ID  - >
          <意向滤光器>
              <作用机器人:名称=com.google.android.c2dm.intent.REGISTRATION/>
              <类机器人:名称=XXXX/>
          &所述; /意图滤光器>
        < /接收器>

        <! -  REQUIRED  - >
        <  - 在安卓进程的!参数是可选的。将其设置为一个值开始
            用冒号(:),使其在一个独立的运行,
            私人过程 - >
        <服务机器人:名称=com.urbanairship.push.PushService
                机器人:工艺=:com.urbanairship.push.process/>

        <! - 可选的,如果您想接收推,推打开,登记完成意图 - >
        <接收器的Andr​​oid版本:NAME =xxx.push_notifications.IntentReceiver/>


        <服务机器人:名称=xxx.inapp.BillingService/>

        <接收器的Andr​​oid版本:NAME =xxx.inapp.BillingReceiver>
            <意向滤光器>
                <作用机器人:名称=com.android.vending.billing.IN_APP_NOTIFY/>
                <作用机器人:名称=com.android.vending.billing.RESPONSE_ code/>
                <作用机器人:名称=com.android.vending.billing.PURCHASE_STATE_CHANGED/>
            &所述; /意图滤光器>
        < /接收器>

    < /用途>

< /舱单>
 

解决方案

您需要确保您使用的是谷歌API的版本,你需要的SDK,并且也有这是市场启用了一个有效的谷歌帐户。这是为C2DM一个要求。

I am new to android, i am having issue in implementing push notification.

As stated in a tutorial I read, i registered in c2dm and got Auth token, then registered in UrbanAirShip, with package xxxx, got app key and secret.

My project team used API 2.1 initially, at that time i got AppId through helium transport, both in device and in emulator.

Then we changed API into 2.2, at that time i again registered in c2dm with another sender id, got Auth token, and also again registered in UrbanAirShip with new account, got key and secret.

For first few tries through c2dm transport, i got AppId, then i got only null, both in device and in emulator with errors as showed below,

I don't know what gone wrong, whether change in API level, or multiple sender id registration in c2dm, or multiple registration in UrbanAirShip for same package name or So many uninstalls. I have added Manifest file and Application's oncreate method , please guide me to get back AppId.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="xxxx"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.UPDATE_DEVICE_STATS" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" >
    </uses-permission>
    <uses-permission android:name="com.android.vending.BILLING" />
    <uses-feature android:name="android.hardware.camera" />
    <uses-feature android:name="android.hardware.camera.autofocus" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.RECORD_VIDEO" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.SEND_SMS" />    
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
    <uses-permission android:name="android.permission.VIBRATE"/>

     <!-- REQUIRED for C2DM  -->
    <!-- Only this application can receive the messages and registration result -->
    <permission android:name="xxxx" android:protectionLevel="signature" />
    <uses-permission android:name="xxxx.permission.C2D_MESSAGE" /> 
    <!-- This app has permission to register and receive message -->
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />

    <supports-screens
        android:anyDensity="true"
        android:largeScreens="true"
        android:normalScreens="true"
        android:smallScreens="true" />

    <uses-sdk
        android:minSdkVersion="4"
        android:targetSdkVersion="10" />

    <application
        android:icon="@drawable/logo"
        android:label="@string/app_name"
        android:name="xx"
        android:debuggable="true"
        android:allowClearUserData="true"
        android:enabled="true" >

        <activity
            android:label="@string/app_name"
            android:name=".activities.SplashActivity"
            android:screenOrientation="portrait" >
            <intent-filter >
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
....
<!-- REQUIRED -->
        <receiver android:name="com.urbanairship.CoreReceiver">
            <!-- REQUIRED IntentFilter - For Helium and Hybrid -->
            <intent-filter>
              <action android:name="android.intent.action.BOOT_COMPLETED" />
              <action android:name="android.intent.action.ACTION_SHUTDOWN" />
            </intent-filter>
        </receiver>

        <!-- REQUIRED for C2DM and Hybrid -->
        <receiver android:name="com.urbanairship.push.c2dm.C2DMPushReceiver"
                android:permission="com.google.android.c2dm.permission.SEND">
          <!-- Receive the actual message -->
          <intent-filter>
              <action android:name="com.google.android.c2dm.intent.RECEIVE" />
              <category android:name="xxxx" />
          </intent-filter>
          <!-- Receive the registration id -->
          <intent-filter>
              <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
              <category android:name="xxxx" />
          </intent-filter>
        </receiver>

        <!-- REQUIRED -->
        <!-- The 'android:process' parameter is optional. Set it to a value starting
            with a colon (:) to make it run in a separate,
            private process -->
        <service android:name="com.urbanairship.push.PushService"
                android:process=":com.urbanairship.push.process"/>

        <!-- OPTIONAL, if you want to receive push, push opened and registration completed intents -->
        <receiver android:name="xxx.push_notifications.IntentReceiver" />


        <service android:name="xxx.inapp.BillingService" />

        <receiver android:name="xxx.inapp.BillingReceiver" >
            <intent-filter >
                <action android:name="com.android.vending.billing.IN_APP_NOTIFY" />
                <action android:name="com.android.vending.billing.RESPONSE_CODE" />
                <action android:name="com.android.vending.billing.PURCHASE_STATE_CHANGED" />
            </intent-filter>
        </receiver>

    </application>

</manifest>

解决方案

You need to make sure you are using the "google api" version of the SDK you want, and also to have a valid google account which is market enabled. This is a requirement for c2dm.

这篇关于C2DM返回应用程序ID为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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