1

您可以在下面找到清單文件,它們是否與配置GCM推送通知類有關?GCM推送通知未復活

沒有收到通知在所有Android設備上,但蘋果設備接收通知

package="ac.iec" 
<uses-permission android:name="android.permission.WAKE_LOCK"/> 
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/> 

<permission 
    android:name="ac.iec.permission.C2D_MESSAGE" 
    android:protectionLevel="signature"/> 

<uses-permission android:name="ac.iec.permission.C2D_MESSAGE"/> 
    <receiver 
     android:name="com.google.android.gms.gcm.GcmReceiver" 
     android:exported="true" 
     android:permission="com.google.android.c2dm.permission.SEND"> 
     <intent-filter> 
      <action android:name="com.google.android.c2dm.intent.RECEIVE"/> 
      <category android:name="ac.iec"/> 
     </intent-filter> 
    </receiver> 
      <service 
     android:name=".pushnotification.GCMIntentService" 
     android:exported="false"> 
     <intent-filter> 
      <action android:name="com.google.android.c2dm.intent.RECEIVE"/> 
     </intent-filter> 
    </service> 
    <service 
     android:name=".pushnotification.MyInstanceIDListenerService" 
     android:exported="false"> 
     <intent-filter> 
      <action android:name="com.google.android.gms.iid.InstanceID"/> 
     </intent-filter> 
    </service> 
+0

使用非常容易使用的FCM。檢查此鏈接https://developers.google.com/cloud-messaging/android/android-migrate-fcm –

回答

1

你錯過一些user permisssion & reciver一套這樣的方式。

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

此權限設置

<permission 
    android:name="your package name.permission.C2D_MESSAGE" 
    android:protectionLevel="signature" /> 

這個用戶權限

<uses-permission android:name="your package.permission.C2D_MESSAGE" /> 
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> 
<uses-permission android:name="android.permission.VIBRATE" /> 

這個代碼在application側設置。

<!-- GCM Receiver --> 
    <!-- this package name set your broadcast receiver class --> 
    <receiver 

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

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

      <category android:name="main package name" /> 
     </intent-filter> 
    </receiver> 

在你的清單文件中試試這段代碼。 謝謝。