2013-12-08 107 views
-2

我在本文檔http://developer.android.com/google/gcm/client.html的幫助下編寫了推送通知示例。它在4.x設備上工作,而不是在2.3.3設備上工作。推送通知不能在2.3.3上工作並在4.x設備上工作

這裏是我的權限:

<uses-permission android:name="android.permission.WAKE_LOCK" /> 
<uses-permission android:name="android.permission.GET_ACCOUNTS" /> 
<uses-permission android:name="android.permission.INTERNET" /> 

<permission 
    android:name="com.example.testing.permission.C2D_MESSAGE" 
    android:protectionLevel="signature" /> 

<uses-permission android:name="com.example.testing.permission.C2D_MESSAGE" /> 
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> 
<uses-permission android:name="com.google.android.c2dm.permission.REGISTRATION" /> 


    <receiver 
     android:name="com.example.testing.GcmBroadcastReceiver" 
     android:permission="com.google.android.c2dm.permission.SEND" > 
     <intent-filter> 

      <!-- Receives the actual messages. --> 
      <action android:name="com.google.android.c2dm.intent.RECEIVE" /> 
      <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> 

      <category android:name="com.example.testing" /> 
     </intent-filter> 
    </receiver> 

    <service android:name=".GcmIntentService" /> 
+0

你在2.3.3設備上出現什麼錯誤?發佈你的Logcat – Jimi

+0

你能否更精確地得到你的錯誤?這就像是說「我的應用程序不工作,出了什麼問題?」 onReceive()中的 – user1940676

+0

字符串messageType = gcm.getMessageType(intent);總是返回null。 –

回答

1

查找到的文檔:

的android.permission.GET_ACCOUNTS許可作爲GCM需要谷歌帳戶(僅需如果該設備是否運行版本低於Android 4.0.4)

此權限不在示例中。

+0

是的,我添加了該權限。 –

相關問題